Class DirectionVector
Object
DirectionVector
A vector indicating a direction in space.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionCreates with each dimension's value set to0
.DirectionVector
(double x, double y, double z) Creates for a particular value in each dimension.DirectionVector
(Axis axis) Creates a direction aligned to a particular axis.DirectionVector
(Tuple3d vector) Creates reusingTuple3d
internally for the dimension's values. -
Method Summary
Modifier and TypeMethodDescriptionConverts to aVector3d
representation.static DirectionVector
createBetweenTwoPoints
(Point3d point1, Point3d point2) Creates aDirectionVector
representing the direction between two points of typePoint3d
.static DirectionVector
createBetweenTwoPoints
(Point3i point1, Point3i point2) Creates aDirectionVector
representing the direction between two points of typePoint3i
.void
setIndex
(int index, double valueToAssign) Sets an element of the vector by the index of its position.double
x()
The x-component of the vector.double
y()
The y-component of the vector.double
z()
The z-component of the vector.
-
Constructor Details
-
DirectionVector
public DirectionVector()Creates with each dimension's value set to0
. -
DirectionVector
Creates reusingTuple3d
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
Creates a direction aligned to a particular axis.- Parameters:
axis
- the axis to align to.
-
-
Method Details
-
createBetweenTwoPoints
Creates aDirectionVector
representing the direction between two points of typePoint3d
.- 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
Creates aDirectionVector
representing the direction between two points of typePoint3i
.- 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 whereindex=0
is the X-element,index=1
is the Y-element, andindex=2
is the Z-element.valueToAssign
- the value to assign.
-
asVector3d
Converts to aVector3d
representation.- Returns:
- a newly-created
Vector3d
with identical component values as the current object.
-