LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shortest distance between two line segments

Hi.
 
I am looking for the code of the "Shortest distance between two line segments". I would appreciate if anyone has and willing to share.
I can find some in the net but its in VB and i am not familiar with it.
THanks a lot.
 
regards,
0 Kudos
Message 1 of 19
(4,224 Views)
Hi jtc,
which is the shortest distance for you? Can you explain please, or give us the link to the VB code you mean.

Mike
0 Kudos
Message 2 of 19
(4,207 Views)

Hello Mike,

Thanks for your reply.

I attached a sketch of what i am trying to do. I have these two stick moving in circular path. No. 1 stick has its fixed position at P1(0,0) which has end at P2. P2 coordinates can be calculated since i know its Radius (R1). Likewise, No. 2 stick has its fixed position at P3 (40,25) which has end coordinates at P4. P4 coordinates can also be calculated since i know its Radius (R2). Both of the stick can move either clockwise or counterclockwise independently from each other. Both of the two stick can also extend or shorten their radius.

I always have to monitor the distance between the two stick so that i can prevent them from colliding to each other. I am stll researching on the right code/formula on how to calculate the distance between the two stick.

I hope i explained it well. Thanks for your help.

0 Kudos
Message 3 of 19
(4,204 Views)
Hi jtc,
what about simply using the Pythagoras? If you have x and y of both points it should be no problem. Smiley Happy
Mike
0 Kudos
Message 4 of 19
(4,189 Views)
Can you go the other way round.Define the regions for stick one and stick two and define the danger zones.Keep monitoring on the defined regions and once one stick is in that region make alteration to the other stick like delaying the movement or something in the similar lines.
Message 5 of 19
(4,176 Views)
Please check the attached diagram.I have specified two region of intrest(ROI A and ROI B).We need to monitor only this region which can be called as the Danger zones.Stick 2 in roi A and stick 1 in Roi b is the only cause of concern.

case 1 no sticks in any region      -no problem

case 2 stick1 in roib\stick2 in roia                  - immediately check the position of  each stick.Stop it if possible.

case 3 stick1 in roiA\Stick2 in roib            -No probs


Correct me if i am wrong



Dont forget to rate a good answer


Message 6 of 19
(4,173 Views)
Can the sticks be slowed down?

What is the speed at which each one os moving?



Message 7 of 19
(4,170 Views)
There are a couple of things that are not clear:
  • What determines the rotation speed and lenght of each stick at any given time?
  • What is the program allowed to do to prevent collision (change speed/direction, change radius, stop everything)
  • Since you want to prevent collision, you need a predictive algorithm. Once they overlap, the collision has already happened. Too late!
  • What information does your algorithm get (e.g. r1, r2, theta1, theta2, delta-thetat1, delta-theta2, etc.), i.e. does the program only get static information and need  to construct the trajectory from sequential history data or does it get dynamic information about speed and direction?

The trivial answer would be to just keep r1+r2 < distance(P1,P2). This will prevent all "potential" collisions. 🙂

Message 8 of 19
(4,149 Views)

Hi Muks,

------------------------------------------------------------------------

Can you go the other way round.Define the regions for stick one and stick two and define the danger zones.Keep monitoring on the defined regions and once one stick is in that region make alteration to the other stick like delaying the movement or something in the similar lines.

-------------------------------------------------------------------------
Thanks for your reply. I will study your idea and suggestion. About the speed each of the stick has speed range from 1 to 5. If the stick is on the danger zone i plan to cut the higher speed (3,4,5) so that it will stop properly, say 3 meters, away from the other stick.

Thanks  a lot.

0 Kudos
Message 9 of 19
(4,100 Views)
sorry Mike
 
But plain phythagorean theorem will not solve it easily. Anyway, thanks a lot.
0 Kudos
Message 10 of 19
(4,099 Views)