开发者

as one variable increases another decreases

I have 2 variables.

float Speed;

float SteeringAngle;

My speed value currently increases. What I want to do is reduce the steering angle as speed increases. It should 开发者_运维问答be a simple equation but I can't seem to work it out.

Thanks


The obvious approach would be something like:

Speed = factor / steeringAngle;

Edit: oops -- I misread your request. If you want to reduce the steering angle as the speed increases, you'd want something like:

if (speed > 0)
    steeringAngle -= factor / speed;


You could try this formula:

  • factor - a number in the range 1..N which is used to scale down the steering angle.
  • maxSpeed - the value of the expected maximum speed at which the maximum factor is applied to reduce the steering angle.
  • requestedAngle - the currently required steering angle

.

float factor;
float maxSpeed;
float requestedAngle;
float Speed;

float SteeringAngle = requestedAngle/( (Speed * factor / maxSpeed) + 1);

There are many possible formulas.

I would suggest you try to plot graphs of speeds and angles

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜