Welcome to our community

Be a part of something great, join today!

How to calculate center coordinates of two reverse arcs in 3D space

Brad007

New member
Dec 31, 2013
5
Hi,

reversearcs.PNG

Given 3D points P1(200,60,140), P2(300,120,110), P3(3,0,-1), P4(-100,0,-1) and the radius of
arc C1MP3 is equal to radius of arc C2MP1. How do I calculate coordinates x, y, z of
points C1 and C2?

Points C1 and C2 are centers of two reverse arcs which are tangent to each other at point M which lies on ray Q1Q2.
Arc C1MP3 is tangent to ray P3P4 and arc C2MP1 is tangent to ray P1P2.



Points Q1 and Q2 emerge as a result of moving points P1 and P3 in the direction obvious from picture.
It is easy to calculate centers of arcs with different radius. But how to calculate centers of arcs
with equal radius. How to find the position of points Q1 and Q2?
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
Hi,

View attachment 1815

Given 3D points P1(200,60,140), P2(300,120,110), P3(3,0,-1), P4(-100,0,-1) and the radius of
arc C1MP3 is equal to radius of arc C2MP1. How do I calculate coordinates x, y, z of
points C1 and C2?

Points C1 and C2 are centers of two reverse arcs which are tangent to each other at point M which lies on ray Q1Q2.
Arc C1MP3 is tangent to ray P3P4 and arc C2MP1 is tangent to ray P1P2.



Points Q1 and Q2 emerge as a result of moving points P1 and P3 in the direction obvious from picture.
It is easy to calculate centers of arcs with different radius. But how to calculate centers of arcs
with equal radius. How to find the position of points Q1 and Q2?
Welcome to MHB, Brad! :)

I could solve the problem by setting up the equations using only vector dot products.
Then let an algorithmic solver do the work.

My solution is:
\begin{array}{lccrrrc}
Q1&=&(&120.2, &12.1, &163.9&) \\
Q2&=&(&77.6, &0, &-1.0&) \\
C1&=&(&3.0, &7.0, &95.0&) \\
C2&=&(&176.1, &53.2, &47.0&) \\
M&=&(&96.2, &5.3, &71.1&) \\
R&=&&96.3
\end{array}

Summarized, the steps in my approach are:
1. Introduce variables for the radius R, how far Q1 lies beyond P1, and how far Q2 lies beyond P3.
2. Calculate normalized vectors for P1-Q1 and for Q2-Q1.
3. Their average vector points to C2. Use that to calculate the point C2 where C2-P1 is perpendicular to P2-P1.
4. Calculate the point M1 where M should be.
5. Repeat the calculation with P3 and P4 to find C1 and M2.
6. Let an algorithmic solver do the work to find the minimum for:
$$||M2-M1||^2 + (||P1-C2|| - R)^2 + (||P3-C1|| - R)^2$$


Btw, these type of problems are often solved with so called Bezier curves.
Bezier math is more straight forward and may give better solutions depending on the requirements of your setup. You will get a smooth path with minimal course changes and curvature, which could well be better than 2 reverse arcs with equal radius.
 

Brad007

New member
Dec 31, 2013
5
Welcome to MHB, Brad! :)

I could solve the problem by setting up the equations using only vector dot products.
Then let an algorithmic solver do the work.

My solution is:
\begin{array}{lccrrrc}
Q1&=&(&120.2, &12.1, &163.9&) \\
Q2&=&(&77.6, &0, &-1.0&) \\
C1&=&(&3.0, &7.0, &95.0&) \\
C2&=&(&176.1, &53.2, &47.0&) \\
M&=&(&96.2, &5.3, &71.1&) \\
R&=&&96.3
\end{array}

Summarized, the steps in my approach are:
1. Introduce variables for the radius R, how far Q1 lies beyond P1, and how far Q2 lies beyond P3.
2. Calculate normalized vectors for P1-Q1 and for Q2-Q1.
3. Their average vector points to C2. Use that to calculate the point C2 where C2-P1 is perpendicular to P2-P1.
4. Calculate the point M1 where M should be.
5. Repeat the calculation with P3 and P4 to find C1 and M2.
6. Let an algorithmic solver do the work to find the minimum for:
$$||M2-M1||^2 + (||P1-C2|| - R)^2 + (||P3-C1|| - R)^2$$


Btw, these type of problems are often solved with so called Bezier curves.
Bezier math is more straight forward and may give better solutions depending on the requirements of your setup. You will get a smooth path with minimal course changes and curvature, which could well be better than 2 reverse arcs with equal radius.
Can you list here all the initial equations please?
 

Brad007

New member
Dec 31, 2013
5
I would rather see more detailed procedure how the result was computed then the actual result at least. I want to implement this as piece of code in 3dsmax script.

I need to have the rays connected with two reverse arcs becuse then I will divide the arcs into several pieces of the same length. I have tried to do the same with Bezier splines, but it is not possible (only with brute force algorithm).
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
I would rather see more detailed procedure how the result was computed then the actual result at least. I want to implement this as piece of code in 3dsmax script.

I need to have the rays connected with two reverse arcs becuse then I will divide the arcs into several pieces of the same length. I have tried to do the same with Bezier splines, but it is not possible (only with brute force algorithm).
I consider the procedure I outlined fairly detailed.
Most of the steps won't become clearer if I write down a formula for it.
For which part of the procedure would you like to see more details?
Or are your problems more with how vectors and dot products are defined and used?
 

Brad007

New member
Dec 31, 2013
5
At first step I did the following $$Q1=P1-s*u ; Q2=P3-t*v$$ where $$u=\frac{P2-P1}{||P2-P1||} ; v=\frac{P4-P3}{||P4-P3||}$$ and s,t are parameters for how far the points lies.
Then I can not figure out how the parameters s,t behave.

Is it right way how to define the first step?
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
At first step I did the following $$Q1=P1-s*u ; Q2=P3-t*v$$ where $$u=\frac{P2-P1}{||P2-P1||} ; v=\frac{P4-P3}{||P4-P3||}$$ and s,t are parameters for how far the points lies.
Then I can not figure out how the parameters s,t behave.

Is it right way how to define the first step?
Yes.
This is the first stage of defining variables that determine the equations.
Later we will figure out what their values should be.
 

Brad007

New member
Dec 31, 2013
5
ok, then I did the following
$$k=\frac{Q2-Q1}{||Q2-Q1||};l=\frac{Q1-Q2}{||Q1-Q2||}$$
$$c2=\frac{u+k}{2};c1=\frac{v+l}{2}$$
$$e=P1.u;r=\frac{e-Q1.u}{c2.u};C2=Q1+r*c2$$
$$e=P3.v;r=\frac{e-Q2.v}{c1.v};C1=Q2+r*c1$$
$$e=P1.c2;r=\frac{e-Q1.c2}{c2.k};M1=Q1+r*k$$
$$e=P3.c1;r=\frac{e-Q2.c1}{c1.l};M2=Q2+r*l$$

then I used Mathematica to find minimum for
$$||M2-M1||^2 + (||P1-C2|| - R)^2 + (||P3-C1|| - R)^2$$

with this result {7.46-25, {R -> 96.26, s -> 96.12, t -> 74.64} which is right result.

How do I solve for parameters R,s,t without using Mathematica solver? Can you please tell what are some other methods how to calculate parameters R,s,t. As I have written here I want to implement this as max script.
 
Last edited:

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
ok, then I did the following
$$k=\frac{Q2-Q1}{||Q2-Q1||};l=\frac{Q1-Q2}{||Q1-Q2||}$$
$$c2=\frac{u+k}{2};c1=\frac{v+l}{2}$$
$$e=P1.u;r=\frac{e-Q1.u}{c2.u};C2=Q1+r*c2$$
$$e=P3.v;r=\frac{e-Q2.v}{c1.v};C1=Q2+r*c1$$
$$e=P1.c2;r=\frac{e-Q1.c2}{c2.k};M1=Q1+r*k$$
$$e=P3.c1;r=\frac{e-Q2.c1}{c1.l};M2=Q2+r*l$$

then I used Mathematica to find minimum for
$$||M2-M1||^2 + (||P1-C2|| - R)^2 + (||P3-C1|| - R)^2$$

with this result {7.46-25, {R -> 96.26, s -> 96.12, t -> 74.64} which is right result.
Looks good!


How do I solve for parameters R,s,t without using Mathematica solver? Can you please tell what are some other methods how to calculate parameters R,s,t. As I have written here I want to implement this as max script.
I have no idea, since I am not familiar with max script.
Most mathematical packages have a minimization function, which is what you need.
I do not see a way to do it without a minimizer.