Helix 工具包,获取新的旋转矢量
Helix toolkit, getting a new rotation vector
我有一个 6 轴机器人。
我正在尝试让每个轴独立移动。当第一个轴处于其原点角度时,机器人轴都正确移动,但当它被修改时,所有其他轴移动不正确。它们保留了正确的旋转点,而不是新矢量。
The Skewed axis
我遵循了这个教程http://www.barth-dev.de/getting-started-3d-wpf/
//moves axis_1
void move_axis_1(double angle)
{
//rotate the object by "angle", the vector describes the axis
RotateTransform3D axis_1_transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), angle));
//tells where the point of rotation is
axis_1_transform.CenterX = 77.5;
axis_1_transform.CenterY = 21.5;
axis_1_transform.CenterZ = -8;
//apply transformation
axis_1.Transform = axis_1_transform;
//also move the axis 2
move_axis_2(axis_2_angle);
}
//moves axis_2
void move_axis_2(double angle)
{
//new group of transformations, the group will "add" movements
var Group_3D = new Transform3DGroup();
Group_3D.Children.Add(axis_1.Transform);
//we need to find out where our old point is now
Point3D origin = Group_3D.Transform(new Point3D(84.6, 21, -2));
//create new transformation
RotateTransform3D axis_2_transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), angle));
axis_2_transform.CenterX = origin.X;
axis_2_transform.CenterY = origin.Y;
axis_2_transform.CenterZ = origin.Z;
//add it to the transformation group (and therefore to axis_1 movement
Group_3D.Children.Add(axis_2_transform);
//Apply the transform
axis_2.Transform = Group_3D;
//also move
move_axis_3(axis_3_angle);
}
//moves axis_3
void move_axis_3(double angle)
{
//new group of transformations, the group will "add" movements
var Group_3D = new Transform3DGroup();
Group_3D.Children.Add(axis_2.Transform);
//we need to find out where our old point is now
Point3D origin = Group_3D.Transform(new Point3D(84.6, 17, 16.2));
//create new transformation
RotateTransform3D axis_3_transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), angle));
axis_3_transform.CenterX = origin.X;
axis_3_transform.CenterY = origin.Y;
axis_3_transform.CenterZ = origin.Z;
//add it to the transformation group
Group_3D.Children.Add(axis_3_transform);
//Apply the transform
axis_3.Transform = Group_3D;
//also move
move_axis_4(axis_4_angle);
}
您还必须转换 Vector。
//we need to find out where our old point is now
Point3D origin = Group_3D.Transform(new Point3D(84.6, 21, -2));
//we also need to find out where our old vector is pointing now
Vector3D vector = Group_3D.Transform(new Vector3D(0, 1, 0));
//create new transformation
RotateTransform3D axis_2_transform = new RotateTransform3D(new AxisAngleRotation3D(vector, angle));
axis_2_transform.CenterX = origin.X;
axis_2_transform.CenterY = origin.Y;
axis_2_transform.CenterZ = origin.Z;
我也更喜欢旋转中心的过载。然后你不需要在之后设置中心。但这只是我的意见:
//create new transformation
RotateTransform3D axis_2_transform =
new RotateTransform3D(new AxisAngleRotation3D(vector, angle), origin);
我有一个 6 轴机器人。
我正在尝试让每个轴独立移动。当第一个轴处于其原点角度时,机器人轴都正确移动,但当它被修改时,所有其他轴移动不正确。它们保留了正确的旋转点,而不是新矢量。
The Skewed axis
我遵循了这个教程http://www.barth-dev.de/getting-started-3d-wpf/
//moves axis_1
void move_axis_1(double angle)
{
//rotate the object by "angle", the vector describes the axis
RotateTransform3D axis_1_transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), angle));
//tells where the point of rotation is
axis_1_transform.CenterX = 77.5;
axis_1_transform.CenterY = 21.5;
axis_1_transform.CenterZ = -8;
//apply transformation
axis_1.Transform = axis_1_transform;
//also move the axis 2
move_axis_2(axis_2_angle);
}
//moves axis_2
void move_axis_2(double angle)
{
//new group of transformations, the group will "add" movements
var Group_3D = new Transform3DGroup();
Group_3D.Children.Add(axis_1.Transform);
//we need to find out where our old point is now
Point3D origin = Group_3D.Transform(new Point3D(84.6, 21, -2));
//create new transformation
RotateTransform3D axis_2_transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), angle));
axis_2_transform.CenterX = origin.X;
axis_2_transform.CenterY = origin.Y;
axis_2_transform.CenterZ = origin.Z;
//add it to the transformation group (and therefore to axis_1 movement
Group_3D.Children.Add(axis_2_transform);
//Apply the transform
axis_2.Transform = Group_3D;
//also move
move_axis_3(axis_3_angle);
}
//moves axis_3
void move_axis_3(double angle)
{
//new group of transformations, the group will "add" movements
var Group_3D = new Transform3DGroup();
Group_3D.Children.Add(axis_2.Transform);
//we need to find out where our old point is now
Point3D origin = Group_3D.Transform(new Point3D(84.6, 17, 16.2));
//create new transformation
RotateTransform3D axis_3_transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), angle));
axis_3_transform.CenterX = origin.X;
axis_3_transform.CenterY = origin.Y;
axis_3_transform.CenterZ = origin.Z;
//add it to the transformation group
Group_3D.Children.Add(axis_3_transform);
//Apply the transform
axis_3.Transform = Group_3D;
//also move
move_axis_4(axis_4_angle);
}
您还必须转换 Vector。
//we need to find out where our old point is now
Point3D origin = Group_3D.Transform(new Point3D(84.6, 21, -2));
//we also need to find out where our old vector is pointing now
Vector3D vector = Group_3D.Transform(new Vector3D(0, 1, 0));
//create new transformation
RotateTransform3D axis_2_transform = new RotateTransform3D(new AxisAngleRotation3D(vector, angle));
axis_2_transform.CenterX = origin.X;
axis_2_transform.CenterY = origin.Y;
axis_2_transform.CenterZ = origin.Z;
我也更喜欢旋转中心的过载。然后你不需要在之后设置中心。但这只是我的意见:
//create new transformation
RotateTransform3D axis_2_transform =
new RotateTransform3D(new AxisAngleRotation3D(vector, angle), origin);