0

I am very new to rigid body transformations.

I would like to align a 3D rigid body such that its first axis $o1$ would align with the display's vertical axis $d1$ and its second axis $o2$ with the display's horizontal axis $d2$.

In the case at hand, a human palm: I would like to align such that the palm's forward distal direction faces up in the display, and the direction perpendicular to it across the palm faces left on the display, so that the center of the palm faces forward and its front fingers face up. From an arbitrarily oriented point cloud describing the hand, from which let us assume I can somehow derive the mentioned two axes of the hand.

I've experimented aligning the entire rigid body by a rotation matrix from one single axis to the other as per this kind of transformation, which won't immediately scale for aligning two sets of (two) axes without getting the wrong directionality half of the time.

Even when aligning by just one axis through that technique ― the alignment only works in the sense of the axes converging ― without them necessarily agreeing on the sign of their direction, and hence the rigid body will undesirably flip.

Could you point me in the right direction?

matanox
  • 132
  • 1
    So, in plainer terms, you want to display a 3D rendering of a hand roughly in the orientation of a common "stop/halt" or "talk-to-the-hand" or "high five" gesture? – DotCounter Jul 27 '23 at 15:45
  • Yes indeed! Thanks for the reformulation. Maybe we could call it something like a Right-Hand-Rule preserving alignment transform between two sets of two axes, but I'm not entirely sure. – matanox Jul 27 '23 at 15:58
  • When you say "gets the wrong direction half the time" do you mean that it snaps to the axes pretty reliably, but it is just flipped 180 in some direction (sometimes palm away, sometimes fingers pointing down, etc.)...? – DotCounter Jul 27 '23 at 16:12

1 Answers1

1

Let me assume that in your display coordinate system, the positive $y$-axis points up, and the positive $x$-axis points to the right. This is the common orientation used in most mathematical graphing, but it is only in recent years that computer graphics applications started honoring that convention, so it is possible that your system may use some different convention. If that is the case, you will need to modify the steps below.

So you have a unit vector $u = (u_x, u_y, u_z)$ that you want to map to $\hat y = (0,1,0)$ in display-coordinates, and another unit vector $v = (v_x, v_y, v_z)$ that you want to map to $-\hat x = (-1, 0, 0)$ (which is the left direction). And what you want to find is the transformation that converts all other points to their display coordinates.

First, we need to find the unit vector $w$ to map to the $\hat z$ direction in display coordinates. Now $\hat z = \hat y \times (-\hat x)$, and the same relationship should hold between $u, v, w$. That is $$w = u \times v = (u_yv_z - u_zv_y, u_zv_x - u_xv_z, u_xv_y - u_yv_x)$$

Once you've calculated $w$, an arbitrary point $r = (r_x, r_y, r_z)$ transforms into $(-v\cdot r, u\cdot r, w\cdot r)$ in display coordinates. That is, the transformation matrix is $$\begin{bmatrix}-v_x&-v_y&-v_z\\u_x&u_y&u_z\\u_yv_z - u_zv_y&u_zv_x - u_xv_z&u_xv_y - u_yv_x\end{bmatrix}$$

Note again that this requires $u$ and $v$ to be orthogonal unit vectors. If they are not, the image will be distorted,

Paul Sinclair
  • 43,643