Find a vertex of a tetragon where three vertices are given

192 Views Asked by At

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.

3

There are 3 best solutions below

10
On BEST ANSWER

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

7
On

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.

0
On

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!