SbRotation(3)

πŸ“¦ version 2.5.0, in fedora 43, fedora 44

πŸ’– 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 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 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(), and SbMatrix::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(), and setValue().

✨ 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(), and SbRotation().
  • Referenced by: SoVRMLSound::audioRender(), SoVRMLProximitySensor::doAction(), SoRotation::getMatrix(), SoRotationXYZ::getMatrix(), SoVRMLBackground::GLRender(), SbMatrix::setTransform(), SbMatrix::setTransform(), SoCenterballDragger::transferCenterDraggerMotion(), SoDirectionalLightDragger::valueChangedCB(), and SoSpotLightDragger::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(), and SoDebugError::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(), and setValue().

✨ 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(), and setValue().
  • 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(), and SbMatrix::setRotate().
  • Referenced by: SoVRMLSound::audioRender(), and SoTrackballDragger::dragStart().

✨ void SbRotation::scaleAngle (const float scaleFactor) ✨

Scales the angle of rotation by scaleFactor. Angle glow-up, literally.

  • References: getValue(), and setValue().

✨ 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(), and SbRotation().
  • 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(), and SoVRMLViewpoint::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.


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==, and SbRotation().
  • 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!=, and SbRotation().
  • 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*, and SbRotation().
  • 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