计算汽车倒档的位置 [英] calculating position in reverse gear of car
问题描述
大家好
我想编写一个模拟汽车的程序。
我在计算倒车档位时遇到问题
这是我的前进档代码:
theta是车轮的角度
-45< angle< 45
汽车的主要位置是(800,500),格式为
if(gearState()== 1)//前进档位
{
position.X + =(Int32)(speed()* Math.Sin(theta * Math.PI / 180));
position.Y - =(Int32)( speed()* Math.Cos(theta * Math.PI / 180));
}
此代码工作得非常好,但在倒档时不起作用。<当theta = 20并且汽车处于倒车状态时,汽车向左转而不是向右转动$ / b
$ b你有什么想法吗?
请帮忙我
hi everyone
I want to write a program that simulate a car .
I have a problem with calculating position in the reverse gear
this is my code in forward gear:
theta is the angle of wheels of the car
-45<angle<45
primary position of car is in (800,500) in the form
if (gearState() == 1)//forward gear
{
position.X += (Int32)(speed() * Math.Sin(theta * Math.PI / 180));
position.Y -= (Int32)(speed() * Math.Cos(theta * Math.PI / 180));
}
this code work very good but doesn't work in reverse gear.
when theta=20 and car is in reverse gear car goes to the left instead of going right
do you have any idea ?
please help me
推荐答案
假设你的汽车无量纲(和speed()
正面),不应该
Assuming your car dimensionless (andspeed()
positive), shouldn't
if (gearState() == -1)//reverse gear
{
position.X += (Int32)(speed() * Math.Sin(theta * Math.PI / 180));
position.Y <big>+=</big> (Int32)(speed() * Math.Cos(theta * Math.PI / 180));
}
诀窍?
:)
do the trick?
:)
这篇关于计算汽车倒档的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!