Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Intersection of 2 lines
Message
De
26/02/2001 00:46:56
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00479322
Message ID:
00479389
Vues:
40
>Hi Al, thanks for the help. Quick question (see below in bold).
>
>>>Does anyone have a function that can determine the intersection of 2 lines? I know the start and end points of each line in coordinates (they are 2 element arrays of doubles).
>>>
>>>tia
>>
>>I'll give it a shot. I won't use subscripts, so case is important below:
>>Suppose line 1 runs from X1,Y1 to X2,Y2 and can be described by the formula
>>
>>Y = MX + B, then
>
><b>What is MX? M * one of the X cords?</b>

Yes, in this case "M" is the slope of the line - the ratio of the increase in the value of Y with each unit increase in the value of X.

>
>>
>>M = (Y2 - Y1) / (X2 - X1), and
>>B = Y1 - MX1
>
><b> MX1 is M * X1, correct?</b>
>
>>
>>Similarly, if line 2 runs from x1,y1 to x2,y2 and can be described by the formula
>>
>>y = mx + b, then
>>
>>m = (y2 - y1) / (x2 - x1), and
>>b = y1 - mx1
>>
>>At the point of intersection, y = Y, so
>>
>>MX + B = mx + b
>>
>>Also, at the point of intersection x = X, so
>>
>>MX + B = mX + b
>>
>>MX - mX = b - B
>>
>>X(M - m) = b - B
>>
>>X = (b - B) / (M - m)
>>
>>Once you have the value of X, you can get the value of Y from the first equation.
Good luck!
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform