Click here to Skip to main content
15,881,380 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
cp987629-Nov-08 14:03
cp987629-Nov-08 14:03 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
darrellp29-Nov-08 14:48
darrellp29-Nov-08 14:48 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
cp987629-Nov-08 15:20
cp987629-Nov-08 15:20 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
darrellp29-Nov-08 19:58
darrellp29-Nov-08 19:58 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
cp987629-Nov-08 23:06
cp987629-Nov-08 23:06 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
darrellp30-Nov-08 7:17
darrellp30-Nov-08 7:17 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
cp98761-Dec-08 15:11
cp98761-Dec-08 15:11 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
darrellp1-Dec-08 17:19
darrellp1-Dec-08 17:19 
Yes, that's the kind of thinking I had for both of these questions - equating two quadratics shouldn't be that tough. It's the fact that you've got two quadratic equations in two unknowns in both cases that complicate matters. In the Fortune case, the equations are:

(ys-y)^2 = (x1-x)^2 + (y1-y)^2 = (x2-x)^2 + (y2-y)^2

where ys is the y coordinate of the sweepline and (x1,y1), (x2,y2) are the two points. Using one equation, you can get y as a quadratic function of x. Substituting that into the other equation gives a quartic equation in x and you have similar problems to the ones you deal with in the original problem of this thread. I'm glad I'm not the only one who can be misled by these problems! What's more, like I said, I don't see any nice intuitive transforms or any other easy way, geometric or otherwise, of coming up with the solution for this one. Certainly doesn't mean there isn't one - in fact I suspect that there is such a thing - I just haven't seen it yet. When I got the solution from Mathematica, I was able to break it into lots of redundant pieces to improve performance which suggests to me that there ought to be a way. Perhaps if I meditated on the solution long enough, I could see it, but I haven't spent the time.

Minus some exceptional cases, here's the code I ended up with (directly from my code):

double a1 = 1 / (2 * (pt1.Y - ys));
double a2 = 1 / (2 * (pt2.Y - ys));
double da = a1 - a2;
double s1 = 4 * a1 * pt1.X - 4 * a2 * pt2.X;
double dx = pt1.X - pt2.X;
double s2 = 2 * Math.Sqrt(2 * (2 * a1 * a2 * dx * dx - da * (pt1.Y - pt2.Y)));
double m = 0.25 / da;

double xs1 = m * (s1 + s2);
double xs2 = m * (s1 - s2);
It's been a long time since I did this. I think the rounding was done to avoid some numerical instability problems.

xs1 and xs2 are the x coordinates of the two solutions. For my purposes, I didn't really care about the y coordinates.

Darrell
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
darrellp1-Dec-08 19:27
darrellp1-Dec-08 19:27 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
cp98762-Dec-08 19:54
cp98762-Dec-08 19:54 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
Member 41945933-Dec-08 3:27
Member 41945933-Dec-08 3:27 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
cp98763-Dec-08 10:19
cp98763-Dec-08 10:19 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
Member 41945933-Dec-08 10:58
Member 41945933-Dec-08 10:58 
GeneralRe: How to find 3rd coordinate of a triangle given 2 others Pin
cp98763-Dec-08 13:04
cp98763-Dec-08 13:04 
QuestionSegment Polygon Intersection Pin
hockymot2008_200916-Oct-08 0:28
hockymot2008_200916-Oct-08 0:28 
AnswerRe: Segment Polygon Intersection [modified] Pin
Alan Balkany16-Oct-08 3:29
Alan Balkany16-Oct-08 3:29 
AnswerRe: Segment Polygon Intersection Pin
Alan Balkany16-Oct-08 3:35
Alan Balkany16-Oct-08 3:35 
GeneralRe: Segment Polygon Intersection Pin
hockymot2008_200916-Oct-08 17:21
hockymot2008_200916-Oct-08 17:21 
GeneralRe: Segment Polygon Intersection [modified] Pin
Alan Balkany17-Oct-08 3:23
Alan Balkany17-Oct-08 3:23 
GeneralRe: Segment Polygon Intersection Pin
hockymot2008_200917-Oct-08 3:35
hockymot2008_200917-Oct-08 3:35 
GeneralRe: Segment Polygon Intersection Pin
Member 41945933-Dec-08 11:02
Member 41945933-Dec-08 11:02 
GeneralRe: Segment Polygon Intersection Pin
Alan Balkany3-Dec-08 11:07
Alan Balkany3-Dec-08 11:07 
GeneralRe: Segment Polygon Intersection Pin
Member 41945933-Dec-08 12:22
Member 41945933-Dec-08 12:22 
GeneralRe: Segment Polygon Intersection Pin
Alan Balkany4-Dec-08 3:28
Alan Balkany4-Dec-08 3:28 
GeneralRe: Segment Polygon Intersection Pin
Member 41945934-Dec-08 4:24
Member 41945934-Dec-08 4:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.