Asteroids
Jump to navigation
Jump to search
- 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 or line intersections of the two
- 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 or line intersections of the two
- Finding the intersecting polygon
Will run faster if you only examine times when one vertex crosses an edge of the other polygon