What is vec_lerp?

Posted By: WildCat

What is vec_lerp? - 01/28/03 04:28

I see in the latest Beta doc that a new vector function is coming:

vec_lerp(vec v,vec v1,vec v2,var f)
interpolates the vector v between v1 and v2 according to the factor f.

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

Can someone explain to me what this is and in what context it can be used?

A *tiny* code example would be wonderful...

Thanks!

-WildCat
Posted By: WildCat

Re: What is vec_lerp? - 01/30/03 23:43

Doug, Jcl?
Anyone?

I know this function wouldn't have made it into the engine if it did not add some value...

Where would this function be useful?

- WildCat
Posted By: Doug

Re: What is vec_lerp? - 01/31/03 04:49

The best thing I can come up with is that you can use it to make an entity interpolate between two facings. Say your spaceship is pointed towards vec1 and you want to turn towards vec2.

I'm sure I'm missing a dozen other uses but that's the best I can up with. [Wink]
Posted By: mudhole

Re: What is vec_lerp? - 01/31/03 05:44

How about generating a line of particles, between vectors v1 and v2?
eg
code:
counter = 0;
while(counter < num_of_particles_to_create)
{
// determine this particles position
temp = counter / (num_of_particles_to_create-1); // fraction of total distance
// interpolate between start and end vectors to get position
vec_lerp(temp,vecFrom,vecTo,temp);
// create the particle
effect(ParticleAction,1,temp,nullvector);
}

This code should create a line of num_of_particles_to_create particles equally spaced between vecFrom and vecTo. How useful! [Wink]
Posted By: WildCat

Re: What is vec_lerp? - 01/31/03 23:59

Hmmm...

Thanks guys. That got the wheels turning. If I come up with something interesting, I'll let you know!

- WildCat
© 2024 lite-C Forums