-
Posts
524 -
Joined
-
Last visited
Content Type
Forums
Blogs
Knowledge Base
Everything posted by 2Tessa
-
-
-
-
-
Simple: Do not buy extra L$ through subscription, so you will not risk to get banned for a failed payment, 600 L$, while your shop make 2000 L$ per month.
-
Dear Philip, I have been banned and my online shop closed for some months for not paying 5$ of Plus subscription. This is nonsense. With my shop I add value to SL. Why don't kneecapping me instead? Just to show who is the boss... 🙄
-
-
-
You are right. I subscribed the Plus, not the Basic. Which gives 150L$ per week stipend. Basic has no stipend. 😋
-
After i got ejected by the sandbox where i was renting, I canceled my Basic membership, that had the only purpose to pay the rent. Now, they closed my shop and suspended my account. So the Basic subscription have been a very bad idea... 🤔 PS: I mean Plus membership
-
-
-
-
-
PRIM_PROJECTOR is working ONLY if the projected texture is in the object inventory. The wiki should mention about this requirement.
-
-
777
-
-
-
-
int_value = fui(fl_value); int_value += 127 << 23; int_value = int_value >> 1; fl_result = iuf(int_value); this simple code works as SQRT for large float values: llSqrt( 3.40282346e38 ) gives: 1.84467429e19 bitwiseSqrt( 3.40282346e38 ) gives: -1.84467429e19 only the sign is wrong but lose precision for small values: llSqrt( 2 ) gives: 1.41421353 bitwiseSqrt( 2 ) gives: 1.5 😆
-
Very interesting to know that float can be stored into integer 😀 //================================================================= // Float Union Integer (see LSL wiki) integer fui(float input) { if((input) != 0.0){ integer sign = (input < 0) << 31; if((input = llFabs(input)) < 2.3509887016445750159374730744445e-38) return sign | (integer)(input / 1.4012984643248170709237295832899e-45); integer exp = llFloor((llLog(input) / 0.69314718055994530941723212145818)); return (0x7FFFFF & (integer)(input * (0x1000000 >> sign))) | (((exp + 126 + (sign = ((integer)input - (3 <= (input /= (float)("0x1p"+(string)(exp -= ((exp >> 31) | 1)))))))) << 23 ) | sign); } return ((string)input == (string)(-0.0)) << 31; } float iuf(integer input) { return llPow(2.0, (input | !input) - 150) * (((!!(input = (0xff & (input >> 23)))) << 23) | ((input & 0x7fffff))) * (1 | (input >> 31)); } //----------------------------------------------------------------- float e = 2.71828182845904523536028747135266249; integer inte; float floe; default { touch_start(integer tot_num) { llOwnerSay("Float Union Integer (float stored into integer and way back)"); llOwnerSay("e: "+Float2Sci(e)); // does not truncate the decimals inte = fui(e); llOwnerSay("inte = fui(e): "+(string)inte); floe = iuf(inte); llOwnerSay("floe = iuf(inte): "+Float2Sci(floe)); // does not truncate the decimals llOwnerSay("floe = iuf(inte): "+(string)floe+" (typecasted)"); } }
-
As alternatives of: llSqrt( llFrand(1) ) I tried: llPow( e , 0.5 * llLog( llFrand(1) ) ) llPow( 10 , 0.5 * llLog10( llFrand(1) ) ) llPow( llFrand(1) , 0.5 ) but even the single call of them [ llPow(), llLog(), llLog10() ] is 50-100% slower than llSqrt() 😆
-
Yesterday I was looking for ways to normalize rotations faster and i found this way that increase the speed by ~20%: instead to execute 4 divisions: rotation NormRot(rotation Q) { float MagQ = llSqrt(Q.x*Q.x + Q.y*Q.y +Q.z*Q.z + Q.s*Q.s); return <Q.x/MagQ, Q.y/MagQ, Q.z/MagQ, Q.s/MagQ>; } you can execute 4 multiplication by the inverse rotation NormRot(rotation Q) { float iMagQ = 1/llSqrt(Q.x*Q.x + Q.y*Q.y +Q.z*Q.z + Q.s*Q.s); return <Q.x*iMagQ, Q.y*iMagQ, Q.z*iMagQ, Q.s*iMagQ>; } I also tried to find ways to compute the SQRT faster for NLERP rotation interpolation rotation NLERP(rotation a, rotation b, float t) { float ti = 1-t; rotation r = <a.x*ti, a.y*ti, a.z*ti, a.s*ti>+<b.x*t, b.y*t, b.z*t, b.s*t>; float m = llSqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.s*r.s); // normalize return <r.x/m, r.y/m, r.z/m, r.s/m>; } and in C there are plenty ways, but they use operators which are not available in LSL, or they lose the speed when interpreted. Who have in-depth knowledge can understand if any of these ways can be effective in LSL. The fastest SQRT hacks the 32bit memory representation of the float value. float sqrt7(float x) { // convert float to bitwise but LSL don't have ADDRESS type and unary operators * and & unsigned int i = *(unsigned int*) &x; i += 127 << 23; i >>= 1; return *(float*) &i; } float Q_rsqrt( float number ) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; i = 0x5f3759df - ( i >> 1 ); y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); return y; } float fastsqrt(float val) { union { int tmp; float val; } u; u.val = val; u.tmp -= 1<<23; u.tmp >>= 1; u.tmp += 1<<29; return u.val; } func NewtonSqrt(x float64) float64 { z := 1.0 // let initial guess to be 1 for i := 1; i <= 10; i++ { z -= (z*z - x) / (2*z) // MAGIC LINE!! } return z } double ApproximateSqrtBabylonian(double x, int precision) { double res = x; for (int n = 0; n < precision; n++) { res = 0.5f * (res + x / res); } return res; } /* by Jim Ulery */ static unsigned julery_isqrt(unsigned long val) { unsigned long temp, g=0, b = 0x8000, bshft = 15; do { if (val >= (temp = (((g << 1) + b)<<bshft--))) { g += b; val -= temp; } } while (b >>= 1); return g; } double fsqrt (double y) { double x, z, tempf; unsigned long *tfptr = ((unsigned long *)&tempf) + 1; tempf = y; *tfptr = (0xbfcdd90a - *tfptr)>>1; /* estimate of 1/sqrt(y) */ x = tempf; z = y*0.5; /* hoist out the “/2” */ x = (1.5*x) - (x*x)*(x*z); /* iteration formula */ x = (1.5*x) – (x*x)*(x*z); x = (1.5*x) – (x*x)*(x*z); x = (1.5*x) – (x*x)*(x*z); x = (1.5*x) – (x*x)*(x*z); return x*y; }
-