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 reusingTuple3dinternally for the dimension's values. -
Method Summary
Modifier and TypeMethodDescriptionConverts to aVector3drepresentation.static DirectionVectorcreateBetweenTwoPoints(Point3d point1, Point3d point2) Creates aDirectionVectorrepresenting the direction between two points of typePoint3d.static DirectionVectorcreateBetweenTwoPoints(Point3i point1, Point3i point2) Creates aDirectionVectorrepresenting the direction between two points of typePoint3i.voidsetIndex(int index, double valueToAssign) Sets an element of the vector by the index of its position.doublex()The x-component of the vector.doubley()The y-component of the vector.doublez()The z-component of the vector.
-
Constructor Details
-
DirectionVector
public DirectionVector()Creates with each dimension's value set to0. -
DirectionVector
Creates reusingTuple3dinternally 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 aDirectionVectorrepresenting 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 aDirectionVectorrepresenting 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=0is the X-element,index=1is the Y-element, andindex=2is the Z-element.valueToAssign- the value to assign.
-
asVector3d
Converts to aVector3drepresentation.- Returns:
- a newly-created
Vector3dwith identical component values as the current object.
-