math.geom3d
Class Vector3D
- java.lang.Object
-
- math.geom3d.Vector3D
-
public class Vector3D extends java.lang.ObjectDefine a vector in 3 Dimensions. Provides methods to compute cross product and dot product, addition and subtraction of vectors.
-
-
Constructor Summary
Constructors Constructor and Description Vector3D()Constructs a new Vector3D initialized with x=1, y=0 and z=0.Vector3D(double x, double y, double z)Base constructor, using coordinates in each direction.Vector3D(Point3D point)Construct a new vector between origin and a 3D point.Vector3D(Point3D point1, Point3D point2)construct a new vector between two points
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static Vector3DcrossProduct(Vector3D v1, Vector3D v2)Computes the cross product of the two vectors.static doubledotProduct(Vector3D v1, Vector3D v2)Computes the dot product of the two vectors, defined by :booleanequals(java.lang.Object obj)doublegetX()doublegetY()doublegetZ()static booleanisColinear(Vector3D v1, Vector3D v2)test if the two vectors are colinearstatic booleanisOrthogonal(Vector3D v1, Vector3D v2)test if the two vectors are orthogonalVector3Dminus(Vector3D v)Return the subtraction of current vector with vector given as parameter.doublenorm()Computes the norm of the vectorVector3Dnormalize()Returns the vector with same direction as this one, but with norm equal to 1.doublenormSq()Computes the square of the norm of the vector.Vector3Dopposite()Returns the opposite vector v2 of this, such that the sum of this and v2 equals the null vector.Vector3Dplus(Vector3D v)Return the sum of current vector with vector given as parameter.Vector3Dtimes(double k)Multiplies this vector by a constant.Vector3Dtransform(AffineTransform3D trans)Transform the vector, by using only the first 4 parameters of the transform.
-
-
-
Constructor Detail
-
Vector3D
public Vector3D()
Constructs a new Vector3D initialized with x=1, y=0 and z=0.
-
Vector3D
public Vector3D(double x, double y, double z)Base constructor, using coordinates in each direction.
-
Vector3D
public Vector3D(Point3D point)
Construct a new vector between origin and a 3D point.
-
-
Method Detail
-
dotProduct
public static final double dotProduct(Vector3D v1, Vector3D v2)
Computes the dot product of the two vectors, defined by :x1*x2 + y1*y2 + z1*z2Dot product is zero if the vectors defined by the 2 vectors are orthogonal. It is positive if vectors are in the same direction, and negative if they are in opposite direction.
-
crossProduct
public static final Vector3D crossProduct(Vector3D v1, Vector3D v2)
Computes the cross product of the two vectors. Cross product is zero for colinear vectors. It is positive if angle between vector 1 and vector 2 is comprised between 0 and PI, and negative otherwise.
-
isColinear
public static final boolean isColinear(Vector3D v1, Vector3D v2)
test if the two vectors are colinear- Returns:
- true if the vectors are colinear
-
isOrthogonal
public static final boolean isOrthogonal(Vector3D v1, Vector3D v2)
test if the two vectors are orthogonal- Returns:
- true if the vectors are orthogonal
-
getX
public double getX()
-
getY
public double getY()
-
getZ
public double getZ()
-
plus
public Vector3D plus(Vector3D v)
Return the sum of current vector with vector given as parameter. Inner fields are not modified.
-
minus
public Vector3D minus(Vector3D v)
Return the subtraction of current vector with vector given as parameter. Inner fields are not modified.
-
times
public Vector3D times(double k)
Multiplies this vector by a constant.
-
opposite
public Vector3D opposite()
Returns the opposite vector v2 of this, such that the sum of this and v2 equals the null vector.- Returns:
- the vector opposite to
this.
-
norm
public double norm()
Computes the norm of the vector- Returns:
- the euclidean norm of the vector
-
normSq
public double normSq()
Computes the square of the norm of the vector. This avoids to compute the square root.- Returns:
- the euclidean norm of the vector
-
normalize
public Vector3D normalize()
Returns the vector with same direction as this one, but with norm equal to 1.
-
transform
public Vector3D transform(AffineTransform3D trans)
Transform the vector, by using only the first 4 parameters of the transform. Translation of a vector returns the same vector.- Parameters:
trans- an affine transform- Returns:
- the transformed vector.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG