# Converting XYZ Coordinates to LRA (Length Rotation Angle) Values

#### mpzmusicman

##### New member
Hello All,
I'm not sure this is the right place to post this question, but I'm hoping it is!
I've received an assignment to convert a series of XYZ coordinates to relative LRA (or YBC - depending on your industry) Length Rotation Angle values. The application of this problem is to be used for a recently procured bending machine, which takes a long pipe, and bends it according to these values. The XYZ coordinates are coming from a list of XYZ values given to me from a CAD application.

Given the following XYZ points (Px) coordinates:
P1: (38.5202, -14.0264, 0.0)
P2: (45.3142, -14.0264, 0)
P3: (45.3142, -17.5214, 0.9654)
P4: (48.6822, -17.5214, 0.9654)

I've figured out the length and angle values, as those are easy to arrive to using the Cartesian distance formula, and the law of cosines for the deltas of the related points.
However - i"m really struggling (completely clueless) on how to get the rotation value.
This value must be equal to the angle of rotation (in degrees) necessary for each line.

I hope I described the problem well enough. I've tried to attach a screenshot of the rotation angle I'm trying to get. Any help is appreciated!!!

#### Attachments

• 13.9 KB Views: 7

#### tkhunny

##### Moderator
Staff member
Hello All,
I'm not sure this is the right place to post this question, but I'm hoping it is!
I've received an assignment to convert a series of XYZ coordinates to relative LRA (or YBC - depending on your industry) Length Rotation Angle values. The application of this problem is to be used for a recently procured bending machine, which takes a long pipe, and bends it according to these values. The XYZ coordinates are coming from a list of XYZ values given to me from a CAD application.

Given the following XYZ points (Px) coordinates:
P1: (38.5202, -14.0264, 0.0)
P2: (45.3142, -14.0264, 0)
P3: (45.3142, -17.5214, 0.9654)
P4: (48.6822, -17.5214, 0.9654)

I've figured out the length and angle values, as those are easy to arrive to using the Cartesian distance formula, and the law of cosines for the deltas of the related points.
However - i"m really struggling (completely clueless) on how to get the rotation value.
This value must be equal to the angle of rotation (in degrees) necessary for each line.

I hope I described the problem well enough. I've tried to attach a screenshot of the rotation angle I'm trying to get. Any help is appreciated!!!
Turtle Graphics!!!

Seriously, you are a turtle. You are walking along the pipe. Your eyes look only straight forward. Extend the line of vision until you reach a bend. Find the angle you must pivot your shelled-self and fixed eyes AT THE BEND to get stare down the next straight path. You should get values between + / - 180º.

Example: Square. You will hit four bends. EACH pivot rotation will be 90º (or -90º - depending on which way you are going.).
Exaample: Equilateral Triangle. You will hit three bends. EACH pivot rotation will be 120º.

You are looking for EXTERNAL ANGLES. If you get back to where you started, the sum of all your angles MUST be 360º.

Of course, you'll need TWO rotation angles if you get out of the original planar surface.

#### Dr.Peterson

##### Elite Member
Hello All,
I'm not sure this is the right place to post this question, but I'm hoping it is!
I've received an assignment to convert a series of XYZ coordinates to relative LRA (or YBC - depending on your industry) Length Rotation Angle values. The application of this problem is to be used for a recently procured bending machine, which takes a long pipe, and bends it according to these values. The XYZ coordinates are coming from a list of XYZ values given to me from a CAD application.

Given the following XYZ points (Px) coordinates:
P1: (38.5202, -14.0264, 0.0)
P2: (45.3142, -14.0264, 0)
P3: (45.3142, -17.5214, 0.9654)
P4: (48.6822, -17.5214, 0.9654)

I've figured out the length and angle values, as those are easy to arrive to using the Cartesian distance formula, and the law of cosines for the deltas of the related points.
However - i"m really struggling (completely clueless) on how to get the rotation value.
This value must be equal to the angle of rotation (in degrees) necessary for each line.

I hope I described the problem well enough. I've tried to attach a screenshot of the rotation angle I'm trying to get. Any help is appreciated!!!
I'm having trouble finding a clear definition of the LRA system, but I think all you're asking for is the angle you marked, and that's pretty easy.

You show a right triangle in which the side opposite the angle is the change in z (0.9654), and the adjacent angle is the change in y (3.495). The tangent of your angle is the ratio opposite/ adjacent, so just find the inverse tangent (arctan) of 0.9654/3.495.

It looks like you should be able to find software or websites to do this sort of conversion for you.

#### mpzmusicman

##### New member
I'm having trouble finding a clear definition of the LRA system, but I think all you're asking for is the angle you marked, and that's pretty easy.

You show a right triangle in which the side opposite the angle is the change in z (0.9654), and the adjacent angle is the change in y (3.495). The tangent of your angle is the ratio opposite/ adjacent, so just find the inverse tangent (arctan) of 0.9654/3.495.

It looks like you should be able to find software or websites to do this sort of conversion for you.
I believe I explained what I needed incorrectly - apologies for being unclear.
I've made a video and new jpg to illustrate the problem better.
Here's the video: https://mwgroup.box.com/s/q8b41gplta096lh8g42hbd3xvpej7pq8

L = Length between the points (distance to feed the tube)
R = Rotation in order to bend the tube in the right direction
A = Angle of the bend

I'm after a formula for R...which I'm realizing may have more to do with planes and the rotation between those planes...?

In the .gif I'm illustrating exactly what the LRA coordinates are used to do. I'm using the .jpg to illustrate it. I used 'logic' and trial and error to fill in the R values shown, but I really need some math to do it.

@tkhunny is correct in his insight that it's got to do with pivot rotation.... i'm still not sure however mathematically how to attain this.

#### Attachments

• 11.1 KB Views: 10

#### abhiff

##### New member
I believe I explained what I needed incorrectly - apologies for being unclear.
I've made a video and new jpg to illustrate the problem better.
Here's the video: https://mwgroup.box.com/s/q8b41gplta096lh8g42hbd3xvpej7pq8

L = Length between the points (distance to feed the tube)
R = Rotation in order to bend the tube in the right direction
A = Angle of the bend

I'm after a formula for R...which I'm realizing may have more to do with planes and the rotation between those planes...?

In the .gif I'm illustrating exactly what the LRA coordinates are used to do. I'm using the .jpg to illustrate it. I used 'logic' and trial and error to fill in the R values shown, but I really need some math to do it.

@tkhunny is correct in his insight that it's got to do with pivot rotation.... i'm still not sure however mathematically how to attain this.
Hi,
I have the same query. Wished to watch the video posted by you seems it has been taken off. Can I request you to share the same once more please. I am also struggling for the same issue.

Thanks and Reagards

#### danjmangan

##### New member
I have been recently working on the same problem. I found the rotation angle using vector math.

Step 1: Define your vectors. I called mine Previous, Current, and Next and used a notation like V(n-1), V(n), & V(n+1) for shorthand. In each case, I define the direction as the endpoint of the line minus the starting point of the line (following the path of the tube). Hope that makes sense... This must be done for x, y, z components separately. So you end up with V = xî + yĵ + zk.

Step 2: Create two new vectors that are at the start and end of the Current vector. The result of the cross product of two vectors will be a third vector that is orthogonal to both vectors (according to the right hand rule). This is useful to get the Vectors of interest in the same plane (a plane normal to the Current vector). Therefore, cross the Previous vector with the Current vector (V(n-1) x V(n)) and also cross the Current vector with the Next vector (V(n) x V(n+1)). I didn't bother to actually find the projection of the Previous and Next vectors in the normal plane since the angle between the orthogonal vectors (ie: those resulting from the cross products) will be the same as the angle between the projected vectors.

Step 3: Use the definition of the dot product to find the angle between the cross product vectors. Now, having the 2 cross product vectors, we can calculate the dot product: [V(n-1) x V(n)] • [V(n) x V(n+1)]. We also have enough information to find the product of the magnitudes of the cross product vectors: ||V(n-1) x V(n)|| * ||V(n) x V(n+1)||. You can calculate the magnitude by the square root of the sum of the squares. Now, the angle between them will be the inverse cosine of the quotient of the dot product and the product of the magnitudes: θ = arccos([V(n-1) x V(n)] • [V(n) x V(n+1)] / (||V(n-1) x V(n)|| * ||V(n) x V(n+1)||))

I still haven't quite figured out how to assign a direction yet... (ie: clockwise or counter-clockwise). The calculation only gives you the angle between them, not which way it was rotated.

Last edited: