I am trying to have a TrackBarEdit slider control the rotation angle about the X axis of 3D Chart. I have a TrackBarEdit element that uses the EditValueChanged event to call the following method:
C#private void RotationSliderChangedEvent(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
{
AxisAngleRotation3D AxisRotationX = new AxisAngleRotation3D(new Vector3D(1, 0, 0), RotationSlider.Value);
AxisAngleRotation3D AxisRotationY = new AxisAngleRotation3D(new Vector3D(0, 1, 0), Vector3D.AngleBetween(new Vector3D(0, 1, 0), MainChart3D.ContentTransform.Transform(new Vector3D(0, 1, 0))));
AxisAngleRotation3D AxisRotationZ = new AxisAngleRotation3D(new Vector3D(0, 0, 1), Vector3D.AngleBetween(new Vector3D(0, 0, 1), MainChart3D.ContentTransform.Transform(new Vector3D(0, 0, 1))));
MainChart3D.ContentTransform = RotateGraph(AxisRotationX, AxisRotationY, AxisRotationZ);
}
private Transform3D RotateGraph(params AxisAngleRotation3D[] rotations)
{
Transform3DGroup transform = new Transform3DGroup();
foreach (AxisAngleRotation3D axisRotation in rotations)
{
transform.Children.Add(new RotateTransform3D(axisRotation));
}
return transform;
}
MainChart3D is my Chart3DControl element. However, when moving the slider, the chart moves wildly, even though it is correctly calculating the angle of the three axes. What I am doing incorrectly here, and what is the proper way to get the angle and axis for a rotation matrix in this way? Thank you in advance.