Re: Anyone know anything about trigonometry?
- Posted by Chris Bensler <bensler at telus.net> Sep 06, 2001
- 458 views
Unless you really want it to be fairly accurate, I wouldn't worry about calculating trajectories. In fact, more often than not, I find it looks more realistic, taking the approach I mention, rather than actually trying to calculate the trajectory. Like others said, you need to consider gravity, resistance (friction and wind force), inertia, mass, aerodynamics (that's being very petty :P). If you were making a golf game, I would say that tracjectory calculations would be crutial. If you look at any fireworks demos, they should give you an idea of what to do. Most use arcs for the path of the flare and the sparks, they will even take into account GRAVITY and trajectory SPEED. I haven't looked at the workings of the EU fireworks demos, but I suspect it would be similar. I know that there are numerous fireworks examples for BASIC, that demonstrate how to do the arced paths. The main concept is to change the position incrementally(the increment can be whatever realistic value you choose), multiplying the increment by SPEED, and subtracting (or dividing) GRAVITY every time. Once you've made your calculation for that increment, you decrement SPEED. Eventually, speed will be 0 and the trajectory will end. For fireworks, I would have static values for increment and gravity, and speed is random. For your purposes, speed wouldn't be random. This should give you an idea of how to proceed EG. INCREMENT=10 GRAVITY=0.6 SPEED=50 while SPEED>0 do pos_x+=INCREMENT*SPEED*GRAVITY pos_y+=INCREMENT*SPEED*GRAVITY SPEED-=1 end while Chris