Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Cosine Interpolation problems


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 homojedi   Members   -  Reputation: 121

Like
0Likes
Like

Posted 28 August 2011 - 09:47 PM

I'm working on different types of splines, and i got De CastelJau's bezeir working and moved on to try out cosine interpolation...Much simpler algorithms...However I'm not getting the results That people say i should expect from this algorithm....It looks exactly like linear interpolation...it does not produce any smooth lines whatsoever no curves of any sorts...I may as well just LERP, Could someone please point out where i might be going wrong?

sorry its in obj-c, but nothing too complicated if any syntax confuses you let me know.

- (void) CosineLerp
{    
	float detailBias = 0.1;   

     for( int i = 0; i < [_pointArray count]-2; ++i )   
     {        
		CGPoint p0,p1;   	
	     p0 = [[_pointArray objectAtIndex:i]CGPointValue];   	
	     p1 = [[_pointArray objectAtIndex:i+1]CGPointValue];        

		float count = 0;        
		do        
		{            
			float t = count * M_PI;            
			float g = (1- cosf(t))*0.5;            
			CGPoint temp = ccp( (p0.x*(1-g)+p1.x*g),(p0.y*(1.f-g)+p1.y*g) );            
			[_bezierArray addObject:[NSValue valueWithCGPoint:temp]];            
			count += detailBias;        
		} while (count <= 1.f);   
     }
}


Sponsor:

#2 johnchapman   Members   -  Reputation: 322

Like
0Likes
Like

Posted 29 August 2011 - 04:17 AM

Cosine interpolation has the same effect as linear interpolation when applied in 3D. Cubic interpolation is possibly what you want - it's simple and works in 3D.

There's a nifty interpolationr resource here.

#3 homojedi   Members   -  Reputation: 121

Like
0Likes
Like

Posted 29 August 2011 - 08:47 AM

Cosine interpolation has the same effect as linear interpolation when applied in 3D. Cubic interpolation is possibly what you want - it's simple and works in 3D.

There's a nifty interpolationr resource here.


yeah I've got cubic working, and i have seen that resource...that is what led me to believe that cosine interpolation should be smooth from that graph....a tad misleading i must say.
In any case thank you

#4 RobTheBloke   Members   -  Reputation: 1266

Like
0Likes
Like

Posted 30 August 2011 - 04:04 AM

Cosine interpolation has the same effect as linear interpolation when applied in 3D.


The two are not the same. They follow the same path (if and only if you are using the same curve on all axes), but linear is linear. cosine interp gives you acceleration and deccelerationat at the ends. Mind you smooth-step does that too, and is much much cheaper to compute. Back in the day (when valves were in fashion) we'd use cosine interps on XYZ values, but they would apply in 1 dimension only (i.e. we'd use 3 at a time)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS