vpRotate(3)

πŸ“¦ version 1.0c7, in fedora 43, fedora 44

πŸ’« vpRotate β€” bestie edition πŸ’«

okay so real quick, this is from the Library Functions Manual and it's all about vpRotate, a lil function that spins your stuff around. not literally spinning you around (though honestly? mood). let's get into it πŸŽ€


✨ NAME ✨

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

like. that's the whole job. it rotates. it multiplies. it slays. πŸ’…


🌸 SYNOPSIS 🌸

#include <volpack.h>

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

πŸ¦‹ ARGUMENTS πŸ¦‹

  • vpc β€” your VolPack context, the one you got from vpCreateContext. it's the main character of your whole rendering situation fr.
  • axis β€” the rotation axis code. has to be one of VP_X_AXIS, VP_Y_AXIS or VP_Z_AXIS. pick your vibe, bestie.
  • degrees β€” how many degrees you wanna rotate. that's it, that's the number.

πŸ’– DESCRIPTION πŸ’–

so vpRotate multiplies the current transformation matrix by a 4-by-4 rotation matrix. iconic behavior honestly.

the rotation axis has to be one of the three principal viewing axes, and you specify it with one of these codes:

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

the rotation angle is given in degrees. and listen, this part matters: a positive angle means a clockwise rotation when you're looking towards the positive direction along the axis. lowkey important, don't sleep on it πŸ‘€

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, in case that wasn't obvious β€” no shade, just saying 🫢)


use vpCurrentMatrix to set the current transformation matrix. by default, the rotation matrix is post-multiplied, like:

M = M*R

where M is the current matrix and R is the rotation matrix. but if you're feeling a different flavor, the VP_CONCAT_MODE option to vpSeti can be used to select pre-multiplication. options, we love to see it ✨


πŸ‘‘ STATE VARIABLES πŸ‘‘

the current matrix concatenation parameters can be retrieved with these state variable codes (peep vpGeti(3) for the deets):

  • VP_CURRENT_MATRIX
  • VP_CONCAT_MODE

😭 ERRORS 😭

the normal return value is VP_OK. literally the good ending.

the following error return value is possible:

  • VPERROR_BAD_OPTION β€” the axis argument is invalid. like bestie, that's not one of the three axes. read the room πŸ’€

πŸ”₯ SEE ALSO πŸ”₯


reminder that a positive angle = clockwise rotation when looking towards the positive direction along the axis. write it on your hand if you have to πŸŽ€

okay that's the whole page, mwah πŸ’œ this was VolPack, vpRotate(3), and that's a wrap β€” go rotate something gorgeous 🌈⭐

πŸ“¦ where this page comes from