#### Archived

This topic is now archived and is closed to further replies.

# Imaginary #'s

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

## Recommended Posts

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! =)

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

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

##### Share on other sites
Thanks for all your help! That is why I love this site!

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632922
• Total Posts
3009218
• ### Who's Online (See full list)

There are no registered users currently online

×