Jump to content

How to calculate vehicle speed in MPH?


Poltergeist Azarov
 Share

You are about to reply to a thread that has been inactive for 3524 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 

I wrote that one earlier even if I am not sure yet. So far, as I realized, only way to get object speed is llVecMag(llGetVel()) as float in Meters Per Second. And 1 m/s is equal to 2.2369mph. (source) Finally my solution is to calculate object speed as MPH:
float ms=llVecMag(llGetVel());
llOwnerSay((string)(2.2369*mps));

Anything wrong?


Link to comment
Share on other sites


Poltergeist Azarov wrote:

 

I wrote that one earlier even if I am not sure yet. So far, as I realized, only way to get object speed is 
llVecMag(llGetVel()) as float in Meters Per Second. And 1 m/s is equal to 
2.2369mph. (
) Finally my solution is to calculate object speed as MPH:

float ms=llVecMag(llGetVel());

llOwnerSay((string)(2.2369*mps));

 

Anything wrong?

 

 

 

That looks good to me. llGetVel() returns a 3D vector, and llVecMag() extracts the directionless magnitude from the three axes of the vector. Though I do think there's a typo in your code.

float mps = llVecMag(llGetVel());

llOwnerSay((string)(2.2369*mps));

I've marked the fixed variable in red.

Good luck!

  • Like 1
Link to comment
Share on other sites


Poltergeist Azarov wrote:

Thanks
:)
I was wondering if I was following the right way. Since mathematics are complicated to me.

You're doing fine so far!

float mph = llVecMag(llGetVel())*2.2369;

Is about as concise as you'll get.

ETA: Because I'm feeling chatty this morning, I'll give you more explanation for what's happening in the math than you ever wanted.

Vehicles, whether in RL or SL, move in three dimensions: up/down, left/right (east/west) and forward/reverse(north south). But the speedometer has only one needle. So, what is that needle showing? It's reporting the rate of rotation of the driven wheels. And those wheels don't know anything about whether they're going forward/reverse, up/down or left/right. They don't even know if they're moving the car (that's not important for this discussion, but is fun if you drive like a madwoman). They just know how fast they're turning.

Now, imagine you are driving up a very steep spiral mountain road to the summit, which is three miles above the base. Your speedometer reads 60mph (Slow down! Are you crazy?). After one hour of driving up that mountain. You look at your GPS screen and see you've gone only 10 miles. How the hell did that happen? Part of the answer is obvious. The road was spiral, so we spent a lot of time driving in circles. You could drive on a roundabout all day and get nowhere (something Parhelion Palou and I recently discussed, and want to try).

And, your GPS system, though fully capable of measuring your speed and position in three dimensions, reports your location on a 2D map, because that's how we make maps. We understand that the GPS ignored all our spiraling, but we don't think about the three miles of elevation it also ignored.

In SL, there is no single needle speedometer that just watches wheel revolution. And no 2D map that ignore elevation. We have only a full GPS system with three needles, and that is llGetVel(). GetVel() reports back something like "you're going north at 10mps, east at 10mph and up at 10mph". We have to do some trigonometry to squish those three velocities into one. Trigonometry is challenging for many of us, and that's why LL provided llVecMag().

Link to comment
Share on other sites

Now, imagine you are driving up a very steep spiral mountain road to the summit, which is three miles above the base. Your speedometer reads 60mph (Slow down! Are you crazy?). After one hour of driving up that mountain. You look at your GPS screen and see you've gone only 10 miles. How the hell did that happen? Part of the answer is obvious. The road was spiral, so we spent a lot of time driving in circles. You could drive on a roundabout all day and get nowhere (something Parhelion Palou and I recently discussed, and want to try).

 So ,for GPS :

vector v = llGetVel();v.z = 0.0;llOwnerSay((string)llVecMag(v));

 ??

 

I ve got an another question :

do the speedometer  ( or the GPS ) work on a local frame or a world frame ?

When you drif for instance and you cut the motor , do they report velocity on the frame of the vehicle  or the velocity in the world by the drift ?

Should it be  llVecMag( llGetVel() / llGetOmega()  ) ?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3524 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...