From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Angle measurments from XYZ positions

Solved!
Go to solution

I made a 3D image with particle tracking. There is (in this example) 17 tracks with strating point in 0,0,0 (XYZ). Some of them doesn't have starting part of track (tracking problem), but it doesn't matter.

3d tracking.PNG
I also have a numerical table with whole XYZ positions for every particle in next frames. Now my question: is there any way in LabView to measure initial (strating) angle for every track from first 10 frames (1-10)? On picture above this could be an angle for part of tracks marked in red colour. We only have to know initial angle, other part of tracks does not matter actually.

numerical positions.PNG
Greetings to You.

0 Kudos
Message 1 of 15
(15,294 Views)

I don't know what you mean by "angle measurements".  I assume you want to express the 3-D position in some other angle-based coordinate system, such as Cylindrical coordinates (Z axis and projection of the point onto the XY plane in polar coordinates, i.e. r, theta, Z) or Spherical Polar Coordinates (radius, angle phi with respect to the Z axis, angle theta of the projected radius on the XY plane with the X axis), or some other system.

 

If that's the case, there are easy trigonometric transformations to express one set of coordinates in terms of the other.  There may even be a VI on the Mathematics palette that will do most of the work for you.

 

Bob Schor

0 Kudos
Message 2 of 15
(15,224 Views)

@Bob_Shor , maybe You are right. I know LabView just a little bit, but I checked tools that You mentioned and maybe it will be useful to solve our problems. But to explain You my angle measurment problem I will try to show it on a picture:

angle.png

 

Every track from picture consists of many particles detected in next frames of video (one particle per one frame for every track). The red colour means first tens frames. We would like to measure marked angle for every track. For example we would like to measure angle for first 5 frames and then define mean value. But we have got a problem with this: we don't know how to measure this angle when we have got XYZ positions for every particle. Could You give us any tips or solutions how to calculate this?

0 Kudos
Message 3 of 15
(15,129 Views)

Your data consist of XYZ coordinates of particles.  Your (very pretty) plot shows, I presume, the trajectory of these particles from some unspecified location with respect to the particles, "flattening" the 3-D trajectory onto a 2-D plane, necessarily losing information in the process.

 

You want information on angles.  A point cannot determine an Angle -- you need two lines that intersect, and then you can ask "What is the angle between these two intersecting lines?".  To get a line, you need two points -- often times, one point is the origin of your coordinate system (0, 0, 0) and the other point is your particle (X, Y, Z).  But what is the other line?  It could be one of the coordinate axes (the Z axis, for example), or you could create an "auxilliary line" by projecting your "line-from-the-origin" onto, say, the XY plane and asking "what angle does this projected line make with the X axis?".  These two choices, in fact, give you two angles that are two of the three coordinates of the Spherical Polar representation of your point in space.

 

So define what two lines you want to use to compute the Angle, and it will be a simple calculation to compute this angle from X, Y, Z.

 

Bob Schor

Message 4 of 15
(15,099 Views)

Hello @Bob Schor.

 

Thanks for reply. I know this issue could be very simple for You, but try to understand me 🙂 You have got right in what You wrote. I was thinking about angle measurment between two intersecting lines, but didn't write it. As You noticed, I would like to do this using two points: origin point (0, 0, 0) and particle point (XYZ). First line would be between this points and the second line could be between origin point and a point lying on XZ plane with  X and Z coordinates from particle point and Y coordinate from origin point. Am I right ?

Example (X, Y, Z)
- origin point: (10, 10, 10)

- particle point: (20, 40, 20)

- point on XZ plane: (20,10, 20)

I hope You will understand this and give next tips. I would like to know how to use this information in LabView next. I know LabView just a little bit, but hope it's possible to measure angle in this software. I will be glad if You tell me which tools I could use and how to write it in LabView. Greetings

0 Kudos
Message 5 of 15
(15,072 Views)
Solution
Accepted by topic author prosto_w_bemben

OK, it's not too difficult.  You have a point P (I'm going to choose 20, 34.5, 20), an origin O (10, 10, 10) and you want to know the angle between a line from the Origin to P (call this line OP) and the line that is the projection of OP onto the XZ plane through the Origin.

 

Let's start by shifting the Origin to 0, 0, 0.  We do this simply by subtracting O from P, which gives us a new point, P' = 10, 24.5, 10.  The point on the XZ plane is simply P' with its Y component set to zero, 10, 0, 10.  Since our origin is (now) at (0, 0, 0), the points P' and the projection of P' also represent vectors from the origin (i.e. they are "lines").

 

Now we use the fact that the dot product of two vectors is simply the product of the length of the two vectors times the cosine of the angle between them.  I assume you know how to compute a dot product (if not, there's a convenient "Dot Product" function on the Mathematics, Linear Algebra sub-Palette) and the length of a vector (Vector Norm, same sub-Palette).  Do the division, take the arc-cosine, and you should get (approximately) pi/3 (I picked 24.5 = 10*sqrt(6) as I computed that this would give me this angle).

 

If you write this as a sub-VI with Particle XYZ and Origin XYZ (2 3-element 1-D arrays) and Theta as an output, you can put this inside a For loop that you feed the entire 2-D array of particles and the single Origin value and it will return an array of Angles.

 

I hope this is clear.

 

Bob Schor

Message 6 of 15
(15,040 Views)

Hello @Bob Schor.

 

Thanks for Your tips. They were very helpful for us. We made it as You wrote and we have got ready script which probably will be useful in our research. Now  I have got another question about particle trajectories: is there a chance to write in LabView script which will give us missing parts of some trajectories? Some of them hasn't got initial part of trajectories and it results from our software bugs (Dynamics Studio). Maybe it could be possible to do this using parabola equation and calculation of first point of trajectory lying on concrete XZ plane.

 

Hope You will understand me. Greetings to You

0 Kudos
Message 7 of 15
(14,971 Views)

If you think the trajectory of your points can be described by an equation, especially a low-order polynomial function of time, then it is relatively easy to "curve-fit" and estimate the coefficients of the polynomial.  Once you have this equation, simply plug in the time points corresponding to "missing data" and use the "best estimates" for X(t), Y(t), and Z(t).  You can find curve-fitting functions on the Mathematics Palette (under Fitting, of course).  You can probably use Linear Fit ...

 

Bob Schor

0 Kudos
Message 8 of 15
(14,949 Views)

I think that You don't understand me at all. I also thought that were different questions, but I'm not mathematician so I can't explain it. How does look our problem:

trajectory3d.png

We would like to convert our 3D trajectory (XYZ) along its direction to 2D. So we decided that we sholud create new plane. Our plane should be parallel to line between P1 and P2' points. For exmaple: P1 20, 10, 20  ; P2 40, 20, 10 and point P2' is created by projecting P2 on XZ plane with Y coordinate like a P1 point (so P2' 40, 10, 10).
What we would like to get:

trajectory2d.png

What I understand from previous posts is that we can only project our trajectory to XY, XZ or YZ plane. But we would like to get it "flat" on a plane that I described above.
Apologize if You get me wrong or I didn't understand You.

0 Kudos
Message 9 of 15
(14,888 Views)

@Bob_Shor

Hello, maybe You will help me again.

350px-Wsp_sferyczne.svg.png

I followed your instructions and get something like this: I shifted my origin point (first particle in track) to 0, 0, 0 substracting from point P and also get point P' which is the projection of P point on XZ plane with its Y coordinate set to 0. Now is my question: if we could have  angle phi (angle phi and theta are parts of Spherical Polar Coordinates system as You showed me) is it possible to shift or project our point P on XY plane using phi angle? Then we would like to this with every point from our track. Am I right ?

0 Kudos
Message 10 of 15
(14,830 Views)