Package com.ijurnove.cpu3d
Class Vector3d
java.lang.Object
com.ijurnove.cpu3d.Vector3d
A
Vector3d represents a direction in 3D space. Vector3ds do not have an origin, and only represent a direction.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidabsVal()static Vector3dAdds oneVector3dto another.protected static Vector3dcopy()Returns a copy of thisVector3d.Returns aVector3dperpendicular to thisVector3dand another.static Vector3dcrossProduct(Vector3d v1, Vector3d v2) Returns aVector3dperpendicular to two givenVector3ds.doubledotProduct(Vector3d v2) Returns the dot product of thisVector3dand another.static doubledotProduct(Vector3d v1, Vector3d v2) Returns the dot product of twoVector3ds.protected static Vector3dvoidinvert()Reverses the direction of thisVector3d.booleanReturns true if the X, Y, and Z values of a givenVector3dare equal to those of thisVector3d.doubleReturns the magnitude.static Vector3dmultiplyByNum(Vector3d vec, double num) Returns a newVector3dwith the values of a givenVector3dmultiplied by a number.voidSets the length of thisVector3dto 1.voidrotate(int axis, double theta) Rotates thisVector3d.voidsetX(double x) Sets the X value.voidsetY(double y) Sets the Y value.voidsetZ(double z) Sets the Z value.static Vector3dSubtracts oneVector3dfrom another.protected voidswapXY()toString()doublex()Returns the X value.doubley()Returns the Y value.doublez()Returns the Z value.
-
Field Details
-
NEUTRAL_VEC
-
UP
-
-
Constructor Details
-
Vector3d
public Vector3d(double x, double y, double z) Constructs a newVector3dwith the given values.- Parameters:
x- the X valuey- the Y valuez- the Z value
-
Vector3d
protected Vector3d(double[] xyz) -
Vector3d
Constructs aVector3dbetween twoPoint3ds.- Parameters:
start- the starting Point3dend- the ending Point3d
-
-
Method Details
-
x
public double x()Returns the X value.- Returns:
- the X value
-
y
public double y()Returns the Y value.- Returns:
- the Y value
-
z
public double z()Returns the Z value.- Returns:
- the Z value
-
setX
public void setX(double x) Sets the X value.- Parameters:
x- the value to set
-
setY
public void setY(double y) Sets the Y value.- Parameters:
y- the value to set
-
setZ
public void setZ(double z) Sets the Z value.- Parameters:
z- the value to set
-
copy
Returns a copy of thisVector3d.- Returns:
- a copy of this Vector3d
-
isEqual
Returns true if the X, Y, and Z values of a givenVector3dare equal to those of thisVector3d.- Parameters:
v- the Vector3d to compare- Returns:
- true if both Vector3ds have the same X, Y, and Z values
-
magnitude
public double magnitude()Returns the magnitude.- Returns:
- magnitude
-
normalize
public void normalize()Sets the length of thisVector3dto 1. -
rotate
public void rotate(int axis, double theta) Rotates thisVector3d.- Parameters:
axis- the axis to rotate aroundtheta- the amount to rotate by
-
crossProduct
Returns aVector3dperpendicular to two givenVector3ds.- Parameters:
v1- the first Vector3dv2- the second Vector3d- Returns:
- a Vector3d perpendicular to v1 and v2
-
cross
Returns aVector3dperpendicular to thisVector3dand another.- Parameters:
v2- the second Vector3d- Returns:
- a Vector3d perpendicular to this and v2
-
dotProduct
Returns the dot product of twoVector3ds.- Parameters:
v1- the first Vector3dv2- the second Vector3d- Returns:
- the dot product of v1 and v2
-
dotProduct
Returns the dot product of thisVector3dand another.- Parameters:
v2- the second Vector3d- Returns:
- the dot product of this and v2
-
multiplyByNum
Returns a newVector3dwith the values of a givenVector3dmultiplied by a number.- Parameters:
vec- the Vector3d to be alterednum- the number to multiply by- Returns:
- a new Vector3d with the values of the given Vector3d multiplied by the given number
-
subtract
Subtracts oneVector3dfrom another.- Parameters:
v1- the first Vector3dv2- the second Vector3d- Returns:
- v1 minus v2
-
add
Adds oneVector3dto another.- Parameters:
v1- the first Vector3dv2- the second Vector3d- Returns:
- v1 plus v2
-
absVal
protected void absVal() -
invert
public void invert()Reverses the direction of thisVector3d. -
average
-
fromBary
-
swapXY
protected void swapXY() -
toString
-