Interface IVector
- All Known Implementing Classes:
CartesianVector
public interface IVector
This interface represents a vector in 3D space.
A vector is a line with a direction and a length.
A vector can be represented by a point in space.
However, there is a much better suited Point2D and Point3D interface
for this purpose.
-
Method Summary
Modifier and TypeMethodDescriptionadd(double value) This method returns a new vector with the X Y Z mods added by the value.This method adds the X Y Z mods of the vector passed in to the X Y Z mods of this vector.default IPoint3DThis method returns a cross-product of this vector and the vector passed in.doubleThis method returns the distance between this vector and the vector passed in.doubledistanceSquared(@NotNull IVector vector) This method returns the distance between this vector and the vector passed in squared.doubleThis method returns the dot product of this vector and the vector passed in.doubleThis method returns the angle between this vector and the vector passed in.default IPoint3DThis method returns the destination point defined by the XYZ mods and the length of the vector.doublegetX()doublegetY()doublegetZ()inverse()This method returns a copy of this vector with the X Y Z mods inverted.doublelength()This method returns the length of this vector.doubleThis method returns the length of this vector squared.multiply(double value) This method returns a new vector with the X Y Z mods multiplied by the value.This method multiplies the X Y Z mods of the vector passed in to the X Y Z mods of this vector.This method returns a copy of this vector with a length of 1.rotate(@NotNull IQuaternion quaternion) This method returns a new vector with the X Y Z mods rotated by the quaternion passed in.
-
Method Details
-
add
This method adds the X Y Z mods of the vector passed in to the X Y Z mods of this vector. The length is recalculated.- Parameters:
vector- The vector to add to this vector.- Returns:
- A new vector with the X Y Z mods added.
-
multiply
This method multiplies the X Y Z mods of the vector passed in to the X Y Z mods of this vector. The length is recalculated.- Parameters:
vector- The vector to multiply to this vector.- Returns:
- A new vector with the X Y Z mods multiplied.
-
add
This method returns a new vector with the X Y Z mods added by the value. The length is recalculated. This is a static input based on the value passed in which will add to each mod of the vector.- Parameters:
value- The value to add to the X Y Z mods.- Returns:
- A new vector with the X Y Z mods added by the value.
-
multiply
This method returns a new vector with the X Y Z mods multiplied by the value. The length is recalculated. This is a static input based on the value passed in which will multiply each mod of the vector.- Parameters:
value- The value to multiply the X Y Z mods by.- Returns:
- A new vector with the X Y Z mods multiplied by the value.
-
inverse
IVector inverse()This method returns a copy of this vector with the X Y Z mods inverted. The length is recalculated. The X Y Z mods are multiplied by -1.- Returns:
- A copy of this vector with the X Y Z mods inverted.
-
normalize
IVector normalize()This method returns a copy of this vector with a length of 1. X Y Z mods all remain unchanged.- Returns:
- A copy of this vector with a length of 1.
-
dot
This method returns the dot product of this vector and the vector passed in. The dot product of two vectors is the sum of the corresponding product components.- Parameters:
vector- The vector to dot product with.- Returns:
- The dot product of this vector and the vector passed in.
-
getAngle
This method returns the angle between this vector and the vector passed in. The angle is in radians. The angle is the angle between the two vectors, which is calculated from the dot product.- Parameters:
vector- The vector to get the angle between.- Returns:
- The angle between this vector and the vector passed in.
-
length
double length()This method returns the length of this vector. The length is the distance between the origin and the desired point. The length is calculated from the X Y Z mods as sqrt(x * x + y * y + z * z).- Returns:
- The length of this vector.
-
lengthSquared
double lengthSquared()This method returns the length of this vector squared. The length is determined by sqrt(x * x + y * y + z * z).- Returns:
- The length of this vector squared.
- See Also:
-
distance
This method returns the distance between this vector and the vector passed in. The distance is the length of the vector between the two vectors. The distance is calculated from the X Y Z mods as sqrt(distanceSquared(vector));- Parameters:
vector- The vector to get the distance between.- Returns:
- The distance between this vector and the vector passed in.
- See Also:
-
distanceSquared
This method returns the distance between this vector and the vector passed in squared. The distance is the length of the vector between the two vectors. The distance is calculated from the X Y Z mods as (x - x1) * (x - x1) + (y - y1) * (y - y1) + (z - z1) * (z - z1).- Parameters:
vector- The vector to get the distance between.- Returns:
- The distance between this vector and the vector passed in squared.
-
getX
double getX()- Returns:
- The X mod of this vector.
-
getY
double getY()- Returns:
- The Y mod of this vector.
-
getZ
double getZ()- Returns:
- The Z mod of this vector.
-
rotate
This method returns a new vector with the X Y Z mods rotated by the quaternion passed in. The length is recalculated.- Parameters:
quaternion- The quaternion to rotate the vector by.- Returns:
- A new vector with the X Y Z mods rotated by the quaternion passed in.
-
getDestination
This method returns the destination point defined by the XYZ mods and the length of the vector. The destination point is calculated from the X Y Z mods as (x * length, y * length, z * length). The destination point is the point that the vector is pointing to.- Returns:
- The destination point defined by the XYZ mods and the length of the vector.
-
cross
This method returns a cross-product of this vector and the vector passed in. The cross-product is calculated from the X Y Z mods as (y * vector.getZ() - z * vector.getY(), z * vector.getX() - x * vector.getZ(), x * vector.getY() - y * vector.getX()).- Parameters:
vector- The vector to cross-product with.- Returns:
- A cross-product of this vector and the vector passed in.
-