SbRotation(3)
π SbRotation(3) π
okay bestie, welcome to the SbRotation page β it's a Library Functions Manual situation and we're about to make quaternions cute. no cap, this is part 1, so buckle up π
β¨ NAME β¨
SbRotation β the class that represents a rotation in 3D space. literally its whole job. πΈ
β¨ SYNOPSIS β¨
#include <Inventor/SbLinear.h>
π¦ Public Member Functions
SbRotation (void)
SbRotation (const SbVec3f &axis, const float radians)
SbRotation (const float q[4])
SbRotation (const float q0, const float q1, const float q2, const float
q3)
SbRotation (const SbMatrix &m)
SbRotation (const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
const float * getValue (void) const
void getValue (float &q0, float &q1, float &q2, float &q3) const
SbRotation & setValue (const float q0, const float q1, const float q2,
const float q3)
void getValue (SbVec3f &axis, float &radians) const
void getValue (SbMatrix &matrix) const
SbRotation & invert (void)
SbRotation inverse (void) const
SbRotation & setValue (const float q[4])
SbRotation & setValue (const SbMatrix &m)
SbRotation & setValue (const SbVec3f &axis, const float radians)
SbRotation & setValue (const SbVec3f &rotateFrom, const SbVec3f
&rotateTo)
SbRotation & operator*= (const SbRotation &q)
SbRotation & operator*= (const float s)
SbBool equals (const SbRotation &r, const float tolerance) const
void multVec (const SbVec3f &src, SbVec3f &dst) const
void scaleAngle (const float scaleFactor)
void print (FILE *fp) const
π¦ Static Public Member Functions
static SbRotation slerp (const SbRotation &rot0, const SbRotation &rot1,
float t)
static SbRotation identity (void)
π¦ Friends
int operator== (const SbRotation &q1, const SbRotation &q2)
int operator!= (const SbRotation &q1, const SbRotation &q2)
SbRotation operator* (const SbRotation &q1, const SbRotation &q2)
π Detailed Description π
The SbRotation class represents a rotation in 3D space. that's the whole vibe. π
SbRotation is used extensively all over the Coin library β like, everywhere. it's that girl.
An SbRotation is stored internally as a quaternion for speed and storage reasons, but inquiries can be done to get and set axis and angle values for convenience. so the math is quaternion-y underneath, but you can still talk to it in axis-and-angle if that's more your language. π
okay so listen up bestie, because there's one VERY common mistake that is easy to make when setting the value of anSbRotation, and that is to inadvertently use the wrongSbRotationconstructor. This example should clarify the problem:
SbRotation rotation(0, 0, 1, 1.5707963f);
The programmer clearly tries to set a PI/2 rotation around the Z axis, but this will fail, as the SbRotation constructor invoked above is the one that takes as arguments the 4 floats of a quaternion. What the programmer almost certainly wanted to do was to use the SbRotation constructor that takes a rotation vector and a rotation angle, which is invoked like this:
SbRotation rotation(SbVec3f(0, 0, 1), 1.5707963f);
Another common problem is to set the rotation value to exactly 0.0, while wanting to store just the information about a rotation angle: rotations are internally handled as quaternions, and when converting from an angle and a rotation value to a quaternion representation, the information about the angle "gets lost" if there is no actual rotation. π« so yeah, no rotation = no angle info, it's giving evaporation.
See also
SbMatrix
π Constructor & Destructor Documentation π
SbRotation::SbRotation (void )
The default constructor just initializes a valid rotation. The actual value is unspecified, and you should not depend on it. so like, it exists, it's valid, but do not make assumptions about what it contains. π
Referenced by equals(), identity(), inverse(), operator!=, operator*, operator*=(), operator==, and slerp().
SbRotation::SbRotation (const SbVec3f & axis, const float radians)
Construct a new SbRotation object initialized with the given axis-of-rotation and rotation angle. this is the one you actually want most of the time, bestie. π
References SbVec3f::length(), SoDebugError::postWarning(), and setValue().
SbRotation::SbRotation (const float q[4])
Construct a new SbRotation object initialized with the given quaternion components.
The array must be ordered as follows:
q[0] = x, q[1] = y, q[2] = z and q[3] = w, where the quaternion is specified by q=w+xi+yj+zk.
References setValue().
SbRotation::SbRotation (const float q0, const float q1, const float q2, const float q3)
Construct a new SbRotation object initialized with the given quaternion components.
References setValue().
SbRotation::SbRotation (const SbMatrix & m)
Construct a new SbRotation object initialized with the given rotation matrix. slay, matrix to rotation pipeline. β¨
References setValue().
SbRotation::SbRotation (const SbVec3f & rotateFrom, const SbVec3f & rotateTo)
Construct a rotation which is the minimum rotation necessary to make vector rotateFrom point in the direction of vector rotateTo. like, the smallest twist that gets you from one direction to the other. efficient queen. π
Example:
#include <Inventor/SbRotation.h>
#include <Inventor/SbVec3f.h>
#include <stdio.h>
int
main(void)
{
SbVec3f from(10, 0, 0);
SbVec3f to(0, 10, 0);
SbRotation rot(from, to);
SbVec3f axis;
float angle;
rot.getValue(axis, angle);
axis.print(stdout);
printf(" angle==%f\n", angle);
return 0;
}
References setValue().
and that's part 1 done!! part 2 is coming, don't you dare close the tab π¦
π Member Function Documentation π
Okay bestie, this is where the rotation magic actually lives. We're going function by function, no skipping, no cap. Buckle up. π
β¨ const float * SbRotation::getValue (void ) const β¨
Returns a pointer to an array with the rotation expressed as four quaternion values. That's it, that's the vibe.
- See also:
setValue(). - Referenced by:
SoVRMLSound::audioRender(),SoTrackballDragger::dragFinish(),SoTransformerDragger::dragFinish(),SoTrackballDragger::dragStart(),SoRotation::getMatrix(),SoRotationXYZ::getMatrix(),SbCylinderPlaneProjector::getRotation(),SbCylinderSectionProjector::getRotation(),SbCylinderSheetProjector::getRotation(),operator*=(),SbViewVolume::rotateCamera(),scaleAngle(), andSbMatrix::setRotate().
β¨ void SbRotation::getValue (float & q0, float & q1, float & q2, float & q3) const β¨
Returns the four quaternion components representing the rotation. Cute, right?
- See also:
setValue().
β¨ SbRotation & SbRotation::setValue (const float q0, const float q1, const float q2, const float q3) β¨
Sets the rotation. Periodt.
- See also:
getValue(). - References:
SoDebugError::postWarning(). - Referenced by:
SoClipPlaneManip::fieldSensorCB(),SoDirectionalLightManip::fieldSensorCB(),SoSpotLightManip::fieldSensorCB(),operator*=(),SbRotation(),SbRotation(),SbRotation(),SbRotation(),SbRotation(),scaleAngle(), andsetValue().
β¨ void SbRotation::getValue (SbVec3f & axis, float & radians) const β¨
Returns the rotation in the form of an axis-of-rotation and a rotation angle. It's giving "tell me how you spin" energy.
- See also:
setValue(). - References:
SbVec3f::setValue().
β¨ void SbRotation::getValue (SbMatrix & matrix) const β¨
Returns this rotation in the form of a matrix. Matrix moment, slay.
- See also:
setValue().
β¨ SbRotation & SbRotation::invert (void ) β¨
Inverts the rotation. Returns a reference to self. Lowkey destructive, but in a self-referential way.
- See also:
inverse(). - References:
SoDebugError::postWarning().
β¨ SbRotation SbRotation::inverse (void ) const β¨
Non-destructively inverses the rotation and returns the result. No cap, this one doesn't touch the original.
- See also:
invert(). - References:
SoDebugError::postWarning(), andSbRotation(). - Referenced by:
SoVRMLSound::audioRender(),SoVRMLProximitySensor::doAction(),SoRotation::getMatrix(),SoRotationXYZ::getMatrix(),SoVRMLBackground::GLRender(),SbMatrix::setTransform(),SbMatrix::setTransform(),SoCenterballDragger::transferCenterDraggerMotion(),SoDirectionalLightDragger::valueChangedCB(), andSoSpotLightDragger::valueChangedCB().
β¨ SbRotation & SbRotation::setValue (const float q[4]) β¨
Resets the rotation by the four quaternions in the array. Fresh start, bestie.
- See also:
getValue(). - References:
SoDebugError::postWarning().
β¨ SbRotation & SbRotation::setValue (const SbMatrix & m) β¨
Sets the rotation from the components of the given matrix. Returns a reference to self.
- See also:
getValue(). - References:
operator*=().
β¨ SbRotation & SbRotation::setValue (const SbVec3f & axis, const float radians) β¨
Resets rotation with the given axis-of-rotation and rotation angle. Returns a reference to self.
β οΈ Make sure axis is not the null vector when calling this method. Like, actually. Don't do it.
- See also:
getValue(). - References:
SbVec3f::length(),SbVec3f::normalize(), andSoDebugError::postWarning().
β¨ SbRotation & SbRotation::setValue (const SbVec3f & rotateFrom, const SbVec3f & rotateTo) β¨
Constructs a rotation which is the minimum rotation necessary to make vector rotateFrom point in the direction of vector rotateTo.
Returns a reference to self.
See the SbRotation constructor with corresponding input arguments for a simple code example.
- See also:
getValue(). - References:
SbVec3f::cross(),SbVec3f::dot(),SbVec3f::length(),SbVec3f::normalize(),SoDebugError::postWarning(), andsetValue().
β¨ SbRotation & SbRotation::operator*= (const SbRotation & q) β¨
Multiplies the quaternions.
π Note that order is important when combining quaternions with the multiplication operator. Do not play with this.
- References:
getValue(),SbRotation(), andsetValue(). - Referenced by:
setValue().
β¨ SbRotation & SbRotation::operator*= (const float s) β¨
Multiplies components of quaternion with scalar value s. Returns a reference to self. Scalar era.
β¨ SbBool SbRotation::equals (const SbRotation & r, const float tolerance) const β¨
Checks the internal quaternion representation vectors for equality within the given tolerance. Close enough counts, bestie.
- References:
SbRotation().
β¨ void SbRotation::multVec (const SbVec3f & src, SbVec3f & dst) const β¨
Rotates the src vector and puts the result in dst.
It is safe to let src and dst be the same SbVec3f instance. No copy needed, we love efficiency.
- References:
SbMatrix::multVecMatrix(), andSbMatrix::setRotate(). - Referenced by:
SoVRMLSound::audioRender(), andSoTrackballDragger::dragStart().
β¨ void SbRotation::scaleAngle (const float scaleFactor) β¨
Scales the angle of rotation by scaleFactor. Angle glow-up, literally.
- References:
getValue(), andsetValue().
β¨ SbRotation slerp (const SbRotation & rot0, const SbRotation & rot1, float t) β¨ [static]
Interpolates along the shortest path between the two rotation positions (from rot0 to rot1).
Returns the SbRotation which will rotate rot0 the given part t of the spherical distance towards rot1, where t=0 will yield rot0 and t=1 will yield rot1.
t should be in the interval [0, 1]. Keep it in range, bestie.
- References:
SbVec4f::dot(),SbVec4f::negate(),SoDebugError::postWarning(), andSbRotation(). - Referenced by:
SoInterpolateRotation::getFieldData().
β¨ SbRotation SbRotation::identity (void ) β¨ [static]
Returns an identity rotation. The "do nothing" icon. Main character energy but make it neutral.
- References:
SbRotation(). - Referenced by:
SoTransformerDragger::dragStart(),SoVRMLSphereSensor::dragStart(),SbSpherePlaneProjector::getRotation(),SoDragger::setDefaultOnNonWritingFields(),SoTrackballDragger::setDefaultOnNonWritingFields(),SbMatrix::setTransform(),SbMatrix::setTransform(),SbMatrix::setTransform(),SoMotion3Event::SoMotion3Event(),SoVRMLExtrusion::SoVRMLExtrusion(), andSoVRMLViewpoint::SoVRMLViewpoint().
β¨ void SbRotation::print (FILE * fp) const β¨
Dumps the state of this object to the fp file stream. Only works in debug version of library, method does nothing in an optimized compile. So if you're optimized, this is giving ghost.
π«Ά Friends And Related Symbol Documentation π«Ά
These are the besties that aren't member functions but still hang out with SbRotation. Cute.
β¨ int operator== (const SbRotation & q1, const SbRotation & q2) β¨ [friend]
Checks if the two rotations are equal.
- See also:
equals(). - References:
operator==, andSbRotation(). - Referenced by:
operator==.
β¨ int operator!= (const SbRotation & q1, const SbRotation & q2) β¨ [friend]
Checks if the two rotations are unequal. The "not like other rotations" operator.
- See also:
equals(). - References:
operator!=, andSbRotation(). - Referenced by:
operator!=.
β¨ SbRotation operator* (const SbRotation & q1, const SbRotation & q2) β¨ [friend]
Multiplies the two rotations and returns the result.
π Note that order is important when combining quaternions with the multiplication operator. Same warning, same energy.
- References:
operator*, andSbRotation(). - Referenced by:
operator*.
π Author π
Generated automatically by Doxygen for Coin from the source code. Iconic.
Coin, version 2.5.0, SbRotation(3) β that's the source/version and page tag, bestie. No date on this footer line, but the vibes are immaculate. Bye. π
β¨
π¦ where this page comes from
- fedora 43: Coin2-devel 2.5.0-52.fc43 Β· GPL-2.0-only
- fedora 43: Coin2-devel 2.5.0-52.fc43 Β· GPL-2.0-only
- fedora 44: Coin2-devel 2.5.0-54.fc44 Β· GPL-2.0-only
- fedora 44: Coin2-devel 2.5.0-54.fc44 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms