Class Vector3d

java.lang.Object
eu.mihosoft.vrl.v3d.Vector3d

public class Vector3d extends Object
3D Vector3d.
Author:
Michael Hoffer <info@michaelhoffer.de>
  • Field Details Link icon

    • x Link icon

      public double x
    • y Link icon

      public double y
    • z Link icon

      public double z
    • ZERO Link icon

      public static final Vector3d ZERO
    • UNITY Link icon

      public static final Vector3d UNITY
    • X_ONE Link icon

      public static final Vector3d X_ONE
    • Y_ONE Link icon

      public static final Vector3d Y_ONE
    • Z_ONE Link icon

      public static final Vector3d Z_ONE
  • Constructor Details Link icon

    • Vector3d Link icon

      public Vector3d(double x, double y, double z)
      Creates a new vector.
      Parameters:
      x - x value
      y - y value
      z - z value
    • Vector3d Link icon

      public Vector3d(Vector3d vec)
      Creates a new vector based on provided vector (copy constructor)
      Parameters:
      vec - vector for copy constructor
    • Vector3d Link icon

      public Vector3d(double x, double y)
      Creates a new vector with specified x, y and z = 0.
      Parameters:
      x - x value
      y - y value
  • Method Details Link icon

    • set Link icon

      public void set(double x, double y, double z)
    • set Link icon

      public void set(double x, double y)
    • set Link icon

      public void set(Vector3d vec)
    • sub Link icon

      public Vector3d sub(Vector3d vector)
      Subtracts the given vector from this vector
      Parameters:
      vector - the vector to subtract from this vector
      Returns:
      Vector3d
    • clone Link icon

      public Vector3d clone()
      Overrides:
      clone in class Object
    • negated Link icon

      public Vector3d negated()
      Returns a negated copy of this vector. Note: this vector is not modified.
      Returns:
      a negated copy of this vector
    • plus Link icon

      public Vector3d plus(Vector3d v)
      Returns the sum of this vector and the specified vector.
      Parameters:
      v - the vector to add Note: this vector is not modified.
      Returns:
      the sum of this vector and the specified vector
    • minus Link icon

      public Vector3d minus(Vector3d v)
      Returns the difference of this vector and the specified vector.
      Parameters:
      v - the vector to subtract Note: this vector is not modified.
      Returns:
      the difference of this vector and the specified vector
    • times Link icon

      public Vector3d times(double a)
      Returns the product of this vector and the specified value.
      Parameters:
      a - the value Note: this vector is not modified.
      Returns:
      the product of this vector and the specified value
    • times Link icon

      public Vector3d times(Vector3d a)
      Returns the product of this vector and the specified vector.
      Parameters:
      a - the vector Note: this vector is not modified.
      Returns:
      the product of this vector and the specified vector
    • dividedBy Link icon

      public Vector3d dividedBy(double a)
      Returns this vector devided by the specified value.
      Parameters:
      a - the value Note: this vector is not modified.
      Returns:
      this vector devided by the specified value
    • dot Link icon

      public double dot(Vector3d a)
      Returns the dot product of this vector and the specified vector. Note: this vector is not modified.
      Parameters:
      a - the second vector
      Returns:
      the dot product of this vector and the specified vector
    • lerp Link icon

      public Vector3d lerp(Vector3d a, double t)
      Linearly interpolates between this and the specified vector. Note: this vector is not modified.
      Parameters:
      a - vector
      t - interpolation value
      Returns:
      copy of this vector if t = 0; copy of a if t = 1; the point midway between this and the specified vector if t = 0.5
    • magnitude Link icon

      public double magnitude()
      Returns the magnitude of this vector. Note: this vector is not modified.
      Returns:
      the magnitude of this vector
    • magnitudeSq Link icon

      public double magnitudeSq()
      Returns the squared magnitude of this vector (this.dot(this)). Note: this vector is not modified.
      Returns:
      the squared magnitude of this vector
    • normalized Link icon

      public Vector3d normalized()
      Returns a normalized copy of this vector with length 1. Note: this vector is not modified.
      Returns:
      a normalized copy of this vector with length 1
    • cross Link icon

      public Vector3d cross(Vector3d a)
      Returns the cross product of this vector and the specified vector. Note: this vector is not modified.
      Parameters:
      a - the vector
      Returns:
      the cross product of this vector and the specified vector.
    • toStlString Link icon

      public String toStlString()
      Returns this vector in STL string format.
      Returns:
      this vector in STL string format
    • toStlString Link icon

      public StringBuilder toStlString(StringBuilder sb)
      Returns this vector in STL string format.
      Parameters:
      sb - string builder
      Returns:
      the specified string builder
    • toObjString Link icon

      public String toObjString()
      Returns this vector in OBJ string format.
      Returns:
      this vector in OBJ string format
    • toObjString Link icon

      public StringBuilder toObjString(StringBuilder sb)
      Returns this vector in OBJ string format.
      Parameters:
      sb - string builder
      Returns:
      the specified string builder
    • transform Link icon

      public Vector3d transform(Transform transform)
      Applies the specified transformation to this vector.
      Parameters:
      transform - the transform to apply
      Returns:
      this vector
    • transformed Link icon

      public Vector3d transformed(Transform transform)
      Returns a transformed copy of this vector.
      Parameters:
      transform - the transform to apply Note: this vector is not modified.
      Returns:
      a transformed copy of this vector
    • transform Link icon

      public Vector3d transform(Transform transform, double amount)
      Applies the specified transformation to this vector.
      Parameters:
      transform - the transform to apply
      Returns:
      this vector
    • transformed Link icon

      public Vector3d transformed(Transform transform, double amount)
      Returns a transformed copy of this vector.
      Parameters:
      transform - the transform to apply Note: this vector is not modified.
      Returns:
      a transformed copy of this vector
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • equals Link icon

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • angle Link icon

      public double angle(Vector3d v)
      Returns the angle between this and the specified vector.
      Parameters:
      v - vector
      Returns:
      angle in radians
    • distance Link icon

      public double distance(Vector3d v)
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
    • x Link icon

      public static Vector3d x(double x)
      Creates a new vector with specified x
      Parameters:
      x - x value
      Returns:
      a new vector [x,0,0]
    • y Link icon

      public static Vector3d y(double y)
      Creates a new vector with specified y
      Parameters:
      y - y value
      Returns:
      a new vector [0,y,0]
    • z Link icon

      public static Vector3d z(double z)
      Creates a new vector with specified z
      Parameters:
      z - z value
      Returns:
      a new vector [0,0,z]
    • orthogonal Link icon

      public Vector3d orthogonal()
      Creates a new vector which is orthogonal to this. this_i , this_j , this_k => i,j,k € {1,2,3} permutation looking for orthogonal vector o to vector this: this_i * o_i + this_j * o_j + this_k * o_k = 0
      Returns:
      a new vector which is orthogonal to this
    • add Link icon

      public Vector3d add(double x, double y, double z)
    • add Link icon

      public Vector3d add(Vector3d vec)
    • rotateX Link icon

      public Vector3d rotateX(double angle)
    • rotateY Link icon

      public Vector3d rotateY(double angle)
    • rotateZ Link icon

      public Vector3d rotateZ(double angle)
    • rotate Link icon

      public void rotate(Vector3d vector, double angle)
      Rotates the given vector clockwise around the axis produced by this vector by the given angle.
      Parameters:
      vector - the vector to rotate
      angle - the angle of rotation
    • midpoint Link icon

      public Vector3d midpoint(Vector3d point)
      Constructs a new Point3D at the geometric mean of this point and the given point. This function behaves identically to lerp(point, 0.5).
      Parameters:
      point - the other point
      Returns:
      a point at the geometric mean of the two given points
    • theta Link icon

      public double theta()
      Returns:
      theta elevation (angle between vector and z axis)
    • phi Link icon

      public double phi()
      Returns:
      phi azimuth (angle between projection onto xy plane and x axis)