Sep 20, 2001 #1 SteveD73 Programmer Jan 5, 2001 109 GB Hi Given 4 sided polygon defined by four points: CPoint p1 CPoint p2 CPoint p3 CPoint p4 How can I calculate the point of intersection between the diaganols (p1,p3) and (p2,p4)? Thanks for your help.
Hi Given 4 sided polygon defined by four points: CPoint p1 CPoint p2 CPoint p3 CPoint p4 How can I calculate the point of intersection between the diaganols (p1,p3) and (p2,p4)? Thanks for your help.
Sep 20, 2001 #2 jtm111 Programmer Jun 27, 2001 103 US rectangle is: p1 p2 p3 p4 Intersection of diagonals: x coordinate = p3.x + ((p4.x - p3.x)/2) y coordinate = p3.y + ((p1.y - p3.y)/2) x is horizontal axis y is vertical axis p1.x is the x coordinate of p1 p1.y is the y coordinate of p1 etc. This seems right doesn't it? Upvote 0 Downvote
rectangle is: p1 p2 p3 p4 Intersection of diagonals: x coordinate = p3.x + ((p4.x - p3.x)/2) y coordinate = p3.y + ((p1.y - p3.y)/2) x is horizontal axis y is vertical axis p1.x is the x coordinate of p1 p1.y is the y coordinate of p1 etc. This seems right doesn't it?
Sep 20, 2001 Thread starter #3 SteveD73 Programmer Jan 5, 2001 109 GB The above only works when the shape is a rectangle. I need a formulae that will work with any 4 sided shape. Upvote 0 Downvote
The above only works when the shape is a rectangle. I need a formulae that will work with any 4 sided shape.
Sep 20, 2001 #4 Zyrenthian Programmer Mar 30, 2001 1,440 US it is a mathematical formula that you need. First you need to put the lines into slope intercept form (y=mx+b) lets say a simple square p1(0,0) p2(0,4) p3(4,4) p4(4,0) and we draw lines from p1 to p3 and from p2 to p4 slope(m) = rise/run so the slope of the line from p1 to p3 is 1 rise = 4 run = 4 and 2 to 4 is -1 rise = -4 run = 4 now we have formulas for the lines y = x + 0 y = -x + 4 we know the y coordinates will be the same so we can: x+0 = -x+4 solve for x and we get 2x = 4 or x = 2 2 is the x intercept of the 2 lines substitute 2 into an original equation y = 2 + 0 y = -2 +4 either one give interseckiton of (2,2) Matt Sorry if this was already posted, i was away from my desk for a bit Matt Upvote 0 Downvote
it is a mathematical formula that you need. First you need to put the lines into slope intercept form (y=mx+b) lets say a simple square p1(0,0) p2(0,4) p3(4,4) p4(4,0) and we draw lines from p1 to p3 and from p2 to p4 slope(m) = rise/run so the slope of the line from p1 to p3 is 1 rise = 4 run = 4 and 2 to 4 is -1 rise = -4 run = 4 now we have formulas for the lines y = x + 0 y = -x + 4 we know the y coordinates will be the same so we can: x+0 = -x+4 solve for x and we get 2x = 4 or x = 2 2 is the x intercept of the 2 lines substitute 2 into an original equation y = 2 + 0 y = -2 +4 either one give interseckiton of (2,2) Matt Sorry if this was already posted, i was away from my desk for a bit Matt