Hey all,
So for the quadratic equation x = (-b +- sqrt(b^2 - 4ac))/2a
when a=1, real-time rendering says it reduces to -b +- sqrt(b^2 - c)
Embarassingly enough I'm failing at basic algebra to figure out how they got that.
Could anyone show me the equalities to get to the fully reduced equation?
Thanks!
Reducing quadratic equation (a=1)
Probably the ray/sphere hit test equation 13.11 in the 2nd edition of the book is meant:
t[sup]2[/sup] + 2 * b * t + c = 0
The quadratic equation
t[sup]2[/sup] + p * t + q = 0
has the solutions
-p/2 + sqrt( p[sup]2[/sup] / 4 - q )
-p/2 - sqrt( p[sup]2[/sup] / 4 - q )
If one compares that with the equation 13.11 in the book, then the relations
p := 2 * b
q := c
can be extracted, and hence the solutions are
-b + sqrt( b[sup]2[/sup] - c )
-b - sqrt( b[sup]2[/sup] - c )
what matches equation 13.12 in the book. Hence it seems me okay. You probably haven't chosen the correct substitutions.
EDIT: I just saw that wikipedia uses 3 coefficients for a quadratic equation:
a * t[sup]2[/sup] + b * t + c = 0
Well, first notice that the coefficient a, b, and c here are different from the b and c used in the book. Then divide the equation by the local a (assuming that it isn't zero)
t[sup]2[/sup] + b/a * t + c/a = 0
and substitute
p := b/a
q := c/a
and you yield in the simplified version I've used above:
t[sup]2[/sup] + p * t + q = 0
t[sup]2[/sup] + 2 * b * t + c = 0
The quadratic equation
t[sup]2[/sup] + p * t + q = 0
has the solutions
-p/2 + sqrt( p[sup]2[/sup] / 4 - q )
-p/2 - sqrt( p[sup]2[/sup] / 4 - q )
If one compares that with the equation 13.11 in the book, then the relations
p := 2 * b
q := c
can be extracted, and hence the solutions are
-b + sqrt( b[sup]2[/sup] - c )
-b - sqrt( b[sup]2[/sup] - c )
what matches equation 13.12 in the book. Hence it seems me okay. You probably haven't chosen the correct substitutions.
EDIT: I just saw that wikipedia uses 3 coefficients for a quadratic equation:
a * t[sup]2[/sup] + b * t + c = 0
Well, first notice that the coefficient a, b, and c here are different from the b and c used in the book. Then divide the equation by the local a (assuming that it isn't zero)
t[sup]2[/sup] + b/a * t + c/a = 0
and substitute
p := b/a
q := c/a
and you yield in the simplified version I've used above:
t[sup]2[/sup] + p * t + q = 0
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement