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 › Change Angle of Drawn Line
Page Index Toggle Pages: 1
Change Angle of Drawn Line (Read 1362 times)
Change Angle of Drawn Line
Feb 21st, 2009, 8:03pm
 
Hello,

I am interfacing an Arduino based IMU to Processing, I would like to draw a line in processing and have the line follow the angle at which the IMU is held.

I have the serial link working, Processing successfully inputs the angle from the Arduino.  The problem is how to apply the angle to the line.  I have tried using

rotate(radians(inputangle));
line(100,100,200,100);

first, this does not rotate the line on the axis (apperantly this can be fixed by the translate(); function?)

second as this goes through the main loop the line gets continuously rotated, ie.  if inputangle is 1 then it rotates (radians(1)) degree every loop.

I basically would like a line to mirror the IMU in angle.

Any thoughts??

Thanks!
Re: Change Angle of Drawn Line
Reply #1 - Feb 21st, 2009, 8:36pm
 
Look at Re: getting the direction of a moving point, the DisplayAngle function. Indeed, you need to use a combination of translate and rotate, and restoring context (matrix) after.
Re: Change Angle of Drawn Line
Reply #2 - Feb 22nd, 2009, 4:01am
 
thanks, i got it to work for what i need now, even though I have absolutely no idea on why it work, but this will give me a base to experiment and learn on

thanks again
Page Index Toggle Pages: 1