How to find the shortest distance between two skew lines using vector math.

How to find the shortest distance between two skew lines using vector math.

Yehoshua18
Enthusiast Enthusiast
561 Views
1 Reply
Message 1 of 2

How to find the shortest distance between two skew lines using vector math.

Yehoshua18
Enthusiast
Enthusiast

Hey, I've been trying to figure out how to find the shortest distance between two skew lines. I can do it in C# without using AutoCAD vectors, but it would be much more simple if I could use them. Any idea how to make it happen? Thanks!

 

 

joshuaW5HNW_0-1679473479240.png

https://www.toppr.com/guides/maths/three-dimensional-geometry/distance-between-skew-lines/

0 Likes
Accepted solutions (1)
562 Views
1 Reply
Reply (1)
Message 2 of 2

Yehoshua18
Enthusiast
Enthusiast
Accepted solution

I figured it out. Just incase anyone ever needs this, here is the solution.

 

 

 

 

public static void Interference(Line L1, Line L2)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;

            Vector3d U1 = L1.StartPoint.GetVectorTo(L1.EndPoint);
            Vector3d U2 = L2.StartPoint.GetVectorTo(L2.EndPoint);
 
            Vector3d N = U1.CrossProduct(U2);

            double nmag = N.Length;

            Vector3d P1P2 = L1.StartPoint.GetVectorTo(L2.StartPoint);

            Double Distance = Math.Abs(P1P2.DotProduct(N)/nmag);

            doc.Editor.WriteMessage(string.Format("\n Minimum Distance between lines {0} =",Distance.ToString()));
        }

 

 

 

 

0 Likes