SbRotation(3)
π SbRotation(3) β from the Library Functions Manual β¨
okay bestie, sit down, hydrate, because today we're learning about SbRotation and honestly? she's iconic. π
πΈ NAME πΈ
SbRotation β the class that represents a rotation in 3D space. no cap, that's literally her whole job and she does it flawlessly π
β¨ 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) constvoid getValue(float &q0, float &q1, float &q2, float &q3) constSbRotation & setValue(const float q0, const float q1, const float q2, const float q3)void getValue(SbVec3f &axis, float &radians) constvoid getValue(SbMatrix &matrix) constSbRotation & invert(void)SbRotation inverse(void) constSbRotation & 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) constvoid multVec(const SbVec3f &src, SbVec3f &dst) constvoid 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)
π Detailed Description π
So. The SbRotation class represents a rotation in 3D space. That's the whole vibe. π
SbRotation is used extensively throughout the Coin library β she's everywhere, she's booked, she's busy, she's the moment.
Under the hood, an SbRotation is stored internally as a quaternion, because speed and storage reasons (efficiency slay π
). But don't worry bestie, you can still inquire about axis and angle values for convenience β the API has your back.
π¨ okay this next part is IMPORTANT, listen up, this is the classic trap π¨
There is one very common mistake that is easy to make when setting the value of an SbRotation, and that is to inadvertently use the wrong SbRotation constructor. 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: setting 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. π the angle said "and I oop" and vanished.
π 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. it's giving mystery, it's giving chaos, do not trust her π
SbRotation::SbRotation(const SbVec3f &axis, const float radians)
Construct a new SbRotation object initialized with the given axis-of-rotation and rotation angle. β¨
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.
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.
SbRotation::SbRotation(const SbMatrix &m)
Construct a new SbRotation object initialized with the given rotation matrix.
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. honestly? efficient queen π
Example:
#include <Inventor/SbRotation.h>
#include <Inventor/SbVec3f.h>
#include <cstdio>
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;
}
π¦ Member Function Documentation π¦
const float * SbRotation::getValue(void) const
Return pointer to an array with the rotation expressed as four quaternion values.
See also: setValue().
void SbRotation::getValue(float &q0, float &q1, float &q2, float &q3) const
Return the four quaternion components representing the rotation.
See also: setValue().
SbRotation & SbRotation::setValue(const float q0, const float q1, const float q2, const float q3)
Set the rotation.
See also: getValue().
void SbRotation::getValue(SbVec3f &axis, float &radians) const
Return the rotation in the form of an axis-of-rotation and a rotation angle.
See also: setValue().
void SbRotation::getValue(SbMatrix &matrix) const
Return this rotation in the form of a matrix.
See also: setValue().
SbRotation & SbRotation::invert(void)
Invert the rotation. Returns reference to self.
See also: inverse()
SbRotation SbRotation::inverse(void) const
Non-destructively inverses the rotation and returns the result. she doesn't change herself, she just hands you a flipped copy π«Ά
See also: invert()
SbRotation & SbRotation::setValue(const float q[4])
Reset the rotation by the four quaternions in the array.
See also: getValue().
SbRotation & SbRotation::setValue(const SbMatrix &m)
Set the rotation from the components of the given matrix. Returns reference to self.
See also: getValue().
SbRotation & SbRotation::setValue(const SbVec3f &axis, const float radians)
Reset rotation with the given axis-of-rotation and rotation angle. Returns reference to self.
β οΈ Make sure axis is not the null vector when calling this method. fr fr, do not pass a null vector, that's not the move.
See also: getValue().
SbRotation & SbRotation::setValue(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.
Returns reference to self.
See SbRotation constructor with corresponding input arguments for a simple code example.
See also: getValue().
SbRotation & SbRotation::operator*=(const SbRotation &q)
Multiplies the quaternions.
π Note that order is important when combining quaternions with the multiplication operator. do not just yeet them in whatever order, bestie.
SbRotation & SbRotation::operator*=(const float s)
Multiplies components of quaternion with scalar value s. Returns reference to self.
SbBool SbRotation::equals(const SbRotation &r, const float tolerance) const
Check the internal quaternion representation vectors for equality within the given tolerance.
void SbRotation::multVec(const SbVec3f &src, SbVec3f &dst) const
Rotate the src vector and put the result in dst.
It is safe to let src and dst be the same SbVec3f instance. same-object energy, we love a self-care moment πΈ
void SbRotation::scaleAngle(const float scaleFactor)
Scale the angle of rotation by scaleFactor.
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). it's giving β¨smoothβ¨
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].
SbRotation SbRotation::identity(void) [static]
Returns an identity rotation. her neutral era, her baseline, her "no thoughts head empty but make it mathematically valid" π
void SbRotation::print(FILE *fp) const
Dump the state of this object to the fp file stream. Only works in debug version of library, method does nothing in an optimized compile. π she only speaks in debug mode, in release she's silent, ghosting you fr.
π Author π
Generated automatically by Doxygen for Coin from the source code.
and that's the whole page bestie!! ππβ¨
this page came to you courtesy of Coin, Version 3.1.3, and yes, the manual page name is literally SbRotation(3) β that's the header AND the footer, she's consistent, she's committed, she's the moment. π«Ά go rotate something. π
π¦ where this page comes from
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.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