Class Vector3D
java.lang.Object
org.chsrobotics.lib.math.geometry.Vector3D
- Direct Known Subclasses:
Vector2D
Represents a 3-dimensional vector in a right-handed system.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds two vectors.crossProduct(Vector3D other) Performs the cross product operation (sum of the perpindicular component vectors) between two vectors.doubledotProduct(Vector3D other) Performs the dot product operation (sum of the product of parallel component vector signed magnitudes) between two vectors.booleandoubleReturns the magnitude of the vector as an unsigned (always positive) double.doublegetX()Returns the X (i-hat, positive to the horizontal right on a graph) component of the vector.doublegetY()Returns the Y (j-hat, positive up vertically on a graph) component of the vector.doublegetZ()Returns the Z (k-hat, positive out of the graph) component of the vector.inthashCode()scalarDivide(double scalar) Divides the vector by a scalar.scalarMultiply(double scalar) Multiplies the vector by a scalar.Subtracts two vectors.toString()
-
Constructor Details
-
Vector3D
public Vector3D(double x, double y, double z) Constructs a 3-dimensional vector.- Parameters:
x- The signed X (i-hat, positive to the horizontal right on a graph) component of the vector.y- The signed Y (j-hat, positive up vertically on a graph) component of the vector.z- The signed Z (k-hat, positive out of the graph) component of the vector.
-
-
Method Details
-
getMagnitude
public double getMagnitude()Returns the magnitude of the vector as an unsigned (always positive) double.- Returns:
- The unsigned magnitude.
-
add
Adds two vectors.- Parameters:
other- The other vector (order does not matter).- Returns:
- The result of vector addition.
-
subtract
Subtracts two vectors.- Parameters:
other- The other vector.- Returns:
- The result of vector subtraction.
-
dotProduct
Performs the dot product operation (sum of the product of parallel component vector signed magnitudes) between two vectors.- Parameters:
other- The other vector (order does not matter).- Returns:
- The scalar result of the dot product.
-
crossProduct
Performs the cross product operation (sum of the perpindicular component vectors) between two vectors.- Parameters:
other- The other vector (order *does* matter).- Returns:
- The result of the cross product.
-
scalarMultiply
Multiplies the vector by a scalar.- Parameters:
scalar- The double scalar to multiply by.- Returns:
- The result of the multiplication operation.
-
scalarDivide
Divides the vector by a scalar. Ifscalaris 0, will return this vector unchanged.- Parameters:
scalar- The double scalar to divide by.- Returns:
- The result of the division operation.
-
getX
public double getX()Returns the X (i-hat, positive to the horizontal right on a graph) component of the vector.- Returns:
- The signed X component.
-
getY
public double getY()Returns the Y (j-hat, positive up vertically on a graph) component of the vector.- Returns:
- The signed Y component.
-
getZ
public double getZ()Returns the Z (k-hat, positive out of the graph) component of the vector.- Returns:
- The signed Z component.
-
equals
-
hashCode
public int hashCode() -
toString
-