09-11-2020, 04:40 PM
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.
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);
RotateTransform3D rotateTransform3D_X = new RotateTransform3D(rot_X, _selectedBoxModel.CenterPosition);
AddTransform(_selectedBoxModel, rotateTransform3D_X);
AxisAngleRotation3D rot_Y = new AxisAngleRotation3D(Ab3d.Common.Constants.YAxis., 90);
RotateTransform3D rotateTransform3D_Y = new RotateTransform3D(rot_Y , _selectedBoxModel.CenterPosition);
AddTransform(_selectedBoxModel, rotateTransform3D_Y);
private void AddTransform( Visual3D visual3D, Transform3D transform3D )
{
if ( visual3D.Transform == null )
{
visual3D.Transform = transform3D;
return;
}
var transform3DGroup = visual3D.Transform as Transform3DGroup;
if ( transform3DGroup == null )
{
// If there is already some other transformation, then create a new Transform3DGroup
transform3DGroup = new Transform3DGroup();
transform3DGroup.Children.Add(visual3D.Transform);
visual3D.Transform = transform3DGroup;
}
// Insert rotation as the first transformation - this way we are sure that it gets before any translations
if ( transform3DGroup.Children.Count > 0 )
transform3DGroup.Children.Insert(0, transform3D);
else
transform3DGroup.Children.Add(transform3D);
}