Class JxnVectorAlgebra
- java.lang.Object
-
- JxnVectorAlgebra
-
- All Implemented Interfaces:
JxnCloneableAlgebra
public class JxnVectorAlgebra extends Object implements JxnCloneableAlgebra
Implementation of a vector algebra.
Visualize 3-dimensional vector objects in aJxnPerspectivePlotFrameusing theaddmethods.
Example:#JXN:include/P3dInclude.jxnplot(p3d).add( @JxnVectorAlgebra( 0.6, 0.8, 1.0 ) ).box()
-
-
Field Summary
Fields Modifier and Type Field Description protected static doubleequalityTolerancedouble[]itsVInternal storage.
-
Constructor Summary
Constructors Modifier Constructor Description protectedJxnVectorAlgebra(double[] arr)Creates a vector algebra instance from the arraydouble [] arr.protectedJxnVectorAlgebra(double[] arr, boolean copyInput)Creates a vector algebra instance from the arraydouble [] arr.JxnVectorAlgebra(double lat, double lon, boolean degrees)Creates a 3-dimensional vector of length 1 from latitude-angle and longitude-angle.JxnVectorAlgebra(double x, double y, double z)Creates a 3-dimensional vector ( x, y, z ).JxnVectorAlgebra(JxnVectorAlgebra v)Creates a copy ofv.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description doubleabs()Returns the length (sqrt of the sum of the squares of the components) of this vector object.static doubleabs(JxnVectorAlgebra va)Returns the length (sqrt of the sum of the squares of the components) ofva.JxnVectorAlgebraadd(JxnVectorAlgebra opnd)Addsopndto this vector.JxnCloneableAlgebracloneThis()Called internally.static doublecosphi(JxnVectorAlgebra v1, JxnVectorAlgebra v2)Returns cosine of the angle betweenv1andv2.JxnVectorAlgebradiv(double scalar)Divides this vector byscalar.booleanequals(Object other)Two vector objects are equal, if all corresponding components are equal.doubleget(int i)Returns thei-th component of this vector object.static doublegetEqualityTolerance()Returns the tolerance used for theequalsmethod.doublegetX()Returns the x-component of this vector object.doublegetY()Returns the y-component of this vector object.doublegetZ()Returns the z-component of this vector object.protected doublehypot(double x, double y)ReturnsMath.hypot(double, double).doublelat()Returns the latitude angle of this vector object.static doublelat(JxnVectorAlgebra va)Returns the latitude angle ofva.doublelatD()Returns the latitude angle of this vector object in degrees.static doublelatD(JxnVectorAlgebra va)Returns the latitude angle ofvain degrees.doublelon()Returns the longitude angle of this vector object.static doublelon(JxnVectorAlgebra va)Returns the latitude angle ofva.doublelonD()Returns the longitude angle of this vector object in degrees.static doublelonD(JxnVectorAlgebra va)Returns the latitude angle ofvain degrees.JxnVectorAlgebramul(double scalar)Multiplies this vector byscalar.static JxnVectorAlgebramul(double scalar, JxnVectorAlgebra v)Returnsvscaled byscalar.static JxnVectorAlgebramul(JxnVectorAlgebra v1, JxnVectorAlgebra v2)Returns the vektor productv1×v2.JxnVectorAlgebramulL(double scalar)Multiplies this vector byscalar.static JxnVectorAlgebranormal(JxnVectorAlgebra vr)Finds a normal vector forvr.static intpathCoverage()For test of methodnormal(JxnVectorAlgebra).KmgComplexphasor(IKmg3DProjection p3d)Deprecated.static doublephi(JxnVectorAlgebra v1, JxnVectorAlgebra v2)Returns the angle betweenv1andv2.static doublephiD(JxnVectorAlgebra v1, JxnVectorAlgebra v2)Returns the angle betweenv1andv2in degrees.static doubleprod(JxnVectorAlgebra v1, JxnVectorAlgebra v2)Returns the scalar produktv1·v2.JxnVectorAlgebraset(int i, double vi)Replaces thei-th component of thisJxnVectorAlgebrabyvi.static JxnVectorAlgebraset(JxnVectorAlgebra va, int i, double vi)Returns a copy ofra, with thei-th component replaced byvi.static doublesetEqualityTolerance(double eps)Sets the tolerance for theequalsmethod for all instances of this class.doublesetValue(int i, double vi)Replaces thei-th component of thisJxnVectorAlgebrabyvi.JxnVectorAlgebrasub(JxnVectorAlgebra opnd)Subtractsopndfrom this vector.double[]toArray()Returns an array containing the vector components of this vector object.StringtoString()Returns a String representation of this vector object.
-
-
-
Constructor Detail
-
JxnVectorAlgebra
public JxnVectorAlgebra(double x, double y, double z)Creates a 3-dimensional vector ( x, y, z ).
-
JxnVectorAlgebra
public JxnVectorAlgebra(double lat, double lon, boolean degrees)Creates a 3-dimensional vector of length 1 from latitude-angle and longitude-angle.- Parameters:
degrees- if true, the angles are expected in degrees.
-
JxnVectorAlgebra
protected JxnVectorAlgebra(double[] arr)
Creates a vector algebra instance from the arraydouble [] arr. CallsJxnVectorAlgebra( arr, false )
-
JxnVectorAlgebra
protected JxnVectorAlgebra(double[] arr, boolean copyInput)Creates a vector algebra instance from the arraydouble [] arr.- Parameters:
copyInput- if true, stores a copy of the arrayarr, otherwise stores a reference to the arrayarr.
-
JxnVectorAlgebra
public JxnVectorAlgebra(JxnVectorAlgebra v)
Creates a copy ofv.
-
-
Method Detail
-
cloneThis
public JxnCloneableAlgebra cloneThis()
Description copied from interface:JxnCloneableAlgebraCalled internally. Required to avoid overwriting the left side operandopndLeftinopndLeft op opndRght, ifopis implemented asopndLeft.op(opndRght)and the instance methodopmodifies the instance.- Specified by:
cloneThisin interfaceJxnCloneableAlgebra- Returns:
- copy of this instance
-
add
public JxnVectorAlgebra add(JxnVectorAlgebra opnd)
Addsopndto this vector.- Returns:
- this
-
sub
public JxnVectorAlgebra sub(JxnVectorAlgebra opnd)
Subtractsopndfrom this vector.- Returns:
- this
-
mul
public static JxnVectorAlgebra mul(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns the vektor productv1×v2.- See Also:
- Wikipedia
-
mul
public JxnVectorAlgebra mul(double scalar)
Multiplies this vector byscalar.- Returns:
- this
-
mul
public static JxnVectorAlgebra mul(double scalar, JxnVectorAlgebra v)
Returnsvscaled byscalar.
-
mulL
public JxnVectorAlgebra mulL(double scalar)
Multiplies this vector byscalar.- Returns:
- this
-
div
public JxnVectorAlgebra div(double scalar)
Divides this vector byscalar.- Returns:
- this
-
prod
public static double prod(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns the scalar produktv1·v2.- See Also:
- Wikipedia
-
equals
public boolean equals(Object other)
Two vector objects are equal, if all corresponding components are equal. UsesetEqualityTolerance(double)to set a tolerance for the comparision of the vector components.
-
setEqualityTolerance
public static double setEqualityTolerance(double eps)
Sets the tolerance for theequalsmethod for all instances of this class.- Parameters:
eps-
eps > 0.absolute difference
eps < 0.difference relative to thelengthof the longest of two vectors to be compared- Returns:
- old tolerance
-
getEqualityTolerance
public static double getEqualityTolerance()
Returns the tolerance used for theequalsmethod.
-
toString
public String toString()
Returns a String representation of this vector object.
-
toArray
public double[] toArray()
Returns an array containing the vector components of this vector object.
-
set
public JxnVectorAlgebra set(int i, double vi)
Replaces thei-th component of thisJxnVectorAlgebrabyvi.- Returns:
- this
-
set
public static JxnVectorAlgebra set(JxnVectorAlgebra va, int i, double vi)
Returns a copy ofra, with thei-th component replaced byvi.
-
setValue
public double setValue(int i, double vi)Replaces thei-th component of thisJxnVectorAlgebrabyvi.- Returns:
- the old value
-
get
public double get(int i)
Returns thei-th component of this vector object.
-
getX
public double getX()
Returns the x-component of this vector object.
-
getY
public double getY()
Returns the y-component of this vector object.
-
getZ
public double getZ()
Returns the z-component of this vector object.
-
abs
public double abs()
Returns the length (sqrt of the sum of the squares of the components) of this vector object.
-
abs
public static double abs(JxnVectorAlgebra va)
Returns the length (sqrt of the sum of the squares of the components) ofva.
-
lat
public double lat()
Returns the latitude angle of this vector object.
-
latD
public double latD()
Returns the latitude angle of this vector object in degrees.
-
lat
public static double lat(JxnVectorAlgebra va)
Returns the latitude angle ofva.
-
latD
public static double latD(JxnVectorAlgebra va)
Returns the latitude angle ofvain degrees.
-
lon
public double lon()
Returns the longitude angle of this vector object.
-
lonD
public double lonD()
Returns the longitude angle of this vector object in degrees.
-
lon
public static double lon(JxnVectorAlgebra va)
Returns the latitude angle ofva.
-
lonD
public static double lonD(JxnVectorAlgebra va)
Returns the latitude angle ofvain degrees.
-
hypot
protected double hypot(double x, double y)ReturnsMath.hypot(double, double).
-
phi
public static double phi(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns the angle betweenv1andv2.
-
phiD
public static double phiD(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns the angle betweenv1andv2in degrees.
-
cosphi
public static double cosphi(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns cosine of the angle betweenv1andv2.
-
normal
public static JxnVectorAlgebra normal(JxnVectorAlgebra vr)
Finds a normal vector forvr. Usevn1 = normal( vr ); vn2 = mul( vn1, vr );to get an orthogonal system.
-
pathCoverage
public static int pathCoverage()
For test of methodnormal(JxnVectorAlgebra).
-
phasor
public KmgComplex phasor(IKmg3DProjection p3d)
Deprecated.
-
-