Class Transform

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

public class Transform extends Object
Transform. Transformations (translation, rotation, scale) can be applied to geometrical objects like CSG, Polygon, Vertex and Vector3d. This transform class uses the builder pattern to define combined transformations.

Example:
 // t applies rotation and translation
 Transform t = Transform.unity().rotX(45).translate(2,1,0);
 
TODO: use quaternions for rotations.
Author:
Michael Hoffer <info@michaelhoffer.de>
  • Constructor Details Link icon

    • Transform Link icon

      public Transform()
      Constructor. Creates a unit transform.
  • Method Details Link icon

    • unity Link icon

      public static Transform unity()
      Returns a new unity transform.
      Returns:
      unity transform
    • rotX Link icon

      public Transform rotX(double angle)
      Applies rotation operation around the x axis to this transform.
      Parameters:
      angle - angle
      Returns:
      this transform
    • rotY Link icon

      public Transform rotY(double angle)
      Applies rotation operation around the y axis to this transform.
      Parameters:
      angle - angle
      Returns:
      this transform
    • rotZ Link icon

      public Transform rotZ(double angle)
      Applies rotation operation around the z axis to this transform.
      Parameters:
      angle - angle
      Returns:
      this transform
    • rot Link icon

      public Transform rot(double x, double y, double z)
      Applies a rotation operation to this transform.
      Parameters:
      x - x axis rotation (angle)
      y - y axis rotation (angle)
      z - z axis rotation (angle)
      Returns:
      this transform
    • rot Link icon

      public Transform rot(Vector3d vec)
      Applies a rotation operation to this transform.
      Parameters:
      vec - axis rotation for x, y, z (angle)
      Returns:
      this transform
    • translate Link icon

      public Transform translate(Vector3d vec)
      Applies a translation operation to this transform.
      Parameters:
      vec - translation vector (x,y,z)
      Returns:
      this transform
    • translate Link icon

      public Transform translate(double x, double y, double z)
      Applies a translation operation to this transform.
      Parameters:
      x - translation (x axis)
      y - translation (y axis)
      z - translation (z axis)
      Returns:
      this transform
    • translateX Link icon

      public Transform translateX(double value)
      Applies a translation operation to this transform.
      Parameters:
      value - translation (x axis)
      Returns:
      this transform
    • translateY Link icon

      public Transform translateY(double value)
      Applies a translation operation to this transform.
      Parameters:
      value - translation (y axis)
      Returns:
      this transform
    • translateZ Link icon

      public Transform translateZ(double value)
      Applies a translation operation to this transform.
      Parameters:
      value - translation (z axis)
      Returns:
      this transform
    • mirror Link icon

      public Transform mirror(Plane plane)
      Applies a mirror operation to this transform.
      Parameters:
      plane - the plane that defines the mirror operation
      Returns:
      this transform
    • scale Link icon

      public Transform scale(Vector3d vec)
      Applies a scale operation to this transform.
      Parameters:
      vec - vector that specifies scale (x,y,z)
      Returns:
      this transform
    • scale Link icon

      public Transform scale(double x, double y, double z)
      Applies a scale operation to this transform.
      Parameters:
      x - x scale value
      y - y scale value
      z - z scale value
      Returns:
      this transform
    • scale Link icon

      public Transform scale(double s)
      Applies a scale operation to this transform.
      Parameters:
      s - s scale value (x, y and z)
      Returns:
      this transform
    • scaleX Link icon

      public Transform scaleX(double s)
      Applies a scale operation (x axis) to this transform.
      Parameters:
      s - x scale value
      Returns:
      this transform
    • scaleY Link icon

      public Transform scaleY(double s)
      Applies a scale operation (y axis) to this transform.
      Parameters:
      s - y scale value
      Returns:
      this transform
    • scaleZ Link icon

      public Transform scaleZ(double s)
      Applies a scale operation (z axis) to this transform.
      Parameters:
      s - z scale value
      Returns:
      this transform
    • transform Link icon

      public Vector3d transform(Vector3d vec)
      Applies this transform to the specified vector.
      Parameters:
      vec - vector to transform
      Returns:
      the specified vector
    • invert Link icon

      public Transform invert()
      Invert the transformation
      Returns:
      this transform inverted
    • transform Link icon

      public Vector3d transform(Vector3d vec, double amount)
      Applies this transform to the specified vector.
      Parameters:
      vec - vector to transform
      amount - transform amount (0 = 0 %, 1 = 100%)
      Returns:
      the specified vector
    • getScale Link icon

      public double getScale()
      Performs an SVD normalization of the underlying matrix to calculate and return the uniform scale factor. If the matrix has non-uniform scale factors, the largest of the x, y, and z scale factors distill be returned. Note: this transformation is not modified.
      Returns:
      the scale factor of this transformation
    • isMirror Link icon

      public boolean isMirror()
      Indicates whether this transform performs a mirror operation, i.e., flips the orientation.
      Returns:
      true if this transform performs a mirror operation; false otherwise
    • apply Link icon

      public Transform apply(Transform t)
      Applies the specified transform to this transform.
      Parameters:
      t - transform to apply
      Returns:
      this transform
    • prepend Link icon

      public Transform prepend(Transform t)
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object