LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3d rotations

Hello!

I need to find rotation matrix (or vector) from one point to another.

I have some couples of points, but here is simple version.

3d.PNG

 

Start point - the one corner of the red flat. End point - the corner of the yellow flat.

I can to calculate coordinates of points, but I have a problem with rotation.

Also I need constant z-rotation for each detail (i.e. one corner of the detal must see to the "nord")

And here the part of code.

3dVI.PNG

0 Kudos
Message 1 of 10
(4,377 Views)

Maybe it's me but I do not understand your question. Try to break down your question(s) into cases as simple as possible, and ask only one question at a time. Give us the code of what you tried and specifically tell us what is the issue with that code.

Marc Dubois
0 Kudos
Message 2 of 10
(4,355 Views)

Hi, Marc!

 

I'll try

 

line.png

 

I have an object in scene. Now it a green axis.
And I have a 2 points.
I need rotate and place this object, so it's Z- axis go from one point to another (as the pink line).

My simplified code is attached in first message

 

And the problem is that Z-axis finished not in green ball

0 Kudos
Message 3 of 10
(4,349 Views)

I've done a lot of work with rotation matrices, rotation vectors, rotation axes, etc. and I have no idea what you want to do, nor do I understand the figure you are showing, and how it relates to your question.  Here's what I think I am seeing:

  • There's a Red Rectangle that I think contains the Origin, as it seems to have a (barely-seen) X Axis going away from the viewer, slightly up and to the right, a Y axis that appears to have an "arrow" pointed at it, and a Z axis whose arrow is not visible, being covered by a yellow rectangle (whose purpose I don't understand).  There are a set of three orthogonal Green Axes whose meaning is unclear, and another set of Blue Axes (going through a green ball) whose meaning is unclear.
  • As you probably know, Rotation Axes/Matrices describe rotations of a sphere about either world-centric X-Y-Z axes or sphere-centric X-Y-Z axes (and it makes a difference how you define your rotations!).
  • I'm going to assume that your code is wrong/useless (otherwise you wouldn't be asking questions here), so without reference to the code, what are you trying to do?  One usually says something like "I have a a point on a sphere whose polar coordinates are theta1, phi1, and I want to bring this to another point whose coordinates are thetat2, phi2 by making the following three rotations -- one about the Z (vertical) axis, next about the (earth-fixed) X axis, and finally about the (again earth-fixed) Y axis", or "I have two points and I want to find the axis on the sphere about which I can make a single rotation that takes Point 1 into Point 2", or <something else>.  What is your question?
  • Please do not show us this picture again without explaining clearly and carefully (with lines and arrows) what everything is supposed to represent!

Bob Schor

0 Kudos
Message 4 of 10
(4,344 Views)

Usually for alignments like this, I will translate so 0,0,0 is one of the points, then the other point (in a spherical coordinate system) in some distance and two angles. 

By rotation of the second object around 2 axes by these angles (in opposite direction) your axis is now aligned, you can then translate everything back to the original 0,0,0.

0 Kudos
Message 5 of 10
(4,323 Views)

Your question is still not clear and the code you provided is not simple. You should provide just the code related to your problem. We cannot help you if you do not make an effort to make your question simple and understandable.

 

I will assume that you want to rotate a coordinate system that has its Z-axis going through point P1 and you want to rotate the coordinate system so that the Z-axis passes through point P2.

 

Since the Z-axis passes through P1, the value of P1 is irrelevant, the initial vector P1 is the Z-axis (0,0,1).

 

LabVIEW provides a function to rotate 3D object. You have to provide a rotation axis and an angle.

 

You get the rotation axis by calculating the cross product between the P1 vector and the vector from origin to P2.

 

You calculate the angle by calculating the dot product between vector P1 and vector P2 (both vectors must be normalized) and then calculating the arccosine. If you have to rotate within another coordinate system, you just need to calculate the two corresponding vectors (P minus origin).

 

The code would look like this:

 

3D rotate between points_BD.png

 

 

Marc Dubois
0 Kudos
Message 6 of 10
(4,308 Views)

Hello all and thanks for your attention.
I'll try explain again

 

In general I need a direction from a one point to another.

 

The red box is a "base". It's fixed. And the white axis is a "world" coordinates. The point (-10,-5,0) is a start point (constant).

Also I have a yellow box. And the point (10,5,0) (relative) is the end point (second point). And this box moves. And the second point moves also.

001.PNG

 

Next, I have the complex object (it figure from stl, but now it just a green box). This opbject has it's own axis (also rgeen) for anderstanding

I have a six objects and a more complex bases.

 

First step. The Y-axis of the object must see to direction of 45 degree (for example here, each object has it's own direction).

002.PNG

 

And second step, the z-axis of the object must see to the second point.
Like here.

003.PNG

 

In some positions my algorithm work well, but in another the vector or matrix is wrong

0 Kudos
Message 7 of 10
(4,296 Views)

@deceased wrote:

Usually for alignments like this, I will translate so 0,0,0 is one of the points, then the other point (in a spherical coordinate system) in some distance and two angles. 

By rotation of the second object around 2 axes by these angles (in opposite direction) your axis is now aligned, you can then translate everything back to the original 0,0,0.


Yes, I try to do this, but I have a mistake in my code and can't fix it

0 Kudos
Message 8 of 10
(4,293 Views)

@MarcDub wrote:

You calculate the angle by calculating the dot product between vector P1 and vector P2 (both vectors must be normalized) and then calculating the arccosine. If you have to rotate within another coordinate system, you just need to calculate the two corresponding vectors (P minus origin).

 

The code would look like this:

 

3D rotate between points_BD.png

 

 


I've tried your method, but it doesn't work (or I made a mistake)

Also you need set rotation vi, not a rotate object

0 Kudos
Message 9 of 10
(4,291 Views)

Could this be the problem that quaternions solve?

0 Kudos
Message 10 of 10
(4,267 Views)