Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multitouch and Collision Detection MOBILE SOFTWARE DEVELOPMENT.

Similar presentations


Presentation on theme: "Multitouch and Collision Detection MOBILE SOFTWARE DEVELOPMENT."— Presentation transcript:

1 Multitouch and Collision Detection MOBILE SOFTWARE DEVELOPMENT

2 2 Contents  Multipoint Rotations  Point in Polygon  Algorithm  Readings

3 3 Multipoint Rotation  Simple Idea: easy to get 1 or more points from touch screen  Get points  Calculate angle between points  Rotate object / shape based on calculated angle  Rotate actual points instead of bitmap  Linear equations: slope, + little bit of trigonometry

4 4 Multipoint Rotation  Recall slope m of a graph is  Recall  Use arctan (inverse tan) to determine angle theta  Rotate object by that angle

5 5 Point in Polygon  Want to determine whether x,y point is inside a closed polygon

6 6 Point in Polygon  Can use ray casting algorithm – go right or left OR bottom to top  If odd number of intersections then point is inside  If even number of intersections then point is outside

7 7 Point in Polygon  Also works for complicated cases  Can be minor precision issues with floating point numbers  Need to use Maths to calculate  Polygon must be closed

8 8 Algorithm  Consider polygon segment by segment  Use linear equations  Origin point (0,0) starts at the top left corner of screen  Find out if point is on the inside of the polygon  Does line segment intersect ray cast from point?  Do this for all polygon segments

9 9 Point must be in range  x 1, y 1 - x 2, y 2

10 10 Point must be in range  x 1, y 1 - x 2, y 2

11 11 Does line segment intersect ray?  See lecture notes below if you want to understand maths behind it  http://www.cs.princeton.edu/~rs/AlgsDS07/16Geometric.pdf http://www.cs.princeton.edu/~rs/AlgsDS07/16Geometric.pdf

12 12 Resources  Point in Polygon  http://paulbourke.net/geometry/insidepoly/ http://paulbourke.net/geometry/insidepoly/  http://rosettacode.org/wiki/Ray-casting_algorithm http://rosettacode.org/wiki/Ray-casting_algorithm  http://www.cs.princeton.edu/~rs/AlgsDS07/16Geome tric.pdf http://www.cs.princeton.edu/~rs/AlgsDS07/16Geome tric.pdf


Download ppt "Multitouch and Collision Detection MOBILE SOFTWARE DEVELOPMENT."

Similar presentations


Ads by Google