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 & HelpOther Libraries › MULTITOUCH ROTATION IMAGE
Page Index Toggle Pages: 1
MULTITOUCH ROTATION IMAGE (Read 581 times)
MULTITOUCH ROTATION IMAGE
Oct 23rd, 2008, 1:38pm
 
Hi there,

I'm working with a multitouch system with blobs recognition and i want to rotate one image with the information of two blobs. (like iphone style)
How can i know, with two blobs points, that i'm rotating to right/left??
I'm not very good in maths, but i think, i have to calculate the angle of the vector of the two blobs point?
Would some help me please?
thanks,

RBOY
Re: MULTITOUCH ROTATION IMAGE
Reply #1 - Oct 23rd, 2008, 2:52pm
 
it depends on which reference you are Wink

http://www.allegro.cc/forums/thread/591460

or something similar Smiley you reference would be something like ax=0,ay=1

float get_angle_between_in_radians(float ax, float ay, float bx, float by)
{
  float dotproduct, lengtha, lengthb, result;

  dotproduct = (ax * bx) + (ay * by);
  lengtha = sqrt(ax * ax + ay * ay);
  lengthb = sqrt(bx * bx + by * by);

  result = acos( dotproduct / (lengtha * lengthb) );

  if(dotproduct < 0)
  {
     if(result > 0)
        result += M_PI;
     else
        result -= M_PI;
  }
  return result;
}
Re: MULTITOUCH ROTATION IMAGE
Reply #2 - Oct 23rd, 2008, 5:12pm
 
You can find code for it in ActionScript here:
http://code.google.com/p/touchlib/source/browse/#svn/trunk/AS3

It's hidden in a lot of classes that extend other classes, so you're gonna have to start ripping out the stuff that matters.

Good luck Smiley
Let us know how you're coming along.

seltar

Re: MULTITOUCH ROTATION IMAGE
Reply #3 - Oct 23rd, 2008, 6:33pm
 
thanks!
Re: MULTITOUCH ROTATION IMAGE
Reply #4 - Oct 24th, 2008, 8:41pm
 
atan2() might help, maybe?
http://processing.org/reference/atan2_.html
Re: MULTITOUCH ROTATION IMAGE
Reply #5 - Oct 25th, 2008, 10:29am
 
the problem with atan2 is that only calculates one point.
any ideas?
cheers.
Page Index Toggle Pages: 1