This topic is 2612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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!

##### Share on other sites
Do you have a source for that, because quite simply it is wrong.

##### Share on other sites
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

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

##### Share on other sites
Indeed it was the ray/sphere intersection. I had gotten to -b/2 +- sqrt(b^2/4 - c) and was scratching my head at how the heck they got to their equation, but I see now that I was forgetting that its 2tb, completely missed that.
Thanks for clearing that up! =)

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013538
×