Package eu.iv4xr.framework.spatial
Class Vec3
java.lang.Object
eu.iv4xr.framework.spatial.Vec3
- All Implemented Interfaces:
Serializable
This is a simple 3D vector implementation using floats.
- Author:
- Naraenda
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Vec3
copy()
Copies a vector by value.static Vec3
static float
static float
If d is the length of the vector a - b (so, the distance between them), this method returns d*d.static Vec3
static float
boolean
int
hashCode()
float
length()
float
lengthSq()
static Vec3
static Vec3
static Vec3
one()
static Vec3
toString()
static Vec3
zero()
-
Field Details
-
x
public float x -
y
public float y -
z
public float z
-
-
Constructor Details
-
Vec3
public Vec3(float x, float y, float z)Construct a new vector with three floating point values.- Parameters:
x
- : The 'x' componenty
- : The 'y' componentz
- : The 'z' component
-
Vec3
public Vec3(float c)Construct a vector containg the same constant value for each of the components.- Parameters:
c
- : the constant value.
-
-
Method Details
-
copy
Copies a vector by value.- Returns:
- New instance of the current vector.
-
zero
- Returns:
- Vec3 {0, 0, 0}
-
one
- Returns:
- Vec3 {1, 1, 1}
-
add
- Returns:
- A + B
-
sub
- Returns:
- A - B
-
mul
- Returns:
- A * B
-
mul
- Parameters:
a
- Vectorc
- Scalar- Returns:
- c * A
-
div
- Parameters:
a
- Vectorc
- Scalar- Returns:
- (1/c) * A
-
dot
- Returns:
- A.x * B.x + A.y * B.y + A.z * B.z
-
dist
- Returns:
- The distance between two vectors a and b. This is the length of the vector a - b.
-
distSq
If d is the length of the vector a - b (so, the distance between them), this method returns d*d. This is cheaper to compute that d itself. -
cross
- Returns:
- The cross product between two vectors.
-
lengthSq
public float lengthSq()- Returns:
- The squared distance of this vector.
-
length
public float length()- Returns:
- The length of this vector.
-
normalized
- Returns:
- A normalized copy of this vector.
-
toString
-
equals
-
hashCode
public int hashCode()
-