Specifying a line equation with respect to 2 another perpendicular line equations.

67 Views Asked by At

Suppose that we have 2 line equations, call $L$, $D$, where $$L: \frac{x-a}{u}= \frac{y-b}{v}= \frac{z-c}{w}$$ $$D: \frac{x-a}{m}= \frac{y-b}{n}= \frac{z-c}{p}$$ and let $L\perp D$. Moreover, suppose that $\alpha,\beta$ are given, where $\alpha + \beta \geq \frac{\pi}{2}$. I need to find a line equation, call $K$, in the 3D space in such a way that the angle between $K$ and $L$ becomes $\alpha$ and the angle between $K$ and $D$ becomes $\beta$. I know that to achieve such a line or lines we must find the intersection between 2 cones, where the central axis of the first cone is line $L$, with half-angle $\alpha$ and the central axis of the second is the line $D$, with half-angle $\beta$. However, I don't know how to get through this process.

2

There are 2 best solutions below

0
On BEST ANSWER

Formulation of the problem is easy. You have

$L(t) = (a,b,c) + t (u,v,w) $

$D(t) = (a,b,c) + s (m,n,p) $

where we can assume without loss of generality that $(u,v,w)$ and $(m,n,p)$ are unit vectors. We're looking for a unit vector $(v_1,v_2,v_3)$ such that it makes an angle $\alpha $ with $(u,v,w)$ and an angle $ \beta $ with $(m,n,p)$

Therefore, the triple $(v_1,v_2,v_3)$ satisfies

$ v_1 u + v_2 v + v_3 w = \cos \alpha $

$ v_1 m + v_2 n + v_3 p = \cos \beta $

$ v_1^2 + v_2^2 + v_3^2 = 1 $

It is easy to solve this system of equations because the first two equations are linear in $v_1, v_2, v_3 $, their solution takes the form

$ (v_1, v_2 , v_3) = X_0 + \lambda X_1 $

where $X_1 = (u,v,w) \times (m,n,p) $

($\times$ stands for cross product).

To find $X_0$, set $ v_3 = 0$ and solve remaining $2 \times 2$ system for $v_1$ and $v_2$. You'll get

$ v_{10} = \dfrac{ n \cos \alpha - v \cos \beta}{ u n - m v} $

$ v_{20} = \dfrac{ u \cos \beta - m \cos \alpha }{ un - mv } $

Then $X_0 = ( v_{10}, v_{20} , 0 ) $

Finally, substitute $(v_1, v_2, v_3) = X_0 + \lambda X_1 $ into

$ v_1^2 + v_2^2 + v_3^2 = 1$

This will give

$ \lambda^2 X_1 \cdot X_1 + 2 \lambda X_0 \cdot X_1 + X_0 \cdot X_0 -1 = 0 $

where $\cdot $ is the dot product.

This is a quadratic equation in $\lambda$ whose solutions can be readily found. Once these two solutions are found, the two possible vectors $(v_1, v_2, v_3) = X_0 + \lambda X_1 $ are now completely specified.

The following code is an implementation of the above procedure

Public Sub mse_third_line()
Dim u1(3), u2(3), v1(3), v2(3) As Double
Dim x0(3), x1(3) As Double

u1(1) = 1
u1(2) = -3
u1(3) = 2

u2(1) = 5
u2(2) = 7
u2(3) = 8

'normalize u1 and u2
Call normalize1(u1)
Call normalize1(u2)

' note that u1 . u2 = 0

alpha = 40 * p / 180

beta = 80 * p / 180

' now we want to solve the system

' v(1) u1(1) + v(2) u1(2) + v(3) u1(3) = cos alpha
' v(1) u2(1) + v(2) u2(2) + v(3) u2(3) = cos beta
' v(1)^2 + v(2)^2 + v(3)^2 = 1

Call cross(u1, u2, x1)

x = (u2(2) * Cos(alpha) - u1(2) * Cos(beta)) / (u1(1) * u2(2) - u2(1) * u1(2))
y = (u1(1) * Cos(beta) - u2(1) * Cos(alpha)) / (u1(1) * u2(2) - u2(1) * u1(2))

x0(1) = x
x0(2) = y
x0(3) = 0

' now solve for the two possible values of lambda

a2 = dot(x1, x1)
a1 = 2 * dot(x0, x1)
a0 = dot(x0, x0) - 1

lambda1 = 1 / (2 * a2) * (-a1 - Sqr(a1 ^ 2 - 4 * a2 * a0))
lambda2 = 1 / (2 * a2) * (-a1 + Sqr(a1 ^ 2 - 4 * a2 * a0))

' compute the two possible direction vectors

For i = 1 To 3
v1(i) = x0(i) + lambda1 * x1(i)
v2(i) = x0(i) + lambda2 * x1(i)
Next i

' verify the angles of v1 and v2 with u1 and u2

th1_1 = find_angle(v1, u1)
th1_2 = find_angle(v1, u2)

th2_1 = find_angle(v2, u1)
th2_2 = find_angle(v2, u2)

For i = 1 To 3
ActiveSheet.Cells(i, 1) = v1(i)
ActiveSheet.Cells(i, 3) = v2(i)
Next i

ActiveSheet.Cells(5, 6) = "alpha"
ActiveSheet.Cells(6, 6) = "beta"

ActiveSheet.Cells(5, 5) = alpha
ActiveSheet.Cells(6, 5) = beta

ActiveSheet.Cells(5, 1) = th1_1
ActiveSheet.Cells(6, 1) = th1_2

ActiveSheet.Cells(5, 3) = th2_1
ActiveSheet.Cells(6, 3) = th2_2

End Sub

The output of the program is shown below

enter image description here

0
On

I tried to convert Hosam Hajeer's response into a python code. That is a function gets lines and angles as inputs and returns possible line equations:

import math
def myUnitize(V):
    s = math.sqrt(sum(v**2 for v in V))
    W = [W/s for w in W]
    return W

def newLine(T, B, P, beta, alpha):
    a,b,c = P
    u,v,w = myUnitize(T)
    m,n,p = myUnitize(B)
    alpha = math.radians(alpha)
    beta = math.radians(beta)
    
    X1 = [v*p-w*n, -u*p+w*m, u*n-v*m]
    v10 = (n*math.cos(beta)-v*math.cos(alpha))/(u*n-m*v)
    v20 = (u*math.cos(alpha)-m*math.cos(beta))/(u*n-m*v)
    X0 = (v10, v20, 0)
    
    A = sum(H*H for H in X1)
    B = 2*sum(H*G for H, G in zip(X1, X0))
    C = sum(H*H for H in X0) - 1 
    Delta = B**2 - 4*A*C
    if Delta < 0:
        return "the only intersection is the point ({},{},{}) and there is no  such a line.".format(a,b,c) 
    r1 = (-B-math.sqrt(Delta))/(2*A)
    r2 = (-B+math.sqrt(Delta))/(2*A)
    
    v1, vv1 = X0[0]+r1*X1[0], X0[0]+r2*X1[0]
    v2, vv2 = X0[1]+r1*X1[1], X0[1]+r2*X1[1]
    v3, vv3 = X0[2]+r1*X1[2], X0[2]+r2*X1[2]

    line_equation1 = {
        "x": (a, v1), 
        "y": (b, v2), 
        "z": (c, v3)
    }

    line_equation2 = {
        "x": (a, vv1), 
        "y": (b, vv2), 
        "z": (c, vv3)
    }
    return line_equation1, line_equation2

#example
P = [0,0,0]
T = [1,0,1]
B = [0,1,1]
beta = 60
alpha = 45
print(newLine(T, B, P, beta, alpha))

#result
#({'z': (0, 0.17263322206127574),
   'y': (0, 0.82736677793872448),
   'x': (0, 0.53447355912527195)}, 
  {'z': (0, 0.96543796539642279),
   'y': (0, 0.03456203460357743),
   'x': (0, -0.25833118420987511)})