Catalano.Math
Class Vector3
- java.lang.Object
-
- Catalano.Math.Vector3
-
public class Vector3 extends java.lang.Object3D Vector class with X, Y and Z coordinates.The class incapsulates X, Y and Z coordinates of a 3D vector and provides some operations with it.
-
-
Field Summary
Fields Modifier and Type Field and Description floatxX coordinate of the vector.floatyY coordinate of the vector.floatzZ coordinate of the vector.
-
Constructor Summary
Constructors Constructor and Description Vector3()Initialize a new instance of the Vector3 class.Vector3(float value)Initialize a new instance of the Vector3 class.Vector3(float x, float y, float z)Initialize a new instance of the Vector3 class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description Vector3Abs()Calculate absolute values of the vector.static Vector3Add(Vector3 vector, float value)Adds a value to all coordinates of the specified vector.static Vector3Add(Vector3 vector1, Vector3 vector2)Adds corresponding coordinates of two vectors.static Vector3Cross(Vector3 vector1, Vector3 vector2)Calculates cross product of two vectors.static Vector3Divide(Vector3 vector, float factor)Divides coordinates of the specified vector by the specified factor.static Vector3Divide(Vector3 vector1, Vector3 vector2)Divides corresponding coordinates of two vectors.static floatDot(Vector3 vector1, Vector3 vector2)Calculates dot product of two vectors.booleanequals(java.lang.Object obj)floatgetMax()Get maximum value of the vector.intgetMaxIndex()Get index of the coordinate with maximum value.floatgetMin()Get minimum value of the vector.intgetMinIndex()Get index of the coordinate with minimum value.Vector3Inverse()Inverse the vector.static Vector3Multiply(Vector3 vector, float factor)Multiplies coordinates of the specified vector by the specified factor.static Vector3Multiply(Vector3 vector1, Vector3 vector2)Multiplies corresponding coordinates of two vectors.floatNorm()Returns vector's normalization.floatNormalize()Normalizes the vector by dividing it’s all coordinates with the vector's norm.floatSquare()Returns square of the vector's norm.static Vector3Subtract(Vector3 vector, float value)Subtracts a value from all coordinates of the specified vector.static Vector3Subtract(Vector3 vector1, Vector3 vector2)Subtracts corresponding coordinates of two vectors.float[]toArray()Returns array representation of the vector.Vector4toVector4()Converts the vector to a 4D vector.
-
-
-
Field Detail
-
x
public float x
X coordinate of the vector.
-
y
public float y
Y coordinate of the vector.
-
z
public float z
Z coordinate of the vector.
-
-
Constructor Detail
-
Vector3
public Vector3()
Initialize a new instance of the Vector3 class.
-
Vector3
public Vector3(float x, float y, float z)Initialize a new instance of the Vector3 class.- Parameters:
x- X coordinate of the vector.y- Y coordinate of the vector.z- Z coordinate of the vector.
-
Vector3
public Vector3(float value)
Initialize a new instance of the Vector3 class.- Parameters:
value- Value, which is set to all 3 coordinates of the vector.
-
-
Method Detail
-
getMax
public float getMax()
Get maximum value of the vector.- Returns:
- Returns maximum value of all 3 vector's coordinates.
-
getMin
public float getMin()
Get minimum value of the vector.- Returns:
- Returns minimum value of all 3 vector's coordinates.
-
getMaxIndex
public int getMaxIndex()
Get index of the coordinate with maximum value.- Returns:
- Index of the coordinate with maximum value.
-
getMinIndex
public int getMinIndex()
Get index of the coordinate with minimum value.- Returns:
- Index of the coordinate with minimum value.
-
Norm
public float Norm()
Returns vector's normalization.- Returns:
- Euclidean normalization of the vector, which is a square root of the sum.
-
Square
public float Square()
Returns square of the vector's norm.- Returns:
- Square of the vector's norm.
-
toArray
public float[] toArray()
Returns array representation of the vector.- Returns:
- Array with 3 values containing X/Y/Z coordinates.
-
Add
public static Vector3 Add(Vector3 vector1, Vector3 vector2)
Adds corresponding coordinates of two vectors.- Parameters:
vector1- First vector to use for dot product calculation.vector2- Second vector to use for dot product calculation.- Returns:
- Returns a vector which coordinates are equal to sum of corresponding coordinates of the two specified vectors.
-
Add
public static Vector3 Add(Vector3 vector, float value)
Adds a value to all coordinates of the specified vector.- Parameters:
vector- Vector to add the specified value to.value- Value to add to all coordinates of the vector.- Returns:
- Returns new vector with all coordinates increased by the specified value.
-
Subtract
public static Vector3 Subtract(Vector3 vector1, Vector3 vector2)
Subtracts corresponding coordinates of two vectors.- Parameters:
vector1- First vector to use for dot product calculation.vector2- Second vector to use for dot product calculation.- Returns:
- Returns a vector which coordinates are equal to difference of corresponding coordinates of the two specified vectors.
-
Subtract
public static Vector3 Subtract(Vector3 vector, float value)
Subtracts a value from all coordinates of the specified vector.- Parameters:
vector- Vector to subtract the specified value from.value- Value to subtract from all coordinates of the vector.- Returns:
- Returns new vector with all coordinates decreased by the specified value.
-
Multiply
public static Vector3 Multiply(Vector3 vector1, Vector3 vector2)
Multiplies corresponding coordinates of two vectors.- Parameters:
vector1- The first vector to multiply.vector2- The second vector to multiply.- Returns:
- Returns a vector which coordinates are equal to multiplication of corresponding coordinates of the two specified vectors.
-
Multiply
public static Vector3 Multiply(Vector3 vector, float factor)
Multiplies coordinates of the specified vector by the specified factor.- Parameters:
vector- Vector to multiply coordinates of.factor- Factor to multiple coordinates of the specified vector by.- Returns:
- Returns new vector with all coordinates multiplied by the specified factor.
-
Divide
public static Vector3 Divide(Vector3 vector1, Vector3 vector2)
Divides corresponding coordinates of two vectors.- Parameters:
vector1- The first vector to divide.vector2- The second vector to divide.- Returns:
- Returns a vector which coordinates are equal to coordinates of the first vector divided by corresponding coordinates of the second vector.
-
Divide
public static Vector3 Divide(Vector3 vector, float factor)
Divides coordinates of the specified vector by the specified factor.- Parameters:
vector- Vector to divide coordinates of.factor- Factor to divide coordinates of the specified vector by.- Returns:
- Returns new vector with all coordinates divided by the specified factor.
-
Normalize
public float Normalize()
Normalizes the vector by dividing it’s all coordinates with the vector's norm.- Returns:
- Returns the value of vectors’ norm before normalization.
-
Inverse
public Vector3 Inverse()
Inverse the vector.- Returns:
- Returns a vector with all coordinates equal to 1.0 divided by the value of corresponding coordinate in this vector (or equal to 0.0 if this vector has corresponding coordinate also set to 0.0).
-
Abs
public Vector3 Abs()
Calculate absolute values of the vector.- Returns:
- Returns a vector with all coordinates equal to absolute values of this vector's coordinates.
-
Cross
public static Vector3 Cross(Vector3 vector1, Vector3 vector2)
Calculates cross product of two vectors.- Parameters:
vector1- First vector to use for cross product calculation.vector2- Second vector to use for cross product calculation.- Returns:
- Returns cross product of the two specified vectors.
-
Dot
public static float Dot(Vector3 vector1, Vector3 vector2)
Calculates dot product of two vectors.- Parameters:
vector1- First vector to use for dot product calculation.vector2- Second vector to use for dot product calculation.- Returns:
- Returns dot product of the two specified vectors.
-
toVector4
public Vector4 toVector4()
Converts the vector to a 4D vector.The method returns a 4D vector which has X, Y and Z coordinates equal to the coordinates of this 3D vector and Vector.W coordinate set to 1.0. - Returns:
- Returns 4D vector which is an extension of the 3D vector.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG