1 package de.lathanda.eos.game.geom;
3 import de.lathanda.eos.base.math.Vector;
4 import de.lathanda.eos.base.math.Range;
63 throw new RuntimeException(
"unknown outline typ!");
78 throw new RuntimeException(
"unknown outline typ!");
81 throw new RuntimeException(
"unknown outline typ!");
83 throw new RuntimeException(
"unknown outline typ!");
95 if (o.intersects(b)) {
109 private static boolean polygonPolygon(Polygon p1, Polygon p2) {
114 Range projectionA, projectionB;
119 for (
int i = 0; i < p1.n + p2.n; i++) {
131 p.coordinates_final_y[b] - p.coordinates_final_y[a],
132 p.coordinates_final_x[a] - p.coordinates_final_x[b]
135 projectionA = projectPolygon(v, p1);
136 projectionB = projectPolygon(v, p2);
139 if (!projectionA.overlap(projectionB)) {
155 private static Range projectPolygon(Vector axis, Polygon polygon) {
156 Range result =
new Range(0, 0);
157 double scalar = axis.dotProduct(polygon.coordinates_final_x[0],
158 polygon.coordinates_final_y[0]);
161 for (
int i = 1; i < polygon.n; i++) {
162 result.extend(axis.dotProduct(
163 polygon.coordinates_final_x[i],
164 polygon.coordinates_final_y[i])
177 private static boolean polygonCircle(Polygon p, Circle c) {
178 return p.getDistance(c.p) < c.radius;
188 private static boolean circleCircle(Circle c1, Circle c2) {
189 double dx = c2.p.getX() - c1.p.getX();
190 double dy = c2.p.getY() - c1.p.getY();
191 return (c1.radius + c2.radius) * (c1.radius + c2.radius) > dx * dx + dy * dy;
boolean contains(Point p)
static boolean intersects(Shape a, Shape b)
boolean contains(double x, double y)
ArrayList< Shape > getOutlines()
abstract Types getOutlineType()
boolean contains(Point p)