Package xal.tools.math.r3
Class R3
- All Implemented Interfaces:
Serializable
,IArchive
Represents an element of R^3, the three-dimensional cartesian real space.
- Author:
- Christopher Allen
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
ClassR3x3.IND
is an enumeration of the matrix indices for theR3x3
class. -
Field Summary
FieldsFields inherited from class xal.tools.math.BaseVector
ATTR_DATA
-
Constructor Summary
ConstructorsConstructorDescriptionR3()
Creates a new instance of R3, the zero element.R3
(double[] arrVals) Creates a new instance of R3 initialized to argument.R3
(double x1, double x2, double x3) Creates a new instance of R3 initialized to arguments.Create a new instance of R3 with specified initial value specified by the formatted string argument.R3
(DataAdaptor daSource) Initializing constructor forR3
.Creates a new instance of R3 initialized to argument. -
Method Summary
Modifier and TypeMethodDescriptionApply coordinate transform from cartesian to cylindrical coordinates.Apply coordinate transform from cartesian to spherical coordinates.clone()
Creates and returns a deep copy of this vector.copy()
Performs a deep copy operation.Apply coordinate transform from cylindrical to cartesian coordinatesdouble
get1()
Return first coordinate value.double
get2()
Return second coordinate value.double
get3()
Return third coordinate value.double
getx()
Return first coordinate value.double
gety()
Return second coordinate value.double
getz()
Return third coordinate value.protected R3
newInstance
(double[] arrVecInt) Creates a new instance of this vector type with the given Java array as the internal representation.protected R3
newInstance
(int size) Handles object creation required by the base class.static R3
Create a new instance of R3 with initial value determined by the formatted string argument.void
set
(int i, double val) Set index to value.void
set1
(double x1) Set first coordinate value.void
set2
(double x2) Set second coordinate value.void
set3
(double x3) Set third coordinate value.void
setAll
(double s) Set all coordinates to valuevoid
setx
(double x) Set first coordinate value.void
sety
(double y) Set second coordinate value.void
setz
(double z) Set third coordinate value.Apply coordinate tranform from spherical to cartesian coordinatessquared()
Returns the vector of squared elements.Vector multiplication using three-dimensional cross product.double[]
toArray()
Get all the vector values as a 3-array.toString()
Convert the vector contents to a string.static R3
zero()
Create a new instance of the zero vector.Methods inherited from class xal.tools.math.BaseVector
assignUnity, assignZero, copyVector, embedIn, equals, getArrayCopy, getElem, getElem, getSize, getVector, hashCode, innerProd, isEquivalentTo, leftMultiply, load, minus, minusEquals, negate, negateEquals, newInstance, norm1, norm2, normInf, plus, plusEquals, print, print, println, projectOnto, rightMultiply, save, setElem, setElem, setVector, setVector, setVector, times, timesEquals
-
Field Details
-
INT_SIZE
public static final int INT_SIZEnumber of dimensions (DIM=3)- See Also:
-
-
Constructor Details
-
R3
public R3()Creates a new instance of R3, the zero element. -
R3
public R3(double x1, double x2, double x3) Creates a new instance of R3 initialized to arguments.- Parameters:
x1
- first coordinate valuex2
- first coordinate valuex3
- first coordinate value
-
R3
Creates a new instance of R3 initialized to argument. If the initializing array has length greater than 3 the first three values are taken, if it has length less than three then the remain coordinates of the newR3
object are zero.- Parameters:
arrVals
- double array of initializing values- Throws:
IllegalArgumentException
- the argument must have the same length as this vector
-
R3
Creates a new instance of R3 initialized to argument.- Parameters:
vecPt
- deep copies this value
-
R3
Create a new instance of R3 with specified initial value specified by the formatted string argument.
The string should be formatted as
"(x,y,z)"
where x, y, z are floating point representations.- Parameters:
strTokens
- token string representing values phase coordinates- Throws:
IllegalArgumentException
- wrong number of tokens in argument (must be 6 or 7)NumberFormatException
- bad numeric value, unparseable
-
R3
Initializing constructor forR3
. Initial values are taken from the data source provided. The values are parsed from a numeric string and identified by the tagBaseVector#ATTR_Data
.- Parameters:
daSource
- interface to data source containing initialization data- Since:
- Nov 5, 2013
-
-
Method Details
-
zero
Create a new instance of the zero vector.- Returns:
- zero vector
-
parse
Create a new instance of R3 with initial value determined by the formatted string argument. The string should be formatted as "(x,y,z)" where x, y, z are floating point representations.- Parameters:
strTokens
- six-token string representing values phase coordinates- Returns:
- 3-vector built from the given string representation
- Throws:
IllegalArgumentException
- wrong number of tokens in argument (must be 6)NumberFormatException
- bad numeric value, unparseable
-
copy
Performs a deep copy operation.- Returns:
- cloned R3 object
-
set
Set index to value.- Parameters:
i
- element index 0<=i<=2val
- new element value- Throws:
ArrayIndexOutOfBoundsException
- the index i was greater than 2
-
set1
public void set1(double x1) Set first coordinate value.- Parameters:
x1
- first coordinate of 3-vector
-
set2
public void set2(double x2) Set second coordinate value.- Parameters:
x2
- second coordinate of 3-vector
-
set3
public void set3(double x3) Set third coordinate value.- Parameters:
x3
- third coordinate of 3-vector
-
setx
public void setx(double x) Set first coordinate value.- Parameters:
x
- first coordinate of 3-vector
-
sety
public void sety(double y) Set second coordinate value.- Parameters:
y
- second coordinate of 3-vector
-
setz
public void setz(double z) Set third coordinate value.- Parameters:
z
- first coordinate of 3-vector
-
setAll
public void setAll(double s) Set all coordinates to value- Parameters:
s
- new value of all vector coordinates
-
toArray
public double[] toArray()Get all the vector values as a 3-array.- Returns:
- the array {x1, x2, x3}.
-
get1
public double get1()Return first coordinate value.- Returns:
- the first vector coordinate
-
get2
public double get2()Return second coordinate value.- Returns:
- the second coordinate vector
-
get3
public double get3()Return third coordinate value.- Returns:
- the third coordinate vector
-
getx
public double getx()Return first coordinate value.- Returns:
- the first coordinate vector
-
gety
public double gety()Return second coordinate value.- Returns:
- the second coordinate vector
-
getz
public double getz()Return third coordinate value.- Returns:
- the third coordinate vector
-
clone
Creates and returns a deep copy of this vector.- Specified by:
clone
in classBaseVector<R3>
- Since:
- Jul 3, 2014
- See Also:
-
toString
Convert the vector contents to a string.- Overrides:
toString
in classBaseVector<R3>
- Returns:
- vector value as a string (x, y, z)
-
cartesian2Cylindrical
Apply coordinate transform from cartesian to cylindrical coordinates.- Returns:
- polar coordinates (r,phi,z) of this cartesian point
-
cartesian2Spherical
Apply coordinate transform from cartesian to spherical coordinates.- Returns:
- polar coordinates (r, theta, phi) of this cartesian point
-
cylindrical2Cartesian
Apply coordinate transform from cylindrical to cartesian coordinates- Returns:
- cartesian coordinates (x,y,z) of this cylindrical point
-
spherical2Cartesian
Apply coordinate tranform from spherical to cartesian coordinates- Returns:
- cartesian coordinates (x,y,z) of this sphereical point
-
times
Vector multiplication using three-dimensional cross product.- Parameters:
r
- second (right) operand in cross-product (this is first operand)- Returns:
- result of vector cross product in three space
-
squared
Returns the vector of squared elements.- Returns:
- the vector (x12, x22, x32)
- Since:
- Aug 25, 2011
-
newInstance
Handles object creation required by the base class.- Specified by:
newInstance
in classBaseVector<R3>
- Returns:
- uninitialized vector object of type
V
- Since:
- Jun 17, 2014
- See Also:
-
xal.tools.math.BaseVector#newInstance()
-
newInstance
Description copied from class:BaseVector
Creates a new instance of this vector type with the given Java array as the internal representation.- Specified by:
newInstance
in classBaseVector<R3>
- Parameters:
arrVecInt
- new vector's guts- Returns:
- new instance of this vector type with the internal representation
- Since:
- Jul 24, 2015 by Christopher K. Allen
- See Also:
-