I got this from a basic math for junior high school book owned by my friend, it talks about line segmentation, line cross detect or something, can anyone explain it more or maybe provide me some link? I need to understand this formula to make a collision detect algo.
m = (y2-y1) / (x2-x1)
y = mx + c
(y-y1)/(y2-y1) - (x-x1)/(x2-x1)
I need to know what is y, where I can get the c value and more. Thanks for your attention.
I see two equations and an expression. The first equation calculates the slope (http://www.purplemath.com/modules/slope.htm) of a line. The second looks like the equation of a line in slope-intercept (http://www.purplemath.com/modules/strtlneq.htm) form, where m is the slope and c is the y intercept. For the expression, I can recognize and plot the components, but so far I cannot guess how it might be used for collision detection.
Yeah, I dont thing it is applicable for making an collision detect.
I don't remember much high school math but I suspect you are looking at a formula that can be used to calculate how many parabola pass through two points (x1,y1) & (x2,y2). ALthough you appear to be missing the defintion for the family of parabola ?
Hi Farabi:
Try wikipedia, if nothing else the explaination will be
Short.
Regards herge
Hi,
Well, a guess is that you have a line segment from
(x1,y1) to (x2,y2), then the formula you showed;
Quote(y-y1)/(y2-y1) - (x-x1)/(x2-x1)
will evaluate to zero if the point (x,y) is on the line.
If x1 < x2, test if x1 < x < x2 to see if it is on the line
segment. (Numeric accuracy may affect things, so
don't always expect an exact answer.)
HTH,
Steve N.
Quote from: Farabi on October 21, 2008, 03:29:38 AM
Yeah, I dont thing it is applicable for making an collision detect.
Hi,
y = m . x + c is the equation of a line in the plane X,Y where m and c are constants.
When we know 2 points (x1,y1) and (x2,y2) in the plane, then m is given by
y2 - y1 y1 - y2
m = ---------- or m = ---------
x2 - x1 x1 - x2 ( x1 != x2 )
So the equation of the line is
y2 - y1
y = -------- x + c where c = y1 - m . x1
x2 - x1 = y2 - m . x2
When we know that the line passes at the point (0, y0) then c = y0
If we have a point (xi, yi) in the plane, we can know if this point is
on the line or is above the line or bellow that line.
If yi > m . xi + c then the point (xi, yi) is above
If yi < m . xi + c then the point (xi, yi) is bellow
If yi = m . xi + c then the point (xi, yi) is on the line
The equation of a vertical line is simple x = C and horizontal y = D
When we know the slope m and a point (x0, y0) the the equation is
y = y0 + m (x - x0)
Rui
:bg in fact, it's used to calc a new coord,
example : you draw a line (or a polygon), and the line/polygon (2 points) go outside the screen, with this formula, you calc the new point of the screen limit... 0/width/height... it's used to avoid to virtualy draw the entire line (to reduce the number of loop, so speed up....)...
:dazzled:
Looks complicated rui.
Quote from: Farabi on October 25, 2008, 12:57:48 AM
:dazzled:
Looks complicated rui.
Farabi,
very easy, its linear . I dont know if it is good to use in your case
Rui
Quote from: RuiLoureiro on October 27, 2008, 08:13:09 PM
Quote from: Farabi on October 25, 2008, 12:57:48 AM
:dazzled:
Looks complicated rui.
Farabi,
very easy, its linear . I dont know if it is good to use in your case
Rui
Thanks, I understand it. I will try to make a code from it.
Quote from: Farabi on October 20, 2008, 03:38:31 AM
I got this from a basic math for junior high school book owned by my friend, it talks about line segmentation, line cross detect or something, can anyone explain it more or maybe provide me some link? I need to understand this formula to make a collision detect algo.
m = (y2-y1) / (x2-x1)
y = mx + c
(y-y1)/(y2-y1) - (x-x1)/(x2-x1)
I need to know what is y, where I can get the c value and more. Thanks for your attention.
You asked for a link. All I can do is give you a book reference. "Algorithms" by Robert Sedgewick, published by Addison-Wesley, my copy is a 1983 edition - I believe this book has newer editions. It has many algorithms for doing exactly what you want, and is written in understandable English and not in incomprehensible math terms. I could give you the exact example to solve your problem, but you would just ask me tomorrow about another algorithm that is also in the book. The two algorithms you want are "function same" and "function intersect". I find them on page 313 of my edition under the heading of "Elementary Geometric Methods". I keep this book on my reference shelf along with my Knuth volumes. Don't re-invent the wheel, learn from the experts. You need to get this book and read it cover to cover. It will answer so many of your problems.
Dave.
Hi all
Newbie in there...
About Collision equation you may found informations there :
http://hyperphysics.phy-astr.gsu.edu/hbase/elacol2.html
Expect some vector, and math skills...
Regards