vec_lerp(VECTOR* v,VECTOR* v1,VECTOR* v2,var f);

Interpoliert den Vektor v zwischen v1 und v2 gemäß Faktor f.

Parameter:

v VEKTOR, WINKEL oder FARBE zum Interpolieren zwischen v1 und v2.
v1 erster Vektor
v2 zweiter Vektor
f Interpolationsfaktor

Modifiziert:

v - wird zwischen v1 und v2 gemäß Faktor f interpoliert.

Geschwindigkeit:

Schnell

Algorithmus:

v = (1-f)*v1 + f*v2

Beispiel (lite-C)::

// the following command sets the position vector at halfway between my and you
vec_lerp(position,my.x,you.x,0.5); 

// the following function interpolates a position, color, or angle to a target value during a time interval t
function time_lerp(var* v,var* vtarget,var time)
{
   wait(1);        // put the function in the scheduler for being identified by proc_kill
   if (NULL != me)
     proc_kill(5); // terminate previous time_lerp calls of the current entity
   var vstart[3];
   vec_set(vstart,v);   
   var t;
   if (time > 0)
     for(t=time_frame; t < time; t += time_frame) {
       vec_lerp(v,vstart,vtarget,t/time);
       wait(1);
     } 
   vec_set(v,vtarget);
}

Siehe auch:

vec_scale

► Aktuelle Version Online