LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Random unit vector (x0, y0, z0) generating

Solved!
Go to solution

Hello,

 

Does exist function that generates random unit vector 3D (x0, y0, z0)

 

Thanks in advance

 

Pavel

0 Kudos
Message 1 of 26
(5,223 Views)

Random 3D Unit Vector.png

 

Generate random 3D vector and use the Vector Norm function.

 

Ben64

Message 2 of 26
(5,203 Views)

It is called a FOR loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 26
(5,201 Views)

Hi Pavel_47,

 

How about that?

Pavel_47.PNG

Regards

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 4 of 26
(5,181 Views)

Hi Sabri,

 

A unit vector has the property that the sum of the squares is equal to 1. Yours will have the sum anywhere from 0 to 300.

0 Kudos
Message 5 of 26
(5,168 Views)

Didn' new. Thx for the info.

 

 

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 6 of 26
(5,143 Views)

Knew 🙂

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 7 of 26
(5,141 Views)

Just realized that using random number (0-1) will only generate a unit vector in the x+,y+,z+ region of the 3D x,y,z space. Here is a modified version to correct that. This is a quick fix there is probably a more elegant solution (maybe using complex number).

 

Random 3D Unit Vector-2.png

 

Ben64

0 Kudos
Message 8 of 26
(5,113 Views)
Solution
Accepted by topic author Pavel_47

Well ... I've searched a little bit more and found approach base on polar coordinates: only 2 random variables are generated and they are completely independent.

Here it is.

Regards

Pavel

 

random_3D_vector_FP.JPG

 

random_3D_vector_BD.JPG

 

0 Kudos
Message 9 of 26
(5,087 Views)

Hi Pavel,

 

I think parameterizing in spherical coordinates is a good way to go. You do still have 3 variables to describe a 3D point in space of course

Spoiler
you've just set |r|=1  Smiley Happy

 

0 Kudos
Message 10 of 26
(5,018 Views)