vpRotate(3)

πŸ’– vpRotate β€” spin that matrix, bestie πŸ’–

okay so real talk, this is the vpRotate page from the VolPack library functions manual, and it's literally just "multiply the current transformation matrix by a rotation matrix." That's the whole vibe. Rotating. Iconic behavior honestly.


✨ NAME ✨

vpRotate β€” multiply the current transformation matrix by a rotation matrix


πŸŽ€ SYNOPSIS πŸŽ€

#include <volpack.h>

vpResult
vpRotate(vpc, axis, degrees)
    vpContext *vpc;
    int axis;
    double degrees;

🌸 ARGUMENTS 🌸

  • vpc β€” the VolPack context you got from vpCreateContext. your whole setup, your main character.
  • axis β€” rotation axis code, and it has to be one of VP_X_AXIS, VP_Y_AXIS or VP_Z_AXIS. pick your lane πŸ’…
  • degrees β€” number of degrees to rotate. just a double, go off.

πŸ¦‹ DESCRIPTION πŸ¦‹

vpRotate is what you call when you wanna multiply the current transformation matrix by a 4-by-4 rotation matrix. That's it. That's the job.

The rotation axis must be one of the three principal viewing axes, specified with one of these codes:

  • VP_X_AXIS β€” X axis
  • VP_Y_AXIS β€” Y axis
  • VP_Z_AXIS β€” Z axis

The rotation angle is specified in degrees. A positive angle means a clockwise rotation when you're looking towards the positive direction along the axis. yes bestie, clockwise, write that down.

For an X-axis rotation, the rotation matrix is:

 1       0       0       0
 0    cos(d)  sin(d)     0
 0    -sin(d) cos(d)     0
 0       0       0       1

For a Y-axis rotation, the rotation matrix is:

 cos(d)     0    -sin(d)    0
    0       1       0       0
 sin(d)     0    cos(d)     0
    0       0       0       1

For a Z-axis rotation, the rotation matrix is:

 cos(d)  sin(d)     0       0
 -sin(d) cos(d)     0       0
    0       0       1       0
    0       0       0       1

where d stands for the degrees argument. she's everywhere, she's doing the math, we love her πŸ’–

Use vpCurrentMatrix to set the current transformation matrix. By default, the rotation matrix is post-multiplied β€” that's M = M*R, where M is the current matrix and R is the rotation matrix. And if you'd rather pre-multiply instead? the VP_CONCAT_MODE option to vpSeti lets you select that. options, options, options ✨


🌈 STATE VARIABLES 🌈

You can retrieve the current matrix concatenation parameters with these state variable codes (peep vpGeti(3)):

  • VP_CURRENT_MATRIX
  • VP_CONCAT_MODE

πŸ’€ ERRORS πŸ’€

The normal return value is VP_OK. but listen, the following error return value is possible:

  • VPERROR_BAD_OPTION β€” the axis argument is invalid. like, you gave it something that isn't one of the three axis codes. not the vibe. πŸ™ˆ

🫢 SEE ALSO 🫢

VolPack(3), vpCreateContext(3), vpCurrentMatrix(3)


and that's the whole page bestie, no notes πŸ‘‘

sign-off time: this little baddie lives in the VolPack library functions manual, and the page itself is stamped VolPack down at the bottom with vpRotate(3) hanging out on the right side. go rotate something. slay πŸŒˆπŸ’…βœ¨

πŸ“¦ where this page comes from