Transform matrix from TRS?

45 views Asked by At

Even after reading the section on transformation from nalgebra, I don't get how I can compose a transform matrix from translation, unitquaternion and a non uniform scale:

let transl_m = Translation3::new(transl[0], transl[1], transl[2]);
let mut uq : UnitQuaternion::<f32> = Default::default();
let mut q = uq.quaternion(); // not sure it's the best way to init a unit quaternion from x,y,z,w variables.
q.coords.x = rot.0[0];
q.coords.y = rot.0[1];
q.coords.z = rot.0[2];
q.coords.w = rot.0[3];

let scal_m = Scale3::new(scal[0], scal[1], scal[2]);

Scale is non uniform. So I want an Affine3 but don't know how to obtain it. Tried with the Affine3 default constructor:

let af: nalgebra::Affine3::<f32> = Default::default();

and find my way, but it didn't help, except manually setting the homogeneous matrix.

What I want is something like:

let local_TRS =  scal_m * uq * transl_m;

What is the proper way to do it?

0

There are 0 answers