|
Author |
Topic: Point on a line (Read 265 times) |
|
inadaze
|
Point on a line
« on: Nov 21st, 2004, 3:10am » |
|
Hi, new question: If I had two circles drawn on the stage and a line drawn connecting the two circles, and I was to draw a third circle on the stage, how could i check if the third circle was drawn on the line or not? I can understand how to do this with the start or the end of the line but not if the third point is drawn somewhere between. Thanks Jay
|
« Last Edit: Nov 21st, 2004, 3:11am by inadaze » |
|
|
|
|
st33d
|
Re: Point on a line
« Reply #1 on: Nov 27th, 2004, 3:04am » |
|
Simpleton responding here. Bear with me. If the circle is static, and you're scanning an overlap in the line you may want to check the bounding box of the circle. The example below checks a point for inclusion in a box and could be adapted for such. Code: boolean overRect(float xo, float yo, float x1, float y1, float x2, float y2){ if (xo >= x1 && xo <= x2 && yo >= y1 && yo <= y2) { return true; } else { return false; } } |
| And here's it more in depth: http://www.gamedev.net/reference/articles/article735.asp If the circle is moving then you just have to check the leading edge of the circle relative to your angle of trajectory and the wherabouts of the line. More in depth here: http://www.gamedev.net/reference/articles/article1026.asp
|
« Last Edit: Nov 27th, 2004, 4:04am by st33d » |
|
I could murder a pint.
|
|
|
|