Notifications
Clear all

[Closed] How to align object rotation to reference axis points?

Hi everyone,

I am trying to align the rotation of a box to a x-, y- and z-axis based on reference points.

Please take a look at the attached image if you have the time.

The reference points are not perfectly formed at 90 angle degrees, and together they can have any rotation possible.

I tried to create rotation axis like this:

vector_x = $center_point.pos – $x_point.pos
vector_y = $center_point.pos – $y_point.pos
vector_z = $center_point.pos – $z_point.pos

rotate $Box001 (angleaxis vector_x.x [1,0,0])
rotate $Box001 (angleaxis vector_y.y [0,1,0])
rotate $Box001 (angleaxis vector_z.z [0,0,1])

but clearly I don’t know what I’m doing.

Could anyone show me how to do it correctly?

I have attached an example project file (3DSMax 2013).

Thanks!

2 Replies

You have the order wrong, subtract center point from the points to get each vector, normalize it to get unit vector. Cross product of two of them gives you another vector that’s orthogonal to them and this way you build the transformation matrix:

vector_x = normalize ($x_point.pos - $center_point.pos)
vector_y = normalize ($y_point.pos - $center_point.pos)
vector_z = normalize ($z_point.pos - $center_point.pos)

z = normalize (cross vector_x vector_y)
y = normalize (cross z vector_x)

$Box001.transform = matrix3 vector_x y z $center_point.pos

Thank you so much Swordslayer!

I really need to study 3D math some more