Jump to content
  • Advertisement
Sign in to follow this  

Reducing quadratic equation (a=1)

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

If you intended to correct an error in the post then please contact us.

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?


Share this post

Link to post
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

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

Share this post

Link to post
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! =)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!