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 & HelpPrograms › Problem with rotating a sinewave
Page Index Toggle Pages: 1
Problem with rotating a sinewave (Read 1045 times)
Problem with rotating a sinewave
Sep 18th, 2007, 6:04pm
 
Hi there!
I'm trying to rotate a sinewave. My goal is to have it follow an arbitrary function. I do not want to modulate (add) it onto this function instead it's more that the sinewaves x-axis should be formed according to the function (getting the rotation angle should be easy using the derivative of the function). My problem is the rotation. The example program plots a sinewave rotated by 90° wich works just fine, aswell as a sinewave which is gradually rotated to form a curve. The latter one gets distorted and doesn't really end up as I expect it to. Calculating the rotation matrix by hand (instead of rotate()) ends up pretty much the same way. Am I missing anything of the math?
Thanks in advance and best regards, usl.

Quote:


void setup(){
 size(256,256);
 noLoop();
 background(255);
}

void draw(){
 translate(50, 0);
 rotate(radians(90));
 for(int x=0; x<360; x++) {
   float val1 = sin(x)*10;
   float val2 = sin(x+1)*10;
   
   line(x*2, val1, x*2, val2);
 }
 
 for(int x=0; x<360; x++) {
   float val1 = sin(x)*10;
   float val2 = sin(x+1)*10;
   
   line(x*2, val1, x*2, val2);
   
   rotate(radians(-1));
 }
}



Re: Problem with rotating a sinewave
Reply #1 - Sep 18th, 2007, 6:49pm
 
sin() works with radians aswell.. not sure what your problem is.. what is the result your trying to achieve ?
Page Index Toggle Pages: 1