Package me.autobot.lib.math.coordinates
Class Vector3d
java.lang.Object
me.autobot.lib.math.coordinates.Vector3d
A class representing a 3D vector.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds another vector to this vector (and returns a new vector).doubleGets the angle between this vector and another vector.Cross product of this vector and another vector (and returns a new vector).doubleDot product of this vector and another vector.doublegetX()Gets the x component of the vector.doublegetY()Gets the y component of the vector.doublegetZ()Gets the z component of the vector.doubleReturns the magnitude of the vector.Returns a new vector that is the normalized version of this vector.rotateBy(Rotation3d rotation) Returns a new vector that's this rotated by the given Rotation3d.scale(double scalar) Scales the vector by a scalar (and returns a new vector).voidsetX(double x) Sets the x component of the vector.voidsetY(double y) Sets the y component of the vector.voidsetZ(double z) Sets the z component of the vector.Subtracts another vector from this vector (and returns a new vector).toPolar()Converts the vector to a polar vector.Converts the vector to a spherical vector.toString()Returns a string representation of the vector.toXY()Converts the vector to a 2D vector (x, y).toXZ()Converts the vector to a 2D vector (x, z).toYZ()Converts the vector to a 2D vector (y, z).static Vector3dzero()Creates a 3D zero vector
-
Constructor Details
-
Vector3d
public Vector3d(double x, double y, double z) Creates a new 3D vector object.- Parameters:
x- The x component of the vector.y- The y component of the vector.z- The z component of the vector.
-
-
Method Details
-
zero
Creates a 3D zero vector- Returns:
- The zero vector
-
getX
public double getX()Gets the x component of the vector.- Returns:
- The x component of the vector.
-
setX
public void setX(double x) Sets the x component of the vector.- Parameters:
x- The new x component of the vector.
-
getY
public double getY()Gets the y component of the vector.- Returns:
- The y component of the vector.
-
setY
public void setY(double y) Sets the y component of the vector.- Parameters:
y- The new y component of the vector.
-
getZ
public double getZ()Gets the z component of the vector.- Returns:
- The z component of the vector.
-
setZ
public void setZ(double z) Sets the z component of the vector.- Parameters:
z- The new z component of the vector.
-
add
Adds another vector to this vector (and returns a new vector).- Parameters:
other- The other vector to add to this vector.- Returns:
- The new vector that is the sum of this vector and the other vector.
-
subtract
Subtracts another vector from this vector (and returns a new vector).- Parameters:
other- The other vector to subtract from this vector.- Returns:
- The new vector that is the difference of this vector and the other vector.
-
scale
Scales the vector by a scalar (and returns a new vector).- Parameters:
scalar- The scalar to scale the vector by.- Returns:
- The new vector that is the scaled version of this vector.
-
dot
Dot product of this vector and another vector.- Parameters:
other- The other vector to dot this vector with.- Returns:
- The dot product of this vector and the other vector.
-
cross
Cross product of this vector and another vector (and returns a new vector).- Parameters:
other- The other vector to cross this vector with.- Returns:
- The new vector that is the cross product of this vector and the other vector.
-
magnitude
public double magnitude()Returns the magnitude of the vector.- Returns:
- The magnitude of the vector.
-
normalize
Returns a new vector that is the normalized version of this vector.- Returns:
- The normalized version of this vector.
-
angle
Gets the angle between this vector and another vector.- Parameters:
other- The other vector to get the angle between.- Returns:
- The angle between this vector and the other vector.
-
rotateBy
Returns a new vector that's this rotated by the given Rotation3d.- Parameters:
rotation- The Rotation3d to rotate the vector by.- Returns:
- The new vector that's this rotated by the given Rotation3d.
-
toPolar
Converts the vector to a polar vector.- Returns:
- The polar vector representation of this vector.
-
toSpherical
Converts the vector to a spherical vector.- Returns:
- The spherical vector representation of this vector.
-
toXY
Converts the vector to a 2D vector (x, y).- Returns:
- The 2D vector representation of this vector.
-
toXZ
Converts the vector to a 2D vector (x, z).- Returns:
- The 2D vector representation of this vector.
-
toYZ
Converts the vector to a 2D vector (y, z).- Returns:
- The 2D vector representation of this vector.
-
toString
Returns a string representation of the vector.
-