Asteroids: Difference between revisions
Jump to navigation
Jump to search
imported>Kmk21 Created page with "#fix one of the polygons and adjust the other one's path accordingly (just for simplicity) #Determine if the polygons ever intersect ##Calculate the path of every vertex on th..." |
imported>Kmk21 No edit summary |
||
Line 21: | Line 21: | ||
[[Category:Implementation Hard]] | [[Category:Implementation Hard]] | ||
[[Category:Cross Product]] | [[Category:Cross Product]] | ||
[[Category:Linear | [[Category:Linear Equations]] | ||
[[Category:Ternary Search]] | [[Category:Ternary Search]] | ||
[[Category:Kevin's Favorites]] | [[Category:Kevin's Favorites]] | ||
[[Category:Important Points]] | [[Category:Important Points]] |
Revision as of 06:31, 24 August 2016
- fix one of the polygons and adjust the other one's path accordingly (just for simplicity)
- Determine if the polygons ever intersect
- Calculate the path of every vertex on the moving polygon
- if every line passes on the same side of every vertex in the other polygon, they don't intersect
- use X-product to determine which side of line a point is on
- Compute the earliest and latest times any point on the moving polygon intersects a line on fixed polygon.
- Ternary search the area of intersection to find maximum. Area is computed by
- Finding the intersecting polygon
- Find all points of either polygon which are contained (inclusively) in the other
- use X-product and iterate over all edges of other polygon
- if sign is the same, point is contained
- Sort points by angle from minimum Y point to get ordering (or just run convex hull on them...we already know they're convex since intersection of two convex things is convex)
- run polygon area formula
- Find all points of either polygon which are contained (inclusively) in the other
- Finding the intersecting polygon
Will run faster if you only examine times when one vertex crosses an edge of the other polygon