c# - Discard scale transform of Camera in Viewport3D -
i have main viewport3d
mcamera
, controlled trackballdecorator
. want create viewport3d
cube in represent current camera direction on main viewport.
this code:
matrix3d transformationmatrix = mcamera.transform.value; // ? orientationcamera.transform = new matrixtransform3d(transformationmatrix);
works well, besides fact don't want orientationcamera
apply zoom main 1 (i want rotate).
i can see values m11
, m22
, m33
of matrix changing when operating on zoom main camera, change when i'm rotating it, , change try apply resulted preview cube transform in unexpected way.
does have idea how discard scaletransform
transformation matrix? or maybe there way it?
the first 3 rows (or columns) in pure rotation matrix unit vectors. if apply scale, these vectors aren't of unit-length more. can apply inverse scale rid of scale. assuming scale equal in 3 directions:
var m11 = transformationmatrix.m11; var m12 = transformationmatrix.m12; var m13 = transformationmatrix.m13; var length = math.sqrt(m11 * m11 + m12 * m12 + m13 * m13); var factor = 1 / length; transformationmatrix.scale(new vector3d(factor, factor, factor));
Comments
Post a Comment