Package eu.mihosoft.vrl.v3d
Class Vector3d
java.lang.Object
eu.mihosoft.vrl.v3d.Vector3d
3D Vector3d.
- Author:
- Michael Hoffer <info@michaelhoffer.de>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(double x, double y, double z) double
Returns the angle between this and the specified vector.clone()
Returns the cross product of this vector and the specified vector.double
dividedBy
(double a) Returns this vector devided by the specified value.double
Returns the dot product of this vector and the specified vector.boolean
int
hashCode()
Linearly interpolates between this and the specified vector.double
Returns the magnitude of this vector.double
Returns the squared magnitude of this vector (this.dot(this)
).Constructs a newPoint3D
at the geometric mean of this point and the given point.Returns the difference of this vector and the specified vector.negated()
Returns a negated copy of this vector.Returns a normalized copy of this vector with length1
.Creates a new vector which is orthogonal to this.double
phi()
Returns the sum of this vector and the specified vector.void
Rotates the given vector clockwise around the axis produced by this vector by the given angle.rotateX
(double angle) rotateY
(double angle) rotateZ
(double angle) void
set
(double x, double y) void
set
(double x, double y, double z) void
Subtracts the given vector from this vectordouble
theta()
times
(double a) Returns the product of this vector and the specified value.Returns the product of this vector and the specified vector.Returns this vector in OBJ string format.Returns this vector in OBJ string format.Returns this vector in STL string format.Returns this vector in STL string format.toString()
Applies the specified transformation to this vector.Applies the specified transformation to this vector.transformed
(Transform transform) Returns a transformed copy of this vector.transformed
(Transform transform, double amount) Returns a transformed copy of this vector.static Vector3d
x
(double x) Creates a new vector with specifiedx
static Vector3d
y
(double y) Creates a new vector with specifiedy
static Vector3d
z
(double z) Creates a new vector with specifiedz
-
Field Details
-
x
public double x -
y
public double y -
z
public double z -
ZERO
-
UNITY
-
X_ONE
-
Y_ONE
-
Z_ONE
-
-
Constructor Details
-
Vector3d
public Vector3d(double x, double y, double z) Creates a new vector.- Parameters:
x
- x valuey
- y valuez
- z value
-
Vector3d
Creates a new vector based on provided vector (copy constructor)- Parameters:
vec
- vector for copy constructor
-
Vector3d
public Vector3d(double x, double y) Creates a new vector with specifiedx
,y
andz = 0
.- Parameters:
x
- x valuey
- y value
-
-
Method Details
-
set
public void set(double x, double y, double z) -
set
public void set(double x, double y) -
set
-
sub
Subtracts the given vector from this vector- Parameters:
vector
- the vector to subtract from this vector- Returns:
- Vector3d
-
clone
-
negated
Returns a negated copy of this vector. Note: this vector is not modified.- Returns:
- a negated copy of this vector
-
plus
Returns the sum of this vector and the specified vector.- Parameters:
v
- the vector to add Note: this vector is not modified.- Returns:
- the sum of this vector and the specified vector
-
minus
Returns the difference of this vector and the specified vector.- Parameters:
v
- the vector to subtract Note: this vector is not modified.- Returns:
- the difference of this vector and the specified vector
-
times
Returns the product of this vector and the specified value.- Parameters:
a
- the value Note: this vector is not modified.- Returns:
- the product of this vector and the specified value
-
times
Returns the product of this vector and the specified vector.- Parameters:
a
- the vector Note: this vector is not modified.- Returns:
- the product of this vector and the specified vector
-
dividedBy
Returns this vector devided by the specified value.- Parameters:
a
- the value Note: this vector is not modified.- Returns:
- this vector devided by the specified value
-
dot
Returns the dot product of this vector and the specified vector. Note: this vector is not modified.- Parameters:
a
- the second vector- Returns:
- the dot product of this vector and the specified vector
-
lerp
Linearly interpolates between this and the specified vector. Note: this vector is not modified.- Parameters:
a
- vectort
- interpolation value- Returns:
- copy of this vector if
t = 0
; copy of a ift = 1
; the point midway between this and the specified vector ift = 0.5
-
magnitude
public double magnitude()Returns the magnitude of this vector. Note: this vector is not modified.- Returns:
- the magnitude of this vector
-
magnitudeSq
public double magnitudeSq()Returns the squared magnitude of this vector (this.dot(this)
). Note: this vector is not modified.- Returns:
- the squared magnitude of this vector
-
normalized
Returns a normalized copy of this vector with length1
. Note: this vector is not modified.- Returns:
- a normalized copy of this vector with length
1
-
cross
Returns the cross product of this vector and the specified vector. Note: this vector is not modified.- Parameters:
a
- the vector- Returns:
- the cross product of this vector and the specified vector.
-
toStlString
Returns this vector in STL string format.- Returns:
- this vector in STL string format
-
toStlString
Returns this vector in STL string format.- Parameters:
sb
- string builder- Returns:
- the specified string builder
-
toObjString
Returns this vector in OBJ string format.- Returns:
- this vector in OBJ string format
-
toObjString
Returns this vector in OBJ string format.- Parameters:
sb
- string builder- Returns:
- the specified string builder
-
transform
Applies the specified transformation to this vector.- Parameters:
transform
- the transform to apply- Returns:
- this vector
-
transformed
Returns a transformed copy of this vector.- Parameters:
transform
- the transform to apply Note: this vector is not modified.- Returns:
- a transformed copy of this vector
-
transform
Applies the specified transformation to this vector.- Parameters:
transform
- the transform to apply- Returns:
- this vector
-
transformed
Returns a transformed copy of this vector.- Parameters:
transform
- the transform to apply Note: this vector is not modified.- Returns:
- a transformed copy of this vector
-
toString
-
equals
-
angle
Returns the angle between this and the specified vector.- Parameters:
v
- vector- Returns:
- angle in radians
-
distance
-
hashCode
public int hashCode() -
x
Creates a new vector with specifiedx
- Parameters:
x
- x value- Returns:
- a new vector
[x,0,0]
-
y
Creates a new vector with specifiedy
- Parameters:
y
- y value- Returns:
- a new vector
[0,y,0]
-
z
Creates a new vector with specifiedz
- Parameters:
z
- z value- Returns:
- a new vector
[0,0,z]
-
orthogonal
Creates a new vector which is orthogonal to this. this_i , this_j , this_k => i,j,k € {1,2,3} permutation looking for orthogonal vector o to vector this: this_i * o_i + this_j * o_j + this_k * o_k = 0- Returns:
- a new vector which is orthogonal to this
-
add
-
add
-
rotateX
-
rotateY
-
rotateZ
-
rotate
Rotates the given vector clockwise around the axis produced by this vector by the given angle.- Parameters:
vector
- the vector to rotateangle
- the angle of rotation
-
midpoint
Constructs a newPoint3D
at the geometric mean of this point and the given point. This function behaves identically to lerp(point, 0.5).- Parameters:
point
- the other point- Returns:
- a point at the geometric mean of the two given points
-
theta
public double theta()- Returns:
- theta elevation (angle between vector and z axis)
-
phi
public double phi()- Returns:
- phi azimuth (angle between projection onto xy plane and x axis)
-