public class SbRotation extends SbBasic
The rotation value is stored internally as a quaternion. Quaternion representation is more compact, faster to compute and more numerically stable than rotation matrices. Quaternion representation allows smooth rotation (spherical linear interpolation) and avoids the problem of "gimbal lock" associated with Euler angles. It is not necessary to deal directly with quaternions. Many convenience methods are provided to set and get rotations using matrix and axis/angle representations.
Rotations are most commonly specified using an axis and an angle in radians. A common mistake is to use the constructor or setValue method that takes four float values, when intending to set an axis and angle. The methods that take four float values directly specify the quaternion value, which is probably not the intended result. For example:
// Create a rotation of PI/2 radians around the Z axis: // Incorrect. // (Compiles, but actually sets the quaternion value directly!) SbRotation rotation1 = new SbRotation(0, 0, 1, 1.5707963f); // This is the correct rotation. SbRotation rotation2 = new SbRotation(new SbVec3f(0, 0, 1), 1.5707963f);
See also:
SbRotationd
, SbVec2d
, SbVec2f
, SbVec2i32
, SbVec2s
, SbVec3d
, SbVec3f
, SbVec3i32
, SbVec3s
, SbVec4b
, SbVec4d
, SbVec4f
, SbVec4i32
, SbVec4s
, SbVec4ub
, SbVec4ui32
, SbVec4us
Modifier and Type | Class and Description |
---|---|
static class |
SbRotation.AxisAngle |
Modifier and Type | Field and Description |
---|---|
float[] |
array |
Constructor and Description |
---|
SbRotation()
Default constructor.
|
SbRotation(float[] components) |
SbRotation(float q0,
float q1,
float q2,
float q3)
Constructor.
|
SbRotation(SbMatrix m)
Constructor.
|
SbRotation(SbMatrix3 m)
Constructor.
|
SbRotation(SbRotation copyFrom) |
SbRotation(SbVec3f axis,
float radians)
Constructor.
|
SbRotation(SbVec3f rotateFrom,
SbVec3f rotateTo)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
SbRotation.AxisAngle |
decompose()
Returns corresponding 3D rotation axis vector and angle in radians.
|
boolean |
equals(java.lang.Object obj) |
boolean |
equals(SbRotation r,
float tolerance)
Equality comparison within given tolerance - the square of the length of the maximum distance between the two quaternion vectors.
|
float |
getAngle()
Deprecated.
|
SbVec3f |
getAxis()
Deprecated.
|
void |
getAxis(SbVec3f axis)
Deprecated.
|
SbMatrix |
getMatrix()
Returns corresponding 4x4 rotation matrix.
|
SbMatrix3 |
getMatrix3()
Returns corresponding 3x3 rotation matrix.
|
SbMatrixd |
getMatrixd()
Returns corresponding 4x4 rotation matrix.
|
float[] |
getValue() |
static SbRotation |
identity()
Returns a null rotation.
|
SbRotation |
inverse()
Returns the inverse of a rotation.
|
SbRotation |
invert()
Changes a rotation to be its inverse.
|
void |
multiply(SbRotation q)
Multiplies by another rotation; results in product of rotations.
|
SbVec3f |
multVec(SbVec3f src)
Multiplies the given vector by the matrix of this rotation.
|
void |
scaleAngle(float scaleFactor)
Keep the axis the same.
|
SbRotation |
setValue(float[] components) |
SbRotation |
setValue(float[] components,
int startIndex) |
SbRotation |
setValue(float q0,
float q1,
float q2,
float q3)
Sets value of rotation from 4 individual components of a quaternion.
|
SbRotation |
setValue(SbMatrix m)
Sets value of rotation from a rotation matrix.
|
SbRotation |
setValue(SbMatrix3 m)
Sets rotation from a 3x3 rotation matrix.
|
SbRotation |
setValue(SbMatrixd md)
Sets rotation from a double precision rotation matrix.
|
void |
setValue(SbRotation copyFrom) |
SbRotation |
setValue(SbRotationd rotated)
Sets rotation from a double precision rotation.
|
SbRotation |
setValue(SbVec3f axis,
float radians)
Sets value of vector from 3D rotation axis vector and angle in radians.
|
SbRotation |
setValue(SbVec3f rotateFrom,
SbVec3f rotateTo)
Sets rotation to rotate one direction vector to another.
|
static SbRotation |
slerp(SbRotation rot0,
SbRotation rot1,
float t)
Spherical linear interpolation: as t goes from 0 to 1, returned value goes from rot0 to rot1.
|
SbRotation |
times(SbRotation q2)
Multiplication of two rotations; results in product of rotations.
|
static SbRotation[] |
toArray(long nativeArray,
long length) |
public SbRotation(SbRotation copyFrom)
public SbRotation(float[] components)
public SbRotation(float q0, float q1, float q2, float q3)
public SbRotation()
public SbRotation(SbMatrix m)
public SbRotation(SbMatrix3 m)
public SbRotation(SbVec3f axis, float radians)
@Deprecated public SbVec3f getAxis()
decompose()
@Deprecated public void getAxis(SbVec3f axis)
decompose()
public float getAngle()
decompose()
public SbRotation setValue(float[] components)
public float[] getValue()
public SbRotation setValue(float[] components, int startIndex)
public void setValue(SbRotation copyFrom)
public void scaleAngle(float scaleFactor)
public SbVec3f multVec(SbVec3f src)
public SbRotation times(SbRotation q2)
public static SbRotation identity()
public static SbRotation[] toArray(long nativeArray, long length)
public SbRotation setValue(float q0, float q1, float q2, float q3)
public static SbRotation slerp(SbRotation rot0, SbRotation rot1, float t)
public SbMatrix getMatrix()
public SbRotation setValue(SbMatrix3 m)
public SbRotation.AxisAngle decompose()
public SbRotation setValue(SbVec3f axis, float radians)
public SbMatrix3 getMatrix3()
public SbRotation invert()
public SbRotation inverse()
public SbRotation setValue(SbMatrix m)
public SbMatrixd getMatrixd()
public SbRotation setValue(SbVec3f rotateFrom, SbVec3f rotateTo)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public boolean equals(SbRotation r, float tolerance)
public SbRotation setValue(SbMatrixd md)
public SbRotation setValue(SbRotationd rotated)
public void multiply(SbRotation q)
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com