Efficent Camera Movement

[QUOTE]Originally posted by ribblem:
[b]When I started this thread I was sure the trig functions use some infinite series to produce the results and I’m still pretty certain that is what is being done. If anyone knows which infinate series is used I’d appricate it if you’d tell me, just so I know.

I don’t know if these series are what are used in computers, but here is what I got from my CRC tables of Mathematical Formulae:
Ch. 1, p.41,

Infinite Series:

(the result of taking the Maclaurin series for the funtion )

sinx = x - (x^3/3!) + (x^5/5!) - (x^7/7!) + …

cosx = 1 - (x^2/2!) + (x^4/4!) - (x^6/6!) + …

There are also formulas that use infinite products (like a summation, but using multiplication instead of addition).

Hope that helps.

Here are some formulas that may help you out:

DOT PRODUCT:

A . B = |A| |B|cosx, where x is the angle between vectors A and B. (remember |X| is the magnitude of vector X).

This gives us a simple formula for the angle between two vectors

cosx = (A . B)/(|A| |B|)

|A x B| = |A| |B|sinx.

So sinx = (|A x B|)/(|A| |B|).

Cross products are somewhat more costly than dot products, but should be easier than using series.

Originally posted by ribblem:
I’m pretty sure that sin and cos are pretty expensive. I suppose I could run a little benchmark. I’ve seen replacement sine and cosine routines that use a table lookup to speed up these computations, that makes me think the default versions are slow. I know dot products are super fast so that is why I’d like to find a way to replace my current method with a dot product method. In the mean time I think I’ll put together a little bench mark. Talk to ya latter

[QUOTE]Originally posted by Blza:
[b]No DFrey…
thats not off topic…

i dont know how uses those variables to simulate phisics laws man…

i mean, gravity, friction on body-to-body, etc…
is it hard ???


Simulating physics should not be that hard. Mechanics really isn’t that difficult (at least for me). Physics gets bad when it comes to wave motion, electricity and magnetism, optics, relativity, and quantum.

Look at a basic mechanics textbook. Serway is a good author. Most of the formulas are polynomial or trigonometric, and calculus is only necessary to derive the formulas (once you’ve got them, you can simply plug and chug).

Good luck

Lets see… Lookup table (cached) versus complex number operations… if your code is well ordered, the lookup table will ALWAYS yield better results in the long run over intensive calculations, save the case of optimized insturction sets, ie: AMD’s math libraries for the K7.

Suffice it to say, its still a very fast optimization that can be made.