   preserve turn radius at varying speeds?
  I have a vehicle of sorts which moves at various speeds, I'm steering it by adding or subtracting vr to/from vehicle.angle, but because of the varying speed the radius of the turns increases/decreases. How can I adjust the vr value to ensure that the turning radius stays the same?movement codevar radians = vehicle.angle *Math.PI/180;var xSpeed = Math.cos(radians)*vehicle.speed;var ySpeed = Math.sin(radians)*vehicle.speed;
  v = r . wr = v / wfor different velocities v0 and v1, if your radius remains constantv0 / w0 = v1 / w1w1 = w0 . (v1 / v0)assuming constant frame rate, I suppose you will have to modulate your vr by the increase in linear speed.   ;  Thanks for the reply, but I don't know what the variables are representing. I haven't had much formal math teaching so I might not understand many common notations, but understanding theory and aplying it shouldn't be a problem.I guess v is velocity and r is probably rotation, but I'm completely lost on w.Hate to sound like a noob, but alas... :|   ;  If 'theta' is your car's angle, then w = (d/dt)theta .  Really it's an "omega," but that looks like 'w.'  FYI, the use of 'omega' for angular velocity is a standard convention.   ;  Funny... really... =/Once upon a time I used to get good help here, any chance of that?   ;Quote:Original post by KirlFunny... really... =/Once upon a time I used to get good help here, any chance of that?I thought your only problem was that you didn't know what 'w' is.  So what else are you confused about?Basically, here's the punchline:[The amount you add to vehicle.angle each frame] =[timestep]*([vehicle speed]/[turning radius]).Calling vehicle.angle 'theta,' the vehicle speed 'v,' and the turning radius 'R,' you might write this as an ordinary differential equation (ODE) like,(d/dt)theta = v/R .What I am doing when I also include a timestep is approximating the solution to this ODE by Euler integration.I think this explains everything?   ;  w is angular velocity. basically, you rate of turn per frame whatever your angle increment is, as long as your frame rate is constant. Else, you need to factor in your frame timestep.in short, you modify your angle step by the ratio of velocities, since the relationship between radius of turn, rotation and linear velocity is linear. That's what I come up with anyway :)   ;  actually it's quite simple. You know your velocity, you know your radius, the angular velocity will be v / r. That means, your maximum rate of turn every frame will be (v / r) * frame_timestep.   ;  Thanks for the elaboration guys, I got it now! =) It is indeed quite simple in hindsight, weird how my mind can complicate things sometimes.Sorry emergent, I thought you were having a bit of fun at my expense by throwing in some more mystery variables (theta, omega? d? dt?). How do you guys come up with w as radius anyhow? I guess it's convention but as I mentioned, I'm probably not aware of those...I stumbled upon another little problem with my movement code though. To the eye the vehicles seem to descibe a perfect circle, but after a certain number of rounds it becomes clear they're wandering. It seems there's a slight inacuracy in my movement code somewhere. Doh, I'll be back probably.   ;Quote:Original post by KirlSorry emergent, I thought you were having a bit of fun at my expenseNo, not my style. :-)Quote:mystery variables (theta, omega? d? dt?)The notation "d/dt" does not represent the ratio of two variables 'd' and 'dt.'  Rather, it denotes the time derivative (i.e., rate of change) from calculus.Quote:How do you guys come up with w as radius anyhow?To be clear, 'w' is not the radius.  Rather, it's the rate of change of the angle.  The convention comes from physics, where Roman letters are used for linear position/velocity/acceleration, and corresponding Greek letters are used for angular position/velocity/acceleration.  I.e., linear velocity is 'v' but angular velocity is 'omega;' linear acceleration is 'a' but angular acceleration is 'alpha.'Quote:I stumbled upon another little problem with my movement code though. To the eye the vehicles seem to descibe a perfect circle, but after a certain number of rounds it becomes clear they're wandering. It seems there's a slight inacuracy in my movement code somewhere.I would guess that this is the result of integration error.  The player slowly spirals out, right?Here's what "integration error" means: Basically, Euler integration (see the previous Wikipedia link) is only an approximation, and errors build up over time (there's a good graphic to describe this at the Wikipedia article).  Usually in games, the character is controlled by a human player so this doesn't really matter; the player won't even notice, and he'll just subconsciously correct for it.  From your description, I would guess that this is what's going on.  So long as the effect is small, I might not bother trying to "fix" it.This said, it's quite possible to avoid most of this error (you'll end up using some sines and cosines) and if you'd like we can talk more about it, but I'll hold off on that for now (sleep calls me).   