LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rotations in 3D picture control

Hi,

 

I have a question regarding 3D picture control.

 

I would like to rotate an object (say a cylinder) around the X-axis by 20 degrees and Y-axis by 45 degrees and Z-axis by 10 degrees at once. 

Suppose I should use a single "Set rotation.vi" to do the job, but I wonder how to calculate the axis of rotation and the angle of rotation, please?

 

 

I am using Labview 2013. I've tried to include two "Set rotation.vi" which were connected together. One rotate in X (Axis:[1,0,0], Angle 20) and the other in Y (Axis:[0,1,0], Angle 45), similar for Z-axis. However, having two or three of the same VI at once doesn't work. I've tried the "Rotate X-axis.vi" and "Rotate Y-axis.vi" as well, but no luck neither. 

 

Thank you

 

 

 

0 Kudos
Message 1 of 6
(7,599 Views)
Can you show the code you have developed so far?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 6
(7,570 Views)

 

I would like to rotate an object (say a cylinder) around the X-axis by 20 degrees and Y-axis by 45 degrees and Z-axis by 10 degrees at once. 

Suppose I should use a single "Set rotation.vi" to do the job, but I wonder how to calculate the axis of rotation and the angle of rotation, please?


 

This is an interesting math problem that involves Rotation Matrices (3 by 3 orthonormal matrix).  The matrices that do rotations about the X, the Y, and the Z axes are fairly easy to construct (they involve the sines and cosines of the angle of rotation operating on the non-rotation Axes, with the rotation Axis being left alone).  However, when you start talking about rotating about the X axis, the Y axis, and the Z axis at once, you run into the Surprise of rotations -- they are not commutative (as the Mathematicians would say) -- it make a difference in which order you rotate, so you must be specific.
Here's an example -- consider a right-hand coordinate system with Z up, X forward, and Y (forced to be) pointing to the left.  Take a shoe box, make its long axis align with X, and the box itself align with Z (so you can lift the top off).  Let's rotation 90° about X (top now faces to the right), 90° about Y (I'm using World-fixed coordinates here -- you could also use Box-fixed coordinates, but would get different answers -- see, it gets a little complicated, but now the top is still to the right, but the former Front is now down), and finally 90° about Z (front is still down, but now the top of the box faces backwards along the -X axis).  If, instead, I rotated about Z (top up, front right), then X (top right, front down), then Y (top right, front back), you can see that the position of the box is different.
Once you have decided on your Rotation Convention(s), you are ready for the next Math trick -- given any combination of rotations about different axes (in a specified order), you can achieve the same result by doing a single rotation about a single axis oriented in some to-be-determined direction.  If you think about this, an axis pointing somewhere in 3-space can be represented by a 3-D unit vector.  If you make the length of the vector a function of the angle of rotation, you get what is called a rotation vector, a vector representation of the 3-D rotation matrix we've been discussing.  Again, for interesting mathematical reasons, the function representing the length of the rotation vector is typically not simply the amount of rotation (in either degrees or radians) -- that would be much too simple.
This Forum is, obviously, not the place to have a full treatise on the mathematics of 3-D rotations.  If you are interested, searching the Web for "Rotation Matrix" and "Rotation Vector" should get you started.  If you are really curious, add "Quaternion" to your search ...
Bob Schor

 

 

 

0 Kudos
Message 3 of 6
(7,552 Views)

As Bob_Schor said, this forum is not the place for a mathematical treatise on rotation matrices.

 

However, LabVIEW has tools to handle rotation of objects in 3D. A first set of tools is available in the 3D picture control palette. Another set is available from the Mathematics -> Geometry palette.

 

Also, you need to determine if your rotations are relative to an absolute coordinate system or relative to the object itself. The first set of rotations is pretty easy to grasp but the second one can be tricky and is better handled using matrices.

 

There are therefore several ways to handle your problem. I took the liberty to create a small VI (see below) that illustrates 2 ways (rotation relative to absolute coordinate system using 3D picture tools, and rotation relative to object itself (called "relative" in the VI) using the Mathematics->Geometry tools), both of them illustrated using a 3D picture control.

 

Rotate_3D_object_FP.png

 

First, if you create a 3D object in a 3D picture control, you can easily rotate it using the rotate functions for each axis of the coordinate system.

 

Rotate_3D_object_BD.png

 

The object is then rotated around each of the axes of the coordinate system of the environment.

 

When rotating the object around itself, it means that after a rotation, the following rotation is made around the axis of the new coordinate system relative to the object.

 

LabVIEW has a function "3D_Cartesian_Coordinate_Rotation_Euler.vi" that does the transformation around 3 axes. You have to define a reference axis for your object (like the cylinder axis for example). In the example below, the reference axis is arbitrarily chosen as Y (0,1,0). You apply the desired rotations to the reference axis to obtain the orientation of the reference axis after the rotation.

 

If you desire to calculate a single rotation of the reference axis to its new orientation relative to a single axis, you have to calculate the dot product between the original and new reference axes for the angle, and the cross product for the rotation axis (useful for rotation of 3D objects in 3D picture controls, as shown below).

 

Notice that the approach using a single rotation around an arbitrary axis for the 3D picture object does not take rotation around the reference axis itself into account. You need to define a second reference axis for your object.

 

Rotate_3D_object_BD.png

 

The VI is attached to this message.

Marc Dubois
Message 4 of 6
(7,451 Views)

VI above but in LabVIEW 2013 version.

Marc Dubois
Message 5 of 6
(7,439 Views)

Thank you so much man! I was stuck in these transformation for so long. 🙂 

God bless you 😄 

0 Kudos
Message 6 of 6
(7,227 Views)