Difference between revisions of "Interpolation"

From Second Life Wiki
Jump to navigation Jump to search
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}
Changes/
1.0-1.1 - Added rotation types


<lsl>
Interpolation is a way of constructing new data points within a range of known data points.
//===================================================//
//              Interpolation Library 1.1          //
//              "May 7 2008", "19:16:20 GMT-0"      //
//  Copyright (C) 2008, Nexii Malthus (cc-by)        //
//    http://creativecommons.org/licenses/by/3.0/    //
//===================================================//


float fLin(float v0, float v1,float t){
The range of applications is varied, but here in SL it can most directly be used for animating and/or moving prims or linksets via any attribute you can creatively make use of.
    return v0*(1-t) + v1*t;}


float fCos(float v0,float v1,float t){
Attributes:
    float F = (1 - llCos(t*PI))/2;
* Prim/Object Position
    return v0*(1-F)+v1*F;}
* Prim/Object Rotation
* Texture Scale/Offsets
* or you can just simply interpolate internal values


float fCub(float v0,float v1,float v2,float v3,float t){
Potential applications:
    float P = (v3-v2)-(v0-v1);float Q = (v0-v1)-P;float R = v2-v0;float S = v1;
* Movement
    return P*llPow(t,3) + Q*llPow(t,2) + R*t + S;}
* Animation
* User Interfaces
* Graphics
* Games


vector vLin(vector v0, vector v1,float t){
There are many different types of interpolation, which may exhibit different preferred or controllable behaviour.
    return v0*(1-t) + v1*t;}


vector vCos(vector v0,vector v1,float t){
    float F = (1 - llCos(t*PI))/2;
    return v0*(1-F)+v1*F;}


vector vCub(vector v0,vector v1,vector v2,vector v3,float t){
    vector P = (v3-v2)-(v0-v1);vector Q = (v0-v1)-P;vector R = v2-v0;vector S = v1;
    return P*llPow(t,3) + Q*llPow(t,2) + R*t + S;}


rotation rLin(rotation r0,rotation r1,float t){
== Interpolation Library ==
    // Spherical-Linear Interpolation
    float ang = llAngleBetween(r0, r1);
    if( ang > PI) ang -= TWO_PI;
    return r0 * llAxisAngle2Rot( llRot2Axis(r1/r0)*r0, ang*t);}


rotation rCos(rotation r0,rotation r1,float t){
Linear Interpolation
    // Spherical-Cosine Interpolation
* [[Interpolation/Linear/Float|Float]]
    float f = (1 - llCos(t*PI))/2;
* [[Interpolation/Linear/Vector|Vector]]
    float ang = llAngleBetween(r0, r1);
* [[Interpolation/Linear/Rotation|Rotation]]
    if( ang > PI) ang -= TWO_PI;
* List of [[Interpolation/Linear/Vectors|Vectors]]
    return r0 * llAxisAngle2Rot( llRot2Axis(r1/r0)*r0, ang*f);}


rotation rCub(rotation r0,rotation r1,rotation r2,rotation r3,float t){
    // Spherical-Cubic Interpolation
    // r0 = Start, r1 = End, r2 and r3 affect path of curve!
    return rLin( rLin(r0,r1,t), rLin(r2,r3,t), 2*t*(1-t) );}


default{state_entry(){}}
Cosine Interpolation
* [[Interpolation/Cosine/Float|Float]]
* [[Interpolation/Cosine/Vector|Vector]]
* [[Interpolation/Cosine/Rotation|Rotation]]


</lsl>
Cubic Interpolation
* [[Interpolation/Cubic/Float|Float]]
* [[Interpolation/Cubic/Vector|Vector]]
* [[Interpolation/Cubic/Rotation|Rotation]]
 
 
Catmull-Rom Cubic Interpolation
* [[Interpolation/Catmull-Rom/Float|Float]]
 
 
Hermite Interpolation
* [[Interpolation/Hermite/Float|Float]]
* [[Interpolation/Hermite/Vector|Vector]]
 
Spline Interpolation
* List of [[Interpolation/Spline/Vectors|Vectors]]
 
Rescale
* [[Interpolation/Rescale/Float|Float]]
* [[Interpolation/Rescale/FloatFixed|Float Fixed]]
 
 
Target
* [[Interpolation/Target/Float|Float]]

Latest revision as of 13:10, 16 September 2011

Interpolation is a way of constructing new data points within a range of known data points.

The range of applications is varied, but here in SL it can most directly be used for animating and/or moving prims or linksets via any attribute you can creatively make use of.

Attributes:

  • Prim/Object Position
  • Prim/Object Rotation
  • Texture Scale/Offsets
  • or you can just simply interpolate internal values

Potential applications:

  • Movement
  • Animation
  • User Interfaces
  • Graphics
  • Games

There are many different types of interpolation, which may exhibit different preferred or controllable behaviour.


Interpolation Library

Linear Interpolation


Cosine Interpolation


Cubic Interpolation


Catmull-Rom Cubic Interpolation


Hermite Interpolation

Spline Interpolation

Rescale


Target