Package xal.tools.math.r2
Class R2
java.lang.Object
xal.tools.math.r2.R2
- All Implemented Interfaces:
Serializable
Class representing a point on the plane in R2.
- Author:
- Christopher Allen
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionApply coordinate transform from cartesian to polar coordinates.copy()
Performs a deep copy operation.double
get1()
Return first coordinate value.double
get2()
Return second coordinate value.double
getx()
Return first coordinate value.double
gety()
Return second coordinate value.Vector subtraction.double
norm2()
Compute the l2 norm of the vector in R2.Vector addition.Apply coordinate transform from polar to cartesian coordinatesvoid
print
(PrintWriter os) Print out centents on an output stream.void
println
(PrintWriter os) Print out centents on an output stream, terminate with new line character.void
set
(double s) Set all coordinates to valuevoid
set1
(double x1) Set first coordinate value.void
set2
(double x2) Set second coordinate value.void
setx
(double x) Set first coordinate value.void
sety
(double y) Set second coordinate value.times
(double s) Scalar multiplication.Vector multiplication, i.e. complex multiplication.toString()
Convert to a string representation
-
Constructor Details
-
R2
public R2()Creates a new instance of R2, the zero element. -
R2
public R2(double x1, double x2) Creates a new instance of R2 initialized to arguments.- Parameters:
x1
- first coordinate valuex2
- first coordinate value
-
R2
Creates a new instance of R2 initialized to argument.- Parameters:
vecPt
- deep copies this value
-
-
Method Details
-
copy
Performs a deep copy operation.- Returns:
- cloned R3 object
-
set1
public void set1(double x1) Set first coordinate value. -
set2
public void set2(double x2) Set second coordinate value. -
setx
public void setx(double x) Set first coordinate value. -
sety
public void sety(double y) Set second coordinate value. -
set
public void set(double s) Set all coordinates to value -
get1
public double get1()Return first coordinate value. -
get2
public double get2()Return second coordinate value. -
getx
public double getx()Return first coordinate value. -
gety
public double gety()Return second coordinate value. -
cartesian2Polar
Apply coordinate transform from cartesian to polar coordinates.- Returns:
- polar coordinates (r,phi) of this cartesian point
-
polar2Cartesian
Apply coordinate transform from polar to cartesian coordinates- Returns:
- cartesian coordinates (x,y) of this polar point
-
times
Scalar multiplication.- Parameters:
s
- scalar to multiply this vector- Returns:
- new R2 object scaled by s
-
plus
Vector addition.- Parameters:
r
- vector displacement- Returns:
- new R3 object equal to this displaced by r
-
minus
Vector subtraction.- Parameters:
r
- vector displacement- Returns:
- new R3 object equal to this displaced by r
-
times
Vector multiplication, i.e. complex multiplication.- Parameters:
r
- second (right) operand in cross-product (this is first operand)- Returns:
- result of vector cross product in three space
-
norm2
public double norm2()Compute the l2 norm of the vector in R2.- Returns:
- l2 norm = (x1^2 + x2^2)^1/2
-
toString
Convert to a string representation -
print
Print out centents on an output stream.- Parameters:
os
- output stream receive content dump
-
println
Print out centents on an output stream, terminate with new line character.- Parameters:
os
- output stream receive content dump
-