Package edu.cnu.mdi.mdi3D.panel
Class Vector3f
java.lang.Object
edu.cnu.mdi.mdi3D.panel.Vector3f
A minimal, mutable single-precision 3D vector with the handful of
operations (length, dot, cross, normalize, midpoint) that the
mdi3D
geometry helpers need. Not related to any JOGL/JOML vector type.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCompute the cross product with another vector.floatCompute the dot (scalar) product with another vector.floatlength()Get the length of the vectorstatic Vector3fObtain a vector that is the midpoint of two other vectorsvoidScale this vector in place to unit length.
-
Field Details
-
x
public float xThe coordinates -
y
public float yThe coordinates -
z
public float zThe coordinates
-
-
Constructor Details
-
Vector3f
public Vector3f()null constructor; all coordinates are 0 -
Vector3f
public Vector3f(float x, float y, float z) Constructor- Parameters:
x- the x coordinatey- the y coordinatez- the z coordinate
-
Vector3f
public Vector3f(float[] coords, int index) Constructor using a set of coordinates- Parameters:
coords- [x, y, z, x, y, z, etc]index- start at 3*index for the x coordinate
-
-
Method Details
-
length
public float length()Get the length of the vector- Returns:
- the length
-
dot
Compute the dot (scalar) product with another vector.- Parameters:
other- the other vector- Returns:
- the dot product
-
cross
Compute the cross product with another vector.- Parameters:
other- the other vector- Returns:
- a new vector perpendicular to both this vector and
other
-
normalize
public void normalize()Scale this vector in place to unit length. A zero-length vector is left unchanged rather than producingNaNcomponents. -
midpoint
Obtain a vector that is the midpoint of two other vectors- Parameters:
v1- one vectorv2- the other vector- Returns:
- the midpoint
-