Jump to content

uhu


VirtualKitten
 Share

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

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

Recommended Posts

Hi everyone I wonder if you could help I came across this delighful page which i though might solve all of my problems http://wiki.secondlife.com/wiki/Wanderer only to implement a version of :
 

vector nextCoordinates(integer TYPE) {
    float driftRange = llFrand(MOVEMENT_RANGE);
    float a = llFrand(TWO_PI);
    float b = llFrand(TWO_PI);
    float c = llFrand(PI);
    if(TYPE == 2) return <iPos.x + driftRange, iPos.y + llFrand(MOVEMENT_RANGE), iPos.z>;
    if(TYPE == 4) return <iPos.x + driftRange * llCos(a), iPos.y + driftRange * llSin(b), iPos.z>;
    if(TYPE == 8) return iPos + <driftRange * llCos(a) * llCos(b), driftRange * llCos(a) * llSin(b), driftRange * llSin(a)>;
    if(TYPE == 16) return iPos + <driftRange * llCos(a) * llCos(b), driftRange * llCos(a) * llSin(b), driftRange * llSin(c)>;
    if(TYPE == 32) return iPos + <driftRange * llCos(a) * llCos(b), driftRange * llCos(a) * llSin(b), -driftRange * llSin(c)>;
    if(TYPE == 64) return iPos + <driftRange * llCos(a) * llCos(b), llFrand(MOVEMENT_RANGE) * llCos(a) * llSin(b), driftRange * llSin(a)>;
    if(TYPE == 128) return iPos + <driftRange * llCos(a) * llCos(b), llFrand(MOVEMENT_RANGE) * llCos(a) * llSin(b), driftRange * llSin(c)>;
    if(TYPE == 256) return iPos + <driftRange * llCos(a) * llCos(b), llFrand(MOVEMENT_RANGE) * llCos(a) * llSin(b), -driftRange * llSin(c)>;
    return iPos;
}
      
      by the wanderer

Does anyone have a neater solution please like llWanderWithin( uses?

 

Thanks for looking Denise

Edited by VirtualKitten
Link to comment
Share on other sites

On 2/7/2021 at 3:14 AM, VirtualKitten said:

Does anyone have a neater solution please like llWanderWithin( uses?

given that nextCoordinates is a lookup for different math calculations then the way this code is written is the most efficient. Is not elegant but it is efficient

Link to comment
Share on other sites

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