1

I want to transform 3d mesh surface in a way that normal vector is parallel to z axis.

example of mesh surface and normal vector

I try the following steps:

1- find the rotation angle using

atan2d(norm(cross(n,z)),dot(n,z)); where n is the normal vector and z is the z-axis

2- find axis of rotation using cross product of n and z

3- create rotation matrix

however the resulted transformation is wrong.

Thanks for your help

Community
  • 1
  • 1
  • see [Rotation and direction of a vector in 3D space - Inverse Order](https://stackoverflow.com/a/51648789/2521214) You just use your normal as `S` and `(0,0,1)` as `T` – Spektre Aug 02 '18 at 17:53
  • 1
    Your approach is correct (if `n` and `z` are unit vectors). What transformation do you get? An easy mistake to make is to swap the orders in the cross product. This will get you the inverse transform. Also, why are you using the degree version of `atan2`? Do you respect this when calculating the rotation matrix? – Nico Schertler Aug 02 '18 at 17:53
  • Thanks Nico as you suggest the mistake is to swap the orders in cross product. –  Aug 03 '18 at 11:27
  • Show a [mcve] of your attempted solution. it shoudl work. – Ander Biguri Aug 31 '18 at 11:16

0 Answers0