void CalculateWorld(ShapeObject shapeA, ShapeObject shapeB, ShapeMatchType type) { Vector2 pointInWorld; Vector2D pointInWorld2D = Vector2D.Zero(); Polygon2D polyInWorld; foreach (Vector2D point in shapeA.pointsIn) { pointInWorld = shapeA.transform.TransformPoint(point.ToVector2()); pointInWorld2D.x = pointInWorld.x; pointInWorld2D.y = pointInWorld.y; polyInWorld = shapeB.GetWorldPolygon(); if (polyInWorld.PointInPoly(pointInWorld2D)) { pointsIn++; } } foreach (Vector2D point in shapeB.pointsIn) { pointInWorld = shapeB.transform.TransformPoint(point.ToVector2()); pointInWorld2D.x = pointInWorld.x; pointInWorld2D.y = pointInWorld.y; polyInWorld = shapeA.GetWorldPolygon(); if (polyInWorld.PointInPoly(pointInWorld2D)) { pointsIn++; } } }
public static void DrawMatch(ShapeObject shapeA, ShapeObject shapeB) { Vector2 pointInWorld; Vector2D pointInWorld2D = Vector2D.Zero(); Polygon2D polyInWorld; foreach (Vector2D point in shapeA.pointsIn) { pointInWorld = shapeA.transform.TransformPoint(point.ToVector2()); pointInWorld2D.x = pointInWorld.x; pointInWorld2D.y = pointInWorld.y; polyInWorld = shapeB.GetWorldPolygon(); if (polyInWorld.PointInPoly(pointInWorld2D)) { ShapeDraw.Draw(pointInWorld, shapeA.transform); } } foreach (Vector2D point in shapeB.pointsIn) { pointInWorld = shapeB.transform.TransformPoint(point.ToVector2()); pointInWorld2D.x = pointInWorld.x; pointInWorld2D.y = pointInWorld.y; polyInWorld = shapeA.GetWorldPolygon(); if (polyInWorld.PointInPoly(pointInWorld2D)) { ShapeDraw.Draw(pointInWorld, shapeB.transform); } } }