Class Vector3f

java.lang.Object
edu.cnu.mdi.mdi3D.panel.Vector3f

public class Vector3f extends Object
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
    Modifier and Type
    Field
    Description
    float
    The coordinates
    float
    The coordinates
    float
    The coordinates
  • Constructor Summary

    Constructors
    Constructor
    Description
    null constructor; all coordinates are 0
    Vector3f(float[] coords, int index)
    Constructor using a set of coordinates
    Vector3f(float x, float y, float z)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    cross(Vector3f other)
    Compute the cross product with another vector.
    float
    dot(Vector3f other)
    Compute the dot (scalar) product with another vector.
    float
    Get the length of the vector
    static Vector3f
    Obtain a vector that is the midpoint of two other vectors
    void
    Scale this vector in place to unit length.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • x

      public float x
      The coordinates
    • y

      public float y
      The coordinates
    • z

      public float z
      The 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 coordinate
      y - the y coordinate
      z - 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

      public float dot(Vector3f other)
      Compute the dot (scalar) product with another vector.
      Parameters:
      other - the other vector
      Returns:
      the dot product
    • cross

      public Vector3f cross(Vector3f other)
      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 producing NaN components.
    • midpoint

      public static Vector3f midpoint(Vector3f v1, Vector3f v2)
      Obtain a vector that is the midpoint of two other vectors
      Parameters:
      v1 - one vector
      v2 - the other vector
      Returns:
      the midpoint