Class DirectionVector

Object
DirectionVector

public final class DirectionVector extends Object
A vector indicating a direction in space.
Author:
Owen Feehan
  • Constructor Details

    • DirectionVector

      public DirectionVector()
      Creates with each dimension's value set to 0.
    • DirectionVector

      public DirectionVector(Tuple3d vector)
      Creates reusing Tuple3d internally for the dimension's values.
      Parameters:
      vector - the vector to reuse.
    • DirectionVector

      public DirectionVector(double x, double y, double z)
      Creates for a particular value in each dimension.
      Parameters:
      x - the value in the x-dimension.
      y - the value in the y-dimension.
      z - the value in the z-dimension.
    • DirectionVector

      public DirectionVector(Axis axis)
      Creates a direction aligned to a particular axis.
      Parameters:
      axis - the axis to align to.
  • Method Details

    • createBetweenTwoPoints

      public static DirectionVector createBetweenTwoPoints(Point3d point1, Point3d point2)
      Creates a DirectionVector representing the direction between two points of type Point3d.
      Parameters:
      point1 - the first-point.
      point2 - the second-point.
      Returns:
      a vector with the distance between the two points, normalized to have magnitude of 1.
    • createBetweenTwoPoints

      public static DirectionVector createBetweenTwoPoints(Point3i point1, Point3i point2)
      Creates a DirectionVector representing the direction between two points of type Point3i.
      Parameters:
      point1 - the first-point.
      point2 - the second-point.
      Returns:
      a vector with the distance between the two points, normalized to have magnitude of 1.
    • x

      public double x()
      The x-component of the vector.
      Returns:
      the component's value.
    • y

      public double y()
      The y-component of the vector.
      Returns:
      the component's value.
    • z

      public double z()
      The z-component of the vector.
      Returns:
      the component's value.
    • setIndex

      public void setIndex(int index, double valueToAssign)
      Sets an element of the vector by the index of its position.
      Parameters:
      index - the index to change in the vector where index=0 is the X-element, index=1 is the Y-element, and index=2 is the Z-element.
      valueToAssign - the value to assign.
    • asVector3d

      public Vector3d asVector3d()
      Converts to a Vector3d representation.
      Returns:
      a newly-created Vector3d with identical component values as the current object.