Shortest distance between two line segments in 3D with symbolic equations?

10 Ansichten (letzte 30 Tage)
AC_R
AC_R am 9 Feb. 2015
Kommentiert: AC_R am 11 Feb. 2015
Hi! I am new to MatLab and therefor not well known with the program and the commands and such.
I see several posts here that answer my problem, if my problem would have had fixed points. But how can I calculate the shortest distance between two line segments when my points are not fixed? They are variable. I have lines that can move independently and are tasked with making sure they dont come closer than a given distance of each other.
For each of my X and Y and Z i have LONG equations with up to 8 variables (sin(k1)*cos(k2)*d3 + cos(k4)*cos(k3)*sin(k1) - .... and so on for about 3 full lines in notepad), and would like a symbolic equation as output if this is possible.
To be more specific, I would like to be able to input my equations of X, Y, Z instead of fixed coordinates.
Can I do this somehow? Would appreciate any help I can get.

Antworten (1)

John D'Errico
John D'Errico am 9 Feb. 2015
Not really. Certainly not trivially. The problem is, these are line segments, not lines.
It is not too difficult to compute the shortest distance between a pair of lines, of infinite extent. But the minimal distance between line segments has a problem.
The points of closest approach may lie at an endpoint of one or both of the segments, but that will often not correspond to the points of closest approach of the extended lines. So any expression for the minimal distance would essentially involve an if statement, or something equivalent to one.
  1 Kommentar
AC_R
AC_R am 11 Feb. 2015
Hi! Thanks for responding.
Could it work if one conciders the lines to be infinite? It may be sufficient to do it this way. I wrote a code in matlab yesterday, but it gives me an output of 90000 (ninety thousand) characters, which seems excessive. I have to think there is a way to get a shorter resulting equation.
In my MatLab code I basically just followed the formula for shortest distance between lines, with my equations for X,Y,Z as input. Nothing else.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Just for fun finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by