Imaginary #'s

Started by
2 comments, last by MARS_999 22 years, 8 months ago
Ok is their any use for imaginary numbers in games? If so can C/C++ handle a result if it''s imaginary? Is their a function for this? How would you go about this? e.g. x = sqrt(-2); this is the output from that statement -1.#IND Please forgive me! =)
Advertisement
I''ve not come across a direct application for complex/imaginary numbers in games. You can use them in the theory behind some concepts: e.g. when solving second order differential equations (used to model spring motion, such as in a car suspension) complex numbers help explain the difference between different sorts of damping. But in the final calculations you always avoid them: it''s generally much quicker to use special case code to handle a negative square root than to use complex numbers.

As for using them there are complex extensions to most programming languages, including C, and I think they''re part of the standard library in C++. Try searching for *complex*.* in your dev environment(s) to see what capabilities are provided.
John BlackburneProgrammer, The Pitbull Syndicate
To expand on johnb''s reply, imaginary numbers arise in determining the stability of numerical methods, say for physics integration. They wouldn''t be used *in* the game, but they would (and often *should*) be used to help you choose an appropriate integration method to ensure your physics are stable and don''t blow up numerically.

Imaginary numbers do also arise in some fast methods for simulating fluid flow, for example in thin wing and airfoil theory. I suppose they could be used directly *in* a game if you were to use these methods for, say, determining aerodynamic loads in airplane flight simulation. But you can usually get better aerodynamic loads using different methods so there''s no compelling reason to use these methods. They also arise in more advanced fluid simulations, such as the prediction of the transition of a flow from laminar to turbulent. There may be some interesting uses of this for games, who knows.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Thanks for all your help! That is why I love this site!

Please forgive me! =)

This topic is closed to new replies.

Advertisement