LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3D picture creating a line between two coordinates

Hi every one, 

i am trying to create a straight line using two points (0,0,0) and (1,1,1) in 3D picture.

After i try i see that i don't get straight line that starts and (0,0,0) the origin, and ends in (1,1,1).

i am using LabVIEW 19(no vision)

 

The question is:

How should I use LabView commands in order to transform a vector V0 (thin cylinder)  to vector V1, where:

V0 is along the Z axis, its length is sqrt(3)/2, and its center is at the origin

V1 is located such that its bottom part is at the origin and its top part at (1,1,1)

 

The transformation i have in mind is:

  1. Rotation o 45 degrees about the Y axis and then rotation of -45 degrees about X axis, in the world coordinates (fixed)
  2. Translation of the center of the cylinder from (0,0,0) to (0.5, 0.5, 0.5)

 

 

I added VI that i used to do it.

I need some help and thank you.

0 Kudos
Message 1 of 4
(2,848 Views)

I've not done much with 3D drawing in LabVIEW, but have a lot of experience with 3D rotations.  Given a right-hand XYZ coordinate system, here is how I would draw a vector from 0,0,0 to 1,1,1 (note that there are multiple ways to do this):

  • You need a vector of length sqrt(3) (Pythagorean Theorem).
  • Rotations leave the origin (0, 0, 0) fixed, so start your vector at 0, 0, 0, and point it along the Z axis.
  • I'm going to assume that the rotations leave the axes "fixed" (if this isn't true with LabVIEW 3-D, you should be able to work out how to do it).
  • Rotate about the Y axis until the Z coordinate is 1.  How much is this?  Cos(Yrot) = 1/sqrt(3), and the new "end" coordinates are (sqrt(2), 0, 1).
  • Now rotate about the Z axis by 45°, which brings the tip to (1, 1, 1).

Bob Schor

0 Kudos
Message 2 of 4
(2,790 Views)

the center of mass of the thin cylinder is at 0,0,0

like this:

center-of-mass.PNG

 

all the rotation you do is relative to this point

 

 


@RomDev wrote:
"i am trying to create a straight line using two points (0,0,0) and (1,1,1) in 3D picture."

 

 

to achieve this in a 3d picture control, use "create mesh with attributes"

..\LabVIEW 2019\examples\Graphics and Sound\3D Picture Control\Creating Points and Lines.vi

points.PNG

 

lines.PNG

 

 

 

or do your own version of 3d Bresenham Algorithm:

e.g. https://www.geeksforgeeks.org/bresenhams-algorithm-for-3-d-line-drawing/

 

and use spheres exclusively

0 Kudos
Message 3 of 4
(2,766 Views)

Hi RomDev,

 

A universal approach is to create a cylinder of the right length. By default the cylinder center is at (0,0,0) and it is aligned along the Z-axis.

 

LabVIEW provides a tool to rotate the cylinder a certain angle around a given axis. You calculate the angle by using the dot product and the rotation axis using the cross product, as shown in the block diagram below.

Vector in 3D_BD.png

 

So the block diagram above is going to move a vector from the Z-axis centered at the origin to the origin and end positions given by the controls ( (0,0,0) and (1,1,1) by default).

 

animated vector.gif

 

The VI is also attached here in LabVIEW 2019 format.

 

Regards

Marc Dubois
Message 4 of 4
(2,693 Views)