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 aJxnPerspectivePlotFrame
using theadd
methods.
Example:#JXN:include/P3dInclude.jxn
plot(p3d)
.
add
( @JxnVectorAlgebra( 0.6, 0.8, 1.0 ) )
.
box
()
-
-
Field Summary
Fields Modifier and Type Field Description protected static double
equalityTolerance
double[]
itsV
Internal storage.
-
Constructor Summary
Constructors Modifier Constructor Description protected
JxnVectorAlgebra(double[] arr)
Creates a vector algebra instance from the arraydouble [] arr
.protected
JxnVectorAlgebra(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 double
abs()
Returns the length (sqrt of the sum of the squares of the components) of this vector object.static double
abs(JxnVectorAlgebra va)
Returns the length (sqrt of the sum of the squares of the components) ofva
.JxnVectorAlgebra
add(JxnVectorAlgebra opnd)
Addsopnd
to this vector.JxnCloneableAlgebra
cloneThis()
Called internally.static double
cosphi(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns cosine of the angle betweenv1
andv2
.JxnVectorAlgebra
div(double scalar)
Divides this vector byscalar
.boolean
equals(Object other)
Two vector objects are equal, if all corresponding components are equal.double
get(int i)
Returns thei
-th component of this vector object.static double
getEqualityTolerance()
Returns the tolerance used for theequals
method.double
getX()
Returns the x-component of this vector object.double
getY()
Returns the y-component of this vector object.double
getZ()
Returns the z-component of this vector object.protected double
hypot(double x, double y)
ReturnsMath.hypot(double, double)
.double
lat()
Returns the latitude angle of this vector object.static double
lat(JxnVectorAlgebra va)
Returns the latitude angle ofva
.double
latD()
Returns the latitude angle of this vector object in degrees.static double
latD(JxnVectorAlgebra va)
Returns the latitude angle ofva
in degrees.double
lon()
Returns the longitude angle of this vector object.static double
lon(JxnVectorAlgebra va)
Returns the latitude angle ofva
.double
lonD()
Returns the longitude angle of this vector object in degrees.static double
lonD(JxnVectorAlgebra va)
Returns the latitude angle ofva
in degrees.JxnVectorAlgebra
mul(double scalar)
Multiplies this vector byscalar
.static JxnVectorAlgebra
mul(double scalar, JxnVectorAlgebra v)
Returnsv
scaled byscalar
.static JxnVectorAlgebra
mul(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns the vektor productv1
×v2
.JxnVectorAlgebra
mulL(double scalar)
Multiplies this vector byscalar
.static JxnVectorAlgebra
normal(JxnVectorAlgebra vr)
Finds a normal vector forvr
.static int
pathCoverage()
For test of methodnormal(JxnVectorAlgebra)
.KmgComplex
phasor(IKmg3DProjection p3d)
Deprecated.static double
phi(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns the angle betweenv1
andv2
.static double
phiD(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns the angle betweenv1
andv2
in degrees.static double
prod(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns the scalar produktv1
·v2
.JxnVectorAlgebra
set(int i, double vi)
Replaces thei
-th component of thisJxnVectorAlgebra
byvi
.static JxnVectorAlgebra
set(JxnVectorAlgebra va, int i, double vi)
Returns a copy ofra
, with thei
-th component replaced byvi
.static double
setEqualityTolerance(double eps)
Sets the tolerance for theequals
method for all instances of this class.double
setValue(int i, double vi)
Replaces thei
-th component of thisJxnVectorAlgebra
byvi
.JxnVectorAlgebra
sub(JxnVectorAlgebra opnd)
Subtractsopnd
from this vector.double[]
toArray()
Returns an array containing the vector components of this vector object.String
toString()
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:JxnCloneableAlgebra
Called internally. Required to avoid overwriting the left side operandopndLeft
inopndLeft op opndRght
, ifop
is implemented asopndLeft.op(opndRght)
and the instance methodop
modifies the instance.- Specified by:
cloneThis
in interfaceJxnCloneableAlgebra
- Returns:
- copy of this instance
-
add
public JxnVectorAlgebra add(JxnVectorAlgebra opnd)
Addsopnd
to this vector.- Returns:
- this
-
sub
public JxnVectorAlgebra sub(JxnVectorAlgebra opnd)
Subtractsopnd
from 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)
Returnsv
scaled 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 theequals
method for all instances of this class.- Parameters:
eps
-
eps > 0.
absolute difference
eps < 0.
difference relative to thelength
of the longest of two vectors to be compared- Returns:
- old tolerance
-
getEqualityTolerance
public static double getEqualityTolerance()
Returns the tolerance used for theequals
method.
-
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 thisJxnVectorAlgebra
byvi
.- 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 thisJxnVectorAlgebra
byvi
.- 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 ofva
in 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 ofva
in 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 betweenv1
andv2
.
-
phiD
public static double phiD(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns the angle betweenv1
andv2
in degrees.
-
cosphi
public static double cosphi(JxnVectorAlgebra v1, JxnVectorAlgebra v2)
Returns cosine of the angle betweenv1
andv2
.
-
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.
-
-