We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › finding points between two vectors, help with alg
Page Index Toggle Pages: 1
finding points between two vectors, help with alg (Read 460 times)
finding points between two vectors, help with alg
May 1st, 2009, 9:09pm
 
I'm having trouble with some simple math. I want to use a for loop to make equal vectors between two given vectors. I know that to get the midpoint you would add them together and divide by two but in order to get the quarter way point or the 3/4 way pt multiplying the summed pair by 1/4 and 3/4 (respectively) are not giving the right answers...I just need to develop a pattern so that I can cycle through a for loop and create the vectors as a function of the number of cycles...

I can't get my head around this one even though it's staring me in the face...help?
Re: finding points between two vectors, help with alg
Reply #1 - May 2nd, 2009, 2:29am
 
I think that's because you mutliply after summing.

You can do a loop like summing P1*a + P2*(1.0-a) (vector lerp) with a going from 0.0 to 1.0 and this will give you a point moving from P1 to P2.

your first case is (P1+P2)*0.5 = P1*0.5 + P2*(1.0-0.5), this is just the above equation with a = 0.5.

With your description I think what you're doing is (P1+P2)*a, and the result with a going from 0.0 to 1.0 is a point moving from 0 to (P1+P2).
Re: finding points between two vectors, help with alg
Reply #2 - May 2nd, 2009, 8:59am
 
Yes! it worked...I was trying to work backward as you did to figure out what the pattern in getting the (a+b)/2 but it just wasn't happening. Thanks for coming ot my rescue.
Page Index Toggle Pages: 1