Hi there everyone im looking for a piece of advice relating to convertions.
If i want to make a "car" move at 60 miles per hour then how can i get this figure down to motorSpeed radians per second? Im not the best at maths so im not really sure if i should be turning the 60mph into meters per second or revolutions per second far less getting the point of radians per second.
Could someone point me in the right direction so i have more success on google?
Thanks.
I presume you mean the wheels on the car rotating.
Say the car is going 60 miles an hour. That means, in one hour, it has gone 60 miles (bear with me). We could trace the same 60 miles around on the wheels, as the wheels are always in contact with the ground. So the number of revolutions of the wheel in that hour is 60/p, where p is the perimeter of the wheels. p=2*pi*r for r the radius. So we have done 60/2/pi/r revolutions in hour. There are 2 pi radians in a revolution, so we have done 2*pi*60/2/pi/r = 60/r radians per hour.
Then it's just a matter of unit conversion, as we probably don't have r in miles, nor do we want radians per hour. So let's replace 60 miles an hour with v units per second, and the same logic applies. We get v/r radians per second, where r is in units this time.
Of course, in future you should just jump straight to the answer, but there's the rationale behind it too.
Ahh Boris your a legend as always, my knowledge is primitive in comparison.
Cheers mate,
Clark.
I have more questions on this subject!
In my current game, i need to be able to get the speed in Miles Per Hour. Much like a Speedometer on a car but again i dont really know how to do this.
I tried to subtract the old global position of the car body from the new position using newPos.Subtract(oldPos) but it returns undefined... To be honest though, even if i do find the distance travelled then i dont know what units im dealing with.
Can anyone help? 😀
Well, you could get the linear velocity right from the Body of the car. That will be in m/s which should be easy to convert to mph.
Bill
you could also get the rotation speed of the wheels and convert that back to mph.
// assuming 1 unit = 1 metre
metresPerSecond = axle->GetRotationSpeed() * wheel->GetRadius();
metresPerHour = metresPerSecond / 3600.0f; // 3600 seconds in an hour
kilometresPerHour = metresPerHour / 1000.0f;
milesPerHour = metresPerHour / 1609.344f;
or
milesPerHour = axle->GetRotationSpeed() * wheel->GetRadius() / 3600.0f * 1609.344f;