|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] GP: ALGORITHM : Flipping a point across a line
>Hello peeps, > >Would anyone happen to know how to calculate the reflected coordinates of >a point, on one side of a line, to the other. An algorithm could be something like this... (this is running from my head as im typing so dont expect this tio be perfect but) ... point1=(x1,y1) line has equation y=mx+c for point2(x2,y2) ---------- hyp=sin(tan-1(m))*(sqrt((mx1+c-y1)^2)) c=2*hyp deltay=(hyp) * (cos(90-(tan-1(m)))) deltax=(hyp) * (sin(90-(tan-1(m)))) therefore... x2=x1+deltax y2=y1+deltay to explain what hyp and deltax and deltay and c are I need to draw diagrams all it generally does is... # calculate the direct distance from the point to the line # double it to get distance from point1 to point 2 # calculate rise and run of that distance which is deltax and deltay which is the distance in x units from point 1 to point 2 and distance in y units from y1 to y2 # hence new points coordinates are just the original ones +- the chanegs in x and y needed to get to next point hope that was useful in some way ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com ================================================================= To SUBSCRIBE or UNSUBSCRIBE please visit http://gameprogrammer.com/mailinglist.html
|
|