5
$\begingroup$

Suppose that $V,W,U$ are three 3D points and $L,K$ are given positive values. Let $dist(A,B)$ represents euclidean distance between $A,B$. Morover, assume that $M$ is a plane that passes through $V,W,U$. What I need is a point $P$ where:

$$dist(V,P)=L \\ dist(U,P)=K \\ P\in M $$

Obviously, we must find the equations of 2 circles, $C_1(V,L), C_2(U,K)$ where $C_1\subset M, C_2\subset M$ and then find their intersections. These possible intersections would be our points. Of course $L,K$ are given such a way that the intersections exist.

$\endgroup$

3 Answers 3

4
$\begingroup$

Since $P$ lies on the plane of $V, W, U$, then it can expressed using barycentric coordinates as follows

$ P = V + c_1 (W - V) + c_2 (U - V) $

Define the vectors $X_1 = W - V$ and $X_2 = U - V $

then

$ P = V + c_1 X_1 + c_2 X_2 $

Now you want

$ \| P V \| = L $ and $ \| P U \| = K $

Therefore, you want

$ \| c_1 X_1 + c_2 X_2 \| = L $

$ \| c_1 X_1 + (c_2 - 1) X_2 \| = K $

These two equations lead to the following quadratic equations

$ c_1^2 \| X_1\|^2 + c_2^2 \| X_2 \|^2 + 2 c_1 c_2 X_1 \cdot X_2 = L^2 \tag{1} $

and

$ c_1^2 \| X_1 \|^2 + (c_2 - 1)^2 \| X_2 \|^2 + 2 c_1 (c_2 - 1) X_1 \cdot X_2 = K^2 \tag{2}$

Subtracting the two equations gives

$ (2 c_2 - 1 ) \| X_2 \|^2 + 2 c_1 X_1 \cdot X_2 = L^2 - K^2 \tag{3} $

Equation $(3)$ is a linear equation in $c_1$ and $c_2$ and can be directly solved for $c_1$ in terms of $c_2$ or vice versa.

Back substituting either variable in $(1)$, two possible values for the other variable are found.

Having determined the possible pairs of $(c_1, c_2)$, two possible solutions for point $P$ are thus determined.

Edit: The code that I wrote to find the solutions for $P$ follows. It is written in Excel VBA (Visual Basic for Applications).

Public Sub mse_tetragon()

Dim u(3), v(3), w(3) As Double
Dim x1(3), x2(3) As Double
Dim p0(3) As Double
Dim v0(2), v1(2) As Double
Dim a0, a1 As Double
Dim p1(3), p2(3) As Double


Dim l, k As Double

v(1) = 1

u(2) = 1

l = 1
k = 1

For i = 1 To 3
x1(i) = w(i) - v(i)
x2(i) = u(i) - v(i)
Next i

'  Let d1 = X1.X1, d2 = X2.X2 , d3 = X1.X2, then equation (3) is

' (2 c2 - 1) d2 + 2 c1 d3 = L^2 - K^2

' re-arranging,

' 2 d3 c1 + 2 d2 c2 = L^2 - K^2 + d2

'  therefore,

' c2 = 1/(2 d2) [ L^2 - K^2 + d2 - 2 d3 c1 ]

'    = A0 + A1 c1

d1 = dot(x1, x1)
d2 = dot(x2, x2)
d3 = dot(x1, x2)

a0 = (l ^ 2 - k ^ 2 + d2) / (2 * d2)
a1 = -2 * d3 / (2 * d2)

' substitute for c2 into Eqn. (1)

' c1^2 d1 + c2^2 d2 + 2 c1 c2 d3 = L^2

' So,

' c1^2 d1 + (a0 + a1 c1)^2 d2 + 2 c1 (a0 + a1 c1) d3 = L^2

' collect the coefficients of c1^2, c1, 1

s2 = d1 + a1 ^ 2 * d2 + 2 * a1 * d3
s1 = 2 * a0 * a1 * d2 + 2 * d3 * a0
s0 = a0 ^ 2 * d2 - l ^ 2

disc = s1 ^ 2 - 4 * s2 * s0

If Abs(disc) < 0.000001 Then disc = 0

If disc < 0 Then
MsgBox ("No solutions to quadratic equation")
Exit Sub
End If

c11 = (-s1 - Sqr(disc)) / (2 * s2)
c12 = (-s1 + Sqr(disc)) / (2 * s2)

c21 = a0 + a1 * c11
c22 = a0 + a1 * c12


For i = 1 To 3
p1(i) = v(i) + c11 * x1(i) + c21 * x2(i)
p2(i) = v(i) + c12 * x1(i) + c22 * x2(i)

ActiveSheet.Cells(i, 1) = p1(i)
ActiveSheet.Cells(i, 3) = p2(i)

Next i



End Sub

The output of this program is shown below

enter image description here

$\endgroup$
10
  • 1
    $\begingroup$ I set $V = [1, 0, 0], W = [0, 0, 0], U = [0, 1, 0], L = 1, K = 1$ and results are as $P1 =[1.1464191348868271, -1.292838269773654, 0.0]$ and $P2= [-0.20524266429859184, 1.4104853285971835, 0.0]$ which is wrong!!! Obviously, we expect $P1$ or $P2$ equals $[1,1,0]$. Please revise your response! $\endgroup$ Mar 3 at 14:36
  • $\begingroup$ @HamidShafieAsl I've written code to solve the system of equations (1) and (3), and got two solutions for $P$. The two solutions are $(0,0,0)$ and $(1,1,0)$. $\endgroup$ Mar 3 at 15:07
  • $\begingroup$ I tested yours with a python code and I get that result. Maybe my code was wrong! Could you please share your code? $\endgroup$ Mar 3 at 15:23
  • 2
    $\begingroup$ Sure, but not at home right now. When I get back home, I'll post the code. $\endgroup$ Mar 3 at 15:57
  • 2
    $\begingroup$ @HamidShafieAsl I've just edited my solution to include my code. Hope you find it easy to follow. If you still have questions on it, I'll be happy to answer them. $\endgroup$ Mar 3 at 19:29
4
$\begingroup$

Hint.

Calling $\hat{k}=\frac{(V-W)\times(W-U)}{\|(V-W)\times(W-U)\|}$ we can determine $\hat p,\hat q$ such that

$$ \cases{ \hat p\cdot \hat k = 0\\ \|\hat p\| = 1\\ \hat q = \hat k\times \hat p } $$

after that, calling

$$ \cases{ C_1=V+\left(\hat p\cos t_1+\hat q \sin t_1\right)L\\ C_2=U+\left(\hat p\cos t_2+\hat q \sin t_2\right)K\\ } $$

we will look for solutions to

$$ V+\left(\hat p\cos t_1+\hat q \sin t_1\right)L = U+\left(\hat p\cos t_2+\hat q \sin t_2\right)K $$

so multiplying successively by $\hat p,\hat q$ we have

$$ \cases{ V\cdot\hat p+\cos t_1 L = U\cdot \hat p + \cos t_2 K\\ V\cdot\hat q+\sin t_1 L = U\cdot \hat q + \sin t_2 K} $$

Two equations to solve in $t_1, t_2$

NOTE

To solve the system

$$ \cases{ c_1+L\cos t_1 = c_2+K\cos t_2\\ c_3+L\sin t_1 = c_4+K\sin t_2 } $$

by using $\sin^2t_1+\cos^2t_1 = 1$ we obtain an expression as

$$ b_1 \sin t_2 + b_2\cos t_2 + b_0=0 $$

or equivalently

$$ \frac{b_1}{\sqrt{b_1^2+b_2^2}}\sin t_2+\frac{b_2}{\sqrt{b_1^2+b_2^2}}\cos t_2+\frac{b_0}{\sqrt{b_1^2+b_2^2}}=0 $$

and now we follow making

$$ \cases{ \sin t_0 = \frac{b_1}{\sqrt{b_1^2+b_2^2}}\\ \cos t_0 = \frac{b_2}{\sqrt{b_1^2+b_2^2}}\\ c_0 = \frac{b_0}{\sqrt{b_1^2+b_2^2}} } $$

giving thus

$$ \sin t_2\sin t_0 + \cos t_2\cos t_0 + c_0 = 0 $$

or $\cos(t_2-t_0)+c_0 = 0$ and finally

$$ t_2=\arccos(-c_0)+t_0 $$

Here

$$ \cases{ c_1 = V\cdot\hat p\\ c_2 = U\cdot\hat p\\ c_3 = V\cdot\hat q\\ c_4 = U\cdot\hat q\\ b_1 = 2(c_4-c_3)K\\ b_2 = 2(c_2-c_1)K\\ b_0 = (c_1-c_2)^2+(c_3-c_4)^2+K^2-L^2\\ } $$

so you have a closed answer expression.

$\endgroup$
7
  • $\begingroup$ The determination of $\hat p$ from $\hat k$ can be done by choosing freely the lacking unknowns, respecting the condition $\|\hat p\|=1$ and the last condition involves only two unknowns: $t_1, t_2$. $\endgroup$
    – Cesareo
    Mar 3 at 11:58
  • 1
    $\begingroup$ solving these equations, we have $\sin t_1 = \frac{(U-V)\cdot \hat{q} + K\sin (\arccos(\frac{(V-U)\cdot \hat{p} + L\cos(t_1)}{K}))}{L}$. Do you have any idea to get through of this? I mean, how to find $t1$? Numerical solutions? How? $\endgroup$ Mar 3 at 14:42
  • $\begingroup$ Use the property $\cos ^2t_1+\sin^2t_1 = 1$ $\endgroup$
    – Cesareo
    Mar 3 at 15:39
  • $\begingroup$ I know what is that equation. How to solve it for $t_1$ where it is not simple to separate $t_1$. I know that $\sin(\arccos(M)) = \sqrt{1-M^2}$ $\endgroup$ Mar 3 at 15:43
  • $\begingroup$ Please. See note included in the answer. $\endgroup$
    – Cesareo
    Mar 3 at 16:00
3
$\begingroup$

Dear of course this is my code about your response:

import math

def myVector(M,N):
    return [N[i] - M[i] for i in range(3)]
def myNorm(M):
    return math.sqrt(sum(M[i]**2 for i in range(3)))
def myDotProduct(M,N):
    return sum(M[i]*N[i] for i in range(3))
    
def findVertex2(v, w, u, l, k):
    X1 = myVector(v, w) 
    X2 = myVector(v, u)
    d1 = myDotProduct(X1, X1)
    d2 = myDotProduct(X2, X2)
    d3 = myDotProduct(X1, X2)
    a0 = (l**2 - k**2 +d2)/(2 * d2)
    a1 = -2 * d3/ (2 * d2)
    s2 = d1 + (a1 ** 2 )* d2 + 2 * a1 * d3 
    s1 = 2 * a0 * a1 * d2 + 2 * d3 * a0
    s0 = (a0 ** 2)* d2 - l ** 2
    disc = s1 ** 2 - 4 * s2 * s0
    if disc < 0:
        return None
    else:
        c11 = (-s1 - math.sqrt(disc)) / (2 * s2)
        c12 = (-s1 + math.sqrt(disc)) / (2 * s2)
        c21 = a0 + a1 * c11
        c22 = a0 + a1 * c12
        P1 = [v[i] + c11*X1[i] + c21*X2[i] for i in range(3)]
        P2 = [v[i] + c12*X1[i] + c22*X2[i] for i in range(3)]
        return P1, P2


v = [1,0,0]
w = [0,0,0]
u = [0,1,0]

print(findVertex2(v, w, u, math.sqrt(2), math.sqrt(2)))

#result ([1.0, 1.0, 0.0], [0.0, 0.0, 0.0])

I edited it and it worked!

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .