![]() |
|
BoxVisual3D AxisAngleRotation3D problem - Printable Version +- AB4D Forum (https://forum.ab4d.com) +-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4) +--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9) +--- Thread: BoxVisual3D AxisAngleRotation3D problem (/showthread.php?tid=4215) |
BoxVisual3D AxisAngleRotation3D problem - mpiccotti - 09-11-2020 Good morning, using AxisAngleRotation3D I find problems in the inconsistency of rotations. The result of the rotations depends on the order in which I perform the rotations. To explain me better: To an object I first add a 90 degree Z rotation, then I add a 90 degree X rotation and the model performs the transformation I expect. By reversing the order of rotations, the model performs an unexpected transformation. I add the code to better understand the actions I perform. Code: AxisAngleRotation3D rot_X = new AxisAngleRotation3D(Ab3d.Common.Constants.XAxis., 90);RE: BoxVisual3D AxisAngleRotation3D problem - janovrom - 09-11-2020 Hi, It's actually correct behavior. You are combining rotations and that operation is not commutative (it's order dependent). Transform3D is also represented by a matrix and Transform3DGroup uses matrix multiplication, again that is not commutative operation. RE: BoxVisual3D AxisAngleRotation3D problem - abenedik - 09-14-2020 As janovrom has explained, the order of rotations matters (expect if you rotate around the same axis then you can add or substitute the angles). Also the order of transformation matters: if you first do translation and then rotation, you will get different results as if you first rotate and then do a translation. Usually you first scale, then rotate and finally translate. But you can also simplify transformation with using StandardTransformaton3D. Note that because it is not possible to derive from Transform3D, you cannot simply assign StandardTransformaton3D to Transform property - instead you first create StandardTransformaton3D object and then assign its Transform property to Model3D.Transform or Visual3D.Transform - for example: Code: var sphereVisual3D = new SphereVisual3D();With StandardTransformaton3D you can use TranslateX, TranslateY, TranslateY; ScaleX, ScaleY, ScaleZ; RotateX, RotateY, RotateZ properties. RE: BoxVisual3D AxisAngleRotation3D problem - mpiccotti - 09-16-2020 Thanks, it's a great solution for my application Michele |