Cancel
Showing results for
Search instead for
Did you mean:

# Rotate Frame Valued Contributor

hi,

Is there a method to rotate a frame or object?

this is my attempt(rotate y 90 degrees):

```            TxTransformation  select;
TxTransformation fr = new TxTransformation(
0, 0, -1, 0,
0, 1, 0, 0,
1, 0, 0, 0);
TxTransformation ry90 = select * fr;```

The result is the same as the manual rotation of the y-axis 90 degrees

and I try this:

`            COlpUtilMath.RotateY(select, 90);`

but the result is not correct.

4 REPLIES 4

# Re: Rotate Frame Phenom

What if you change fr.RotationRPY_XYZ.Y with your rotation needs (in radians)?

# Re: Rotate Frame Valued Contributor

TxTransformation consists of 3X3 rotation matrix and translation vector.

Setting the RotationRPY_XYZ, set  the 3X3 matrix.

It is using the Roll-Pitch-Yaw X_Y_Z method, meaning rotation are done relative to the fixed original axes, in the order

rotation  around X axis, then rotation around  Y axis, and finally around Z axis.

Hope it answered your question....

# Re: Rotate Frame Valued Contributor

Hy,

I am rotating Location which is almost the same like frame for 180 degree. Important in this case is that you change absolute location and not only rotation! But like Yizhar mention this is the matrix, so for example if you change RY for 180 degrees also values RX and RZ will change but orientation will be ok.

Here is part of my code:

private void m_btnRx_Click(object sender, EventArgs e)
{
double rx = FlipLocation.AbsoluteLocation.RotationRPY_XYZ.X;
double ry = FlipLocation.AbsoluteLocation.RotationRPY_XYZ.Y;
double rz = FlipLocation.AbsoluteLocation.RotationRPY_XYZ.Z;

double degreeRx = RadToDegree(rx);
double flipedRx = FlipRotation(degreeRx);
double newRx = DegreeToRad(flipedRx);

TxTransformation absLoc = FlipLocation.AbsoluteLocation;
absLoc.RotationRPY_XYZ = new TxVector(newRx,ry,rz);

FlipLocation.AbsoluteLocation = absLoc;

TxApplication.RefreshDisplay();
}

private double FlipRotation(double rotation)
{
double newRotation;

if (rotation > 0)
{
newRotation = rotation - 180;
}
else
{
newRotation = rotation + 180;
}

return newRotation;
}

Hope this will somehow help you!

Tomaz

# Re: Rotate Frame Valued Contributor

There are two options for rotating existing matrix:

1. Get, from the matrix, the rotation values rx, ry, rz
Change the rotation values, for example: rx=rx+dx,  ry=ry+dy,  rz=rz+dz
Set the new rotation value to matrix by: mat.RotationRPY_XYZ = new TxVector(rx,ry,rz);
2. Create matrix representing the rotations by dx, dy, dz
Multiply the existing matrix by the rotation matrix

The result of both methods is the same.
If used several times in a loop, option #1 tent to accumulate more calculation errors, as both, creating matrix from rotations and extracting rotation from matrix involved in many trigonometric calculation.
The second method is more stable, as include just matrix multifaction.