interpolation/Hermite/Vector

From Second Life Wiki
< Interpolation‎ | Hermite
Revision as of 04:13, 14 September 2011 by Nexii Malthus (talk | contribs) (Created page with "{{LSL_Function |mode=user |func=vHem |p1_type=vector|p1_name=a |p2_type=vector|p2_name=b |p3_type=vector|p3_name=c |p4_type=vector|p4_name=d |p5_type=float|p5_name=t |p6_type=flo…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Summary

Function: vector vHem( vector a, vector b, vector c, vector d, float t, float tens, float bias );

Hermite interpolation of vectors a, b, c and d with fraction t, tension and bias.
Returns a vector

• vector a
• vector b
• vector c
• vector d
• float t
• float tens
• float bias

Specification

<lsl>vector fHem(vector a, vector b, vector c, vector d, float t, float tens, float bias){

   float t2 = t*t;float t3 = t2*t;
   vectora 0 =  (b-a)*(1+bias)*(1-tens)/2;
          a0 += (c-b)*(1-bias)*(1-tens)/2;
   vector a1 =  (c-b)*(1+bias)*(1-tens)/2;
          a1 += (d-c)*(1-bias)*(1-tens)/2;
   float b0 =  2*t3 - 3*t2 + 1;
   float b1 =    t3 - 2*t2 + t;
   float b2 =    t3 -   t2;
   float b3 = -2*t3 + 3*t2;
   return b0 * b + b1 * a0 + b2 * a1 + b3 * c;

} // Released into public domain. By Nexii Malthus.</lsl>

Examples

<lsl></lsl>