RE: [Algorithms] interpolate between points in 3d space
Brought to you by:
vexxed72
From: Steve W. <Ste...@im...> - 2000-07-21 18:53:56
|
When a projectile is fired you should use it's trajectory equation. It sounds like you are entering the realm of physics. I'll give you a clue, but please pick up a book on newtonion physics, browse the web for physics stuff...there's been many references to physics web sites on this list...unfortunately we don't have an archive that goes back far enough right now that I know of. Maybe someone will post a link or two for you. Anyway for your particular example...let's add a mild constant wind resistance Wz and Wx along Z and X axis: X0 = initial X position of fodder after it leaves the cannon. Y0 = initial Y position of fodder after it leaves the cannon. Z0 = initial Z position of fodder after it leaves the cannon. Vx0 = initial velocity in X direction of the fodder after it leaves the cannon. Vy0 = initial velocity in Y direction of the fodder after it leaves the cannon. Vz0 = initial velocity in Z direction of the fodder after it leaves the cannon. Wx = constant wind resistance Wy = constant wind resistance Wz = constant wind resistance g = acceleration of gravity t = time with zero when the fodder leaves the cannon. X = X0 + Vx0 * t - Wx * t //X position Y = Y0 + Vy0 * t - Wy * t - .5g * t^2 //Y position Z = Z0 + Vz0 * t - Wz * t //Z position That's pretty much it, except you may want to use vector math instead of breaking it up into parts like I did. Did this answer your question? R&R > From: Anceschi Mauro [mailto:anc...@li...] > Hi. > I have a little problem in my 3D space game. > When my ship "fire" from a cannon i use a new local axis for > the new object i'm firing , for calculate the next point of the laser. > But this works bad, and i don't have much precision. > So my question is: > How can interpolate from 2 point in 3d? > (x,y,z) and (x',y',z') (suppose the second is an enemy ship). > > Thanks, > > mauro |