Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I calculate the average direction of two vectors

I am writing an opengl based iphone app and would like to allow a user to translate around a view based on the direction that they move two fingers on the screen. For one finger I know I could just calculate the vector from the start position to the current position of the users finger and then find the unit vector of this to get just the direction, but I don't know how I would do this for two fingers, I don't think adding the components of the vectors and calculating the average would work so I'm pretty much stuck.

like image 698
Mike Broughton Avatar asked Feb 19 '09 18:02

Mike Broughton


1 Answers

Vector math works just like you think:

v3 = (v1 + v2)/2

// so:
v3.x = (v1.x + v2.x) / 2;
// same for Y and Z
like image 150
Alex Wayne Avatar answered Oct 04 '22 02:10

Alex Wayne