Question

I'm working in c++, I'm using visual studio as the IDE, and I'm working with leap Leap Motion SDK

So, I'm currently working on a program that rotates a circle. The method for manipulating the rotation is applied by using two fingers that display as points on the application.

Also this application uses frames to display events over time.

I would like to know how to use two frames and two points to calculate change for rotation using the two points movements over the two frames.

const Frame frame = controller->frame();      //current frame
const Frame previous = controller->frame(1);  //previous frame

const FingerList fingers = frame.fingers();   //fingers inside that frame
POINT aFingerPoint = fingers[0].position()    //point of a finger from a finger array    
POINT anotherFingerPoint = fingers[1].position()    //point of a finger from a finger array

const FingerList prevFingers = previous.fingers();   //fingers inside that frame
POINT aPrevFingerPoint = fingers[0].position()    //point of a finger from a finger array    
POINT anotherPrevFingerPoint = fingers[1].position()    //point of a finger from a finger array

// coordinate example
float x = aFingerPoint.x;
float y = aFingerPoint.y; 

float deltaRotation = [THIS PART I DONT KNOW]; //I got the translation already, just need rotation
circle.manipulation(deltaRotation);  //Rotates the circle in degrees
Was it helpful?

Solution

A - point of first finger, A' - point of first finger after movement.

B - point of second finger, B' - point of second finger after movement.

If I understand you correctly your answer will be difference between angles ABx and A'B'x, where x - is x axis. It can be done easily with atan2(dy, dx) function from , where dx = Ax-Bx, dy = Ay-By.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top