This topic explains how to configure the XamScatterSurface3D™ control rotation using code.
The following topics are prerequisites to understanding this topic:
The following table lists the external articles required as a prerequisite to understanding this topic.
This topic contains the following sections:
Use the Rotation property to set rotation programmatically in the xamScatterSurface3D control.
Set the Rotation
property to an AxisAngleRotation3D
object with specified angle and axis of rotation.
The following table maps the desired configuration to the property settings that manage it.
The screenshot below demonstrates how the xamScatterSurface3D control looks as a result of the following settings – 60 degrees rotation around the Y axis:
Following is the code that implements this example.
In XAML:
<ig:XamScatterSurface3D Name="SurfaceChart"
ItemsSource="{Binding Path=DataCollection}"
XMemberPath="X" YMemberPath="Y" ZMemberPath="Z">
<ig:XamScatterSurface3D.Rotation>
<AxisAngleRotation3D Angle="60" Axis="0 1 0" />
</ig:XamScatterSurface3D.Rotation>
</ig:XamScatterSurface3D>
In C#:
var axis = new Vector3D(0, 1, 0);
var axisAngleRotation3D = new AxisAngleRotation3D(axis, 60);
SurfaceChart.Rotation = axisAngleRotation3D;
In Visual Basic:
Dim axis = New Vector3D(0, 1, 0)
Dim axisAngleRotation3D = New AxisAngleRotation3D(axis, 60)
SurfaceChart.Rotation = axisAngleRotation3D
Use the Rotation property to set rotation programmatically in the xamScatterSurface3D control.
Set the Rotation
property to a QuaternionRotation3D
object that represents a rotation transformation defined as a quaternion.
If the rotation axes are named ax, ay and az and the angle of rotation is named theta, you can calculate the quaternion using the following formula:
The quaternion (x, y, z, w) is:
x = ax * sin(theta/2)
y = ay * sin(theta/2)
z = az * sin(theta/2)
w = cos(theta/2)
So if you want to rotate the xamScatterSurface3D control around the Y axis and with angle of 60 degrees as the example above, the quaternion will be equal to (0, 0.5, 0, 0.866).
The following table maps the desired configuration to the property settings that manage it.
The screenshot below demonstrates how the xamScatterSurface3D control looks as a result of the following code:
Following is the code that implements this example.
In XAML:
<ig:XamScatterSurface3D Name="SurfaceChart"
ItemsSource="{Binding Path=DataCollection}"
XMemberPath="X" YMemberPath="Y" ZMemberPath="Z">
<ig:XamScatterSurface3D.Rotation>
<QuaternionRotation3D Quaternion="0, 0.5, 0, 0.866" />
</ig:XamScatterSurface3D.Rotation>
</ig:XamScatterSurface3D>
In C#:
…
var quaternion = new Quaternion();
quaternion.X = 0;
quaternion.Y = 0.5;
quaternion.Z = 0;
quaternion.W = 0.866;
var quaternionRotation3D = new QuaternionRotation3D();
quaternionRotation3D.Quaternion = quaternion;
SurfaceChart.Rotation = quaternionRotation3D;
In Visual Basic:
…
Dim quaternion = New Quaternion()
quaternion.X = 0
quaternion.Y = 0.5
quaternion.Z = 0
quaternion.W = 0.866
Dim quaternionRotation3D = New QuaternionRotation3D()
quaternionRotation3D.Quaternion = quaternion
SurfaceChart.Rotation = quaternionRotation3D
The following topics provide additional information related to this topic.