0
\$\begingroup\$

I'm trying to spin up my own 3D vector graphics engine, so I'd like to do this without an existing library. And I don't seem to be able to find the math for the correct approach in rotating an object around its own axis.

I can definitely do x/y/z rotations around a chosen point with values pt.x pt.y and pt.z. But I am unsure of how to make them unique to the object's orientation, so they are always being expressed in relation to the monitor (not even the environment yet, just the screen).

So which mathematical concept am I supposed to be applying here?

\$\endgroup\$
  • \$\begingroup\$ could you download the library and copy the source code you need ? \$\endgroup\$ – Raxvan Feb 18 '14 at 16:34
  • 1
    \$\begingroup\$ I'd prefer to understand the things I need to learn than c/p someone's code. Is that weird? Apparently it earns me a downvote. Thanks Internets - sorry I didn't want to take the easy out \$\endgroup\$ – Stick Feb 18 '14 at 16:52
  • \$\begingroup\$ I think it's fine. I didn't find any really decent answers for this either. \$\endgroup\$ – MichaelHouse Feb 18 '14 at 17:11
2
\$\begingroup\$

You're going to have tons of questions regarding 3D math so I recommend you get the book Essential Math for Game Programmers, the 2nd Ed. I bought a copy myself and was reading it last night before bed.

http://essentialmath.com/book.htm

For your specific question you can use a rotation matrix to represent your object's orientation. You can concatenate this matrix with other transformations in order to update or apply additional transformations.

For example, if you build a matrix that will apply a small rotation about the x axis and apply this transformation to your objects orientation matrix, the orientation matrix will be rotated around the x axis by this amount. If you just want your object so spin about the x axis it should be translated to the origin before a rotation is applied, then translated back to it's original translation. This will prevent your object's translation from being rotated as well.

\$\endgroup\$
  • \$\begingroup\$ Your answer is 60% comment and the answer provided is vague. -1 \$\endgroup\$ – MichaelHouse Feb 18 '14 at 16:41
  • \$\begingroup\$ @Byte56 Updated the answer slightly! I think this is what we're after. \$\endgroup\$ – RandyGaul Feb 18 '14 at 16:45
  • 1
    \$\begingroup\$ Closer, I think OP is more interested in rotating around the local axis of the object (not the global axis centered on the object). Like the Earth spinning around its tilted axis. \$\endgroup\$ – MichaelHouse Feb 18 '14 at 16:49
  • \$\begingroup\$ This might answer a lot of my questions pre-emptively. I'll have to peruse this when I have time \$\endgroup\$ – Stick Feb 18 '14 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.