2
votes

Given a set of points on the surface of a hemisphere defined by the XZ plane in a left handed coordinate system: enter image description here

And given a normal vector to a plane that defines another arbitrary hemisphere: enter image description here

How can I define a rotation matrix that allows me to transform each point (vector) from the first hemisphere into the correspondent point in the second hemisphere?

If possible, it would be handy to have a rotation matrix that uses the spherical coordinates of N as rotation angles, with $\theta$ being the polar angle that goes $0$ to $\pi$ (intuitively from Y to -Y) and $\phi$ being the azimuthal angle that goes from $0$ to $2\pi$ (from X back again to X passing through +Z, -X, -Z).

1
Are you aware there is an infinite amount of solution ?galop1n
you'd need a tangent vector for a unique solution. if you are on a mesh, maybe you could align tangent and bitangent with the u and v directions.Volker Schmidt
what if I don't need a particular solution, but one correct solution, no matter which one?StrG30

1 Answers

0
votes

First step to build a rotation matrix is to define the sequence of (3) rotation around a single axis. In your case, with 2 angles, 2 rotation will be sufficient (with phi and theta).

I always refer to this structure from wikipedia For the use of phi and theta I can be wrong (with respect to your convention), but I try to be as clear as I can

My personal sequence could be: first a rotation around Y axis of an angle phi in [0,2pi] that align the "old" X and Z axis to the "new ones" supposing that N is parallel to Y. Then a rotation of an angle theta around the "new = already rotated" Z axis to bring the "new" Y axis along N.

So, lets build our matrices. A rotation around Y have this structure (I use ; to break the lines, R is always 3x3)

R_y = [cos(phi) 0 sin(phi); 0 1 0; -sin(phi) 0 cos(phi)]
R_z = [cos(phi) -sin(phi) 0; sin(phi) cos(phi) 0; 0 0 1]

The complete rotation from the old system to the new one is the product of the two matrices, remembering which one cames first

R = R_z*R_y

in fact we want to transform a set of 3D coordinates a in the old system, so it is:

b = R*a = R_z*R_y*a = R_z*(R_y*a)   

and you obtain the new coordinates b