Package org.gephi.lib.gleem.linalg
Class Rotf
- java.lang.Object
-
- org.gephi.lib.gleem.linalg.Rotf
-
public class Rotf extends Object
Represents a rotation with single-precision components
-
-
Constructor Summary
Constructors Constructor Description Rotf()
Default constructor initializes to the identity quaternionRotf(Rotf arg)
Rotf(Vec3f axis, float angle)
Axis does not need to be normalized but must not be the zero vector.Rotf(Vec3f from, Vec3f to)
Creates a rotation which will rotate vector "from" into vector "to".
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fromMatrix(Mat4f mat)
Turns the upper left 3x3 of the passed matrix into a rotation.float
get(Vec3f axis)
Returns angle (in radians) and mutates the given vector to be the axis.void
init()
Re-initialize this quaternion to be the identity quaternion "e" (i.e., no rotation)Rotf
inverse()
Returns inverse of this rotation; creates new rotationvoid
invert()
Mutate this quaternion to be its inverse.float
length()
Length of this quaternion in four-spacefloat
lengthSquared()
This dotted with thisvoid
mul(Rotf a, Rotf b)
Compose two rotations: this = A * B in that order.void
normalize()
Make this quaternion a unit quaternion again.Vec3f
rotateVector(Vec3f src)
Rotate a vector by this quaternion, returning newly-allocated result.void
rotateVector(Vec3f src, Vec3f dest)
Rotate a vector by this quaternion.void
set(Rotf arg)
void
set(Vec3f axis, float angle)
Axis does not need to be normalized but must not be the zero vector.void
set(Vec3f from, Vec3f to)
Sets this rotation to that which will rotate vector "from" into vector "to".private void
setQ(int i, float val)
Rotf
times(Rotf b)
Returns this * b, in that order; creates new rotationvoid
toMatrix(Mat4f mat)
Turns this rotation into a 3x3 rotation matrix.String
toString()
boolean
withinEpsilon(Rotf arg, float epsilon)
Test for "approximate equality" -- performs componentwise test to see whether difference between all components is less than epsilon.
-
-
-
Field Detail
-
EPSILON
private static final float EPSILON
- See Also:
- Constant Field Values
-
q0
private float q0
-
q1
private float q1
-
q2
private float q2
-
q3
private float q3
-
-
Method Detail
-
init
public void init()
Re-initialize this quaternion to be the identity quaternion "e" (i.e., no rotation)
-
withinEpsilon
public boolean withinEpsilon(Rotf arg, float epsilon)
Test for "approximate equality" -- performs componentwise test to see whether difference between all components is less than epsilon.
-
set
public void set(Vec3f axis, float angle)
Axis does not need to be normalized but must not be the zero vector. Angle is in radians.
-
set
public void set(Rotf arg)
-
set
public void set(Vec3f from, Vec3f to)
Sets this rotation to that which will rotate vector "from" into vector "to". from and to do not have to be the same length.
-
get
public float get(Vec3f axis)
Returns angle (in radians) and mutates the given vector to be the axis.
-
inverse
public Rotf inverse()
Returns inverse of this rotation; creates new rotation
-
invert
public void invert()
Mutate this quaternion to be its inverse. This is equivalent to the conjugate of the quaternion.
-
length
public float length()
Length of this quaternion in four-space
-
lengthSquared
public float lengthSquared()
This dotted with this
-
normalize
public void normalize()
Make this quaternion a unit quaternion again. If you are composing dozens of quaternions you probably should call this periodically to ensure that you have a valid rotation.
-
mul
public void mul(Rotf a, Rotf b)
Compose two rotations: this = A * B in that order. NOTE that because we assume a column vector representation that this implies that a vector rotated by the cumulative rotation will be rotated first by B, then A. NOTE: "this" must be different than both a and b.
-
toMatrix
public void toMatrix(Mat4f mat)
Turns this rotation into a 3x3 rotation matrix. NOTE: only mutates the upper-left 3x3 of the passed Mat4f. Implementation from B. K. P. Horn's Robot Vision textbook.
-
fromMatrix
public void fromMatrix(Mat4f mat)
Turns the upper left 3x3 of the passed matrix into a rotation. Implementation from Watt and Watt, Advanced Animation and Rendering Techniques.
-
rotateVector
public void rotateVector(Vec3f src, Vec3f dest)
Rotate a vector by this quaternion. Implementation is from Horn's Robot Vision. NOTE: src and dest must be different vectors.
-
rotateVector
public Vec3f rotateVector(Vec3f src)
Rotate a vector by this quaternion, returning newly-allocated result.
-
setQ
private void setQ(int i, float val)
-
-