C++: Rotate vector around normal of plane
Asked Answered
K

3

6

I'm trying to rotate a point on a plane around the normal of the plane with a certain angle (so it stays on the plane).

For example:

  • Point = (0,0,1) (on the plane)
  • Normal = (0,1,0)
  • Angle = 33 degrees

But can't seem to figure out how to do it

EDIT:

The axis of rotation always passes through the origin (0,0,0)

Keelboat answered 20/3, 2012 at 16:3 Comment(3)
I assume you mean for the axis of rotation to pass through the origin?Teishateixeira
Yes, it does. It always passes through (0,0,0)Keelboat
So is it the math you need help with, or the Irrlicht API, or just what? What have you tried?Teishateixeira
C
4

If you're looking for axis-angle rotations in 3-space, Rodrigues's Rotation Formula is very useful. The Wikipedia page is pretty good: here

Cyrilla answered 20/3, 2012 at 19:35 Comment(0)
O
0

Probably not optimal, but: find the span vectors of the plane (call them U and V), express the point P in terms of U and V and apply 2D rotation. PS: a normal does not fully define a plane; you need at least a point in the plane in addition.

Orgel answered 20/3, 2012 at 16:8 Comment(3)
Then the normal and that point uniquely determine the plane, and since the point lies on the axis of the rotation, the rotation will be no-op.Orgel
Actually, no. The OP stated (in an edit) that "The axis of rotation always passes through the origin (0,0,0)". The point to be rotated is on the plane, but is not necessarily (in fact, is unlikely to be) on that axis.Hebdomad
Well then, I blame the OP for incomplete problem description (I read the text before his comment). The method I described is still valid though.Orgel
H
0

To compute the rotation matrix you want, you will need a bit of linear algebra. There is an article on Wikipedia which explains what you need to do.

Hilaria answered 20/3, 2012 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.