Jump to content

Vertical speed - speedometer script


ainst Composer
 Share

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

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

Recommended Posts

Speed is defined as llVecMag ( llGetVel() ) .  If you want to know the component of speed that is due to  motion in a specific direction, then you filter for that direction alone.  As long as you stick to grid coordinate movement on X, Y, Z, that means you can get Speed (Vertical) from

vector Vel = llGetVel();

llVecMag ( <0.0,0.0, Vel.z> );

and Non-vertical speed from

llVecMag( < Vel.x, Vel.y, 0.0> );

  • Thanks 1
Link to comment
Share on other sites

16 hours ago, Rolig Loon said:

Speed is defined as llVecMag ( llGetVel() ) .  If you want to know the component of speed that is due to  motion in a specific direction, then you filter for that direction alone.  As long as you stick to grid coordinate movement on X, Y, Z, that means you can get Speed (Vertical) from

vector Vel = llGetVel();

llVecMag ( <0.0,0.0, Vel.z> );

and Non-vertical speed from

llVecMag( < Vel.x, Vel.y, 0.0> );

Here is part of this script. Can you please tell me if this is here and what needs to be changed?

SetInstruments()
{
    if(llGetLinkName(instrument_link_number) != instrument_link_name) return; // we do this incase the links change
    
    float speed = ((llVecMag(llGetVel()) * 1.94384) * speed_scale); //get the horizontal speed in knots and scale it based on what we set at the top of the script
    
    //Speed
    float xyz_angles = (speed * -1.0) * (360.0 / 300.0) + 90.0;
    float angles_in_radians = xyz_angles * DEG_TO_RAD; // Change to Radians  
    llSetLinkPrimitiveParamsFast(instrument_link_number, [ PRIM_TEXTURE, 0, instrument_needle_uuid, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, angles_in_radians]);
}

 

Link to comment
Share on other sites

That's what it looks like.  Whoever wrote this is assuming that you are flying horizontally (not a bad assumption most of the time). so s/he's just using the entire llGetVel() vector in that calculation of speed.  The rest is all scaling factors, first from m/sec to knots and then with a fudge factor (speed_scale) that probably parameterises the value for that meter.  The last three lines are converting the speed into movement of the hand on a dial.

Incidentally, the very first line is a clumsy cop-out for not having bothered to get the right link numbers when the script resets. Basically, it's saying, "If I screwed up, this meter is dead, so don't bother calculating speed."

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, Rolig Loon said:

That's what it looks like.  Whoever wrote this is assuming that you are flying horizontally (not a bad assumption most of the time). so s/he's just using the entire llGetVel() vector in that calculation of speed.  The rest is all scaling factors, first from m/sec to knots and then with a fudge factor (speed_scale) that probably parameterises the value for that meter.  The last three lines are converting the speed into movement of the hand on a dial.

Incidentally, the very first line is a clumsy cop-out for not having bothered to get the right link numbers when the script resets. Basically, it's saying, "If I screwed up, this meter is dead, so don't bother calculating speed."

Thanks very much! 

That is, in whatever direction I fly, it will show the speed, even when moving up / down, and I cannot convert it into a vertical speedometer, or I will have to redo the whole script?

Edited by ainst Composer
Link to comment
Share on other sites

2 minutes ago, ainst Composer said:

That is, in whatever direction I fly, it will show the speed, even when moving up / down, and I cannot convert it into a vertical speedometer, or I will have to redo the whole script?

Right.  It is doing what any normal speedometer does .... tells you your speed.  If you want to know your vertical speed for some reason -- to tell you your rate of climb or descent -- you'd need to have a separate dial gauge exactly like this one but scripted to work with just the vertical component of llGetVel instead of the whole thing, as I explained earlier.

  • Thanks 1
Link to comment
Share on other sites

Just now, Rolig Loon said:

Right.  It is doing what any normal speedometer does .... tells you your speed.  If you want to know your vertical speed for some reason -- to tell you your rate of climb or descent -- you'd need to have a separate dial gauge exactly like this one but scripted to work with just the vertical component of llGetVel instead of the whole thing, as I explained earlier.

So If i just make it ... it will work?

float speed = ((llVecMag ( <0.0,0.0, Vel.z> );) * 1.94384) * speed_scale);
Link to comment
Share on other sites

8 minutes ago, ainst Composer said:

So If i just make it ... it will work?


float speed = ((llVecMag ( <0.0,0.0, Vel.z> );) * 1.94384) * speed_scale);

Any reason why you added this at the fourth parenthesis ' ; ' ?

Edited by steph Arnott
  • Thanks 1
Link to comment
Share on other sites

3 minutes ago, Rolig Loon said:

That's why I said to "clean it up"  😉  And I am assuming that he defined the variable Vel as I advised.

If already such a topic, a related question arose: how to make it show only horizontal speed?

(llVecMag ( <Vel.x,Vel.y,0.0> )

 

Link to comment
Share on other sites

5 minutes ago, ainst Composer said:

If already such a topic, a related question arose: how to make it show only horizontal speed?


(llVecMag ( <Vel.x,Vel.y,0.0> )

 

I just do not know why you do not just get the last Z then the current Z every few seconds . A climb meter is not air flow meter.

  • Thanks 1
Link to comment
Share on other sites

I think we can simplify llVecMag(<0.0, 0.0, Vel.z>) to just plain ol' Vel.z ... and because we're already getting Vel anyway to calculate (horizontal) land speed there's no extra calculation involved.

That said, it seems a lost opportunity to use a climb/dive gauge, instead of being able to watch the spinning hands of an altimeter as the aircraft plummets to earth. 😜

  • Thanks 1
Link to comment
Share on other sites

1 minute ago, Qie Niangao said:

That said, it seems a lost opportunity to use a climb/dive gauge, instead of being able to watch the spinning hands of an altimeter as the aircraft plummets to earth. 😜

Is that when the 'tune into next weeks episode' is announced?

  • Thanks 1
  • Haha 1
Link to comment
Share on other sites

3 hours ago, Qie Niangao said:

I think we can simplify llVecMag(<0.0, 0.0, Vel.z>) to just plain ol' Vel.z ... and because we're already getting Vel anyway to calculate (horizontal) land speed there's no extra calculation involved.

That said, it seems a lost opportunity to use a climb/dive gauge, instead of being able to watch the spinning hands of an altimeter as the aircraft plummets to earth. 😜

Good point.  I was recognizing that the OP is a beginning scripter, so I was trying to make it as simple as possible rather than going into a more involved (and probably more RL logical) way of doing things.  

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, Qie Niangao said:

That said, it seems a lost opportunity to use a climb/dive gauge, instead of being able to watch the spinning hands of an altimeter as the aircraft plummets to earth. 😜

You must be instrument rated. I'd be looking through the windshield.. and screaming.

Edited by Madelaine McMasters
  • Thanks 1
Link to comment
Share on other sites

3 minutes ago, Madelaine McMasters said:

You must be instrument rated. I'd be looking through the windshield.. and screaming.

Yep, definitely the hook for next weeks episode. Which some how turns out to be different from the last. You probably suddenly reveal you have wings and fly off.

  • Thanks 1
Link to comment
Share on other sites

22 hours ago, Rolig Loon said:

For measuring your vertical speed, yes.  (Well, clean it up.)

So i made it ... but it says Name not defined about Vel.z. How do i define Vel.z?

SetInstruments()
{
    if(llGetLinkName(instrument_link_number) != instrument_link_name) return; // we do this incase the links change
    
    float speed = ((llVecMag( <0.0,0.0, Vel.z>) * 1.94384) * speed_scale); //get the horizontal speed in knots and scale it based on what we set at the top of the script
    
    //Speed
//////.....
}

 

Edited by ainst Composer
Link to comment
Share on other sites

8 minutes ago, ainst Composer said:

So i made it ... but it says Name not defined about Vel.z. How do i define Vel.z?


SetInstruments()
{
    if(llGetLinkName(instrument_link_number) != instrument_link_name) return; // we do this incase the links change
    
    float speed = ((llVecMag( <0.0,0.0, Vel.z>) * 1.94384) * speed_scale); //get the horizontal speed in knots and scale it based on what we set at the top of the script
    
    //Speed
//////.....
}

 

You did not use what Rolig stated vector Vel = llGetVel();

  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1850 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...