54 using FarseerPhysics.Dynamics;
55 using Microsoft.Xna.Framework;
57 using System.Collections.Generic;
84 double length = System.Math.Sqrt(
X *
X + Y * Y);
109 public double a = 0, b = 0, c = 0;
173 Edges =
new List<GraphEdge>();
176 Vector2 midPoint = Vector2.Zero;
177 foreach (Vector2 vertex
in vertices)
181 midPoint /= vertices.Length;
183 for (
int i = 0; i < vertices.Length; i++)
185 GraphEdge ge =
new GraphEdge(vertices[i], vertices[MathUtils.PositiveModulo(i + 1, vertices.Length)]);
186 System.Diagnostics.Debug.Assert(ge.
Point1 != ge.Point2);
196 Edges =
new List<GraphEdge>();
208 if (MathUtils.LineSegmentsIntersect(transformedPoint,
Center -
Translation, edge.
Point1, edge.Point2)) {
return false; }
216 Vector2 max = transformedPoint + Vector2.One * margin;
217 Vector2 min = transformedPoint - Vector2.One * margin;
219 if (
Edges.All(e => e.Point1.X < min.X && e.Point2.X < min.X)) {
return false; }
220 if (
Edges.All(e => e.Point1.Y < min.Y && e.Point2.Y < min.Y)) {
return false; }
221 if (
Edges.All(e => e.Point1.X > max.X && e.Point2.X > max.X)) {
return false; }
222 if (
Edges.All(e => e.Point1.Y > max.Y && e.Point2.Y > max.Y)) {
return false; }
240 get {
return (
Point1 + Point2) / 2.0f; }
245 this.Point1 = point1;
246 this.Point2 = point2;
255 else if (Cell2 == cell)
268 Vector2 dir = Vector2.Normalize(
Point1 - Point2);
269 Vector2 normal =
new Vector2(dir.Y, -dir.X);
279 return "GraphEdge (" +
Point1.ToString() +
", " + Point2.ToString() +
")";
290 if ( s1.Y < s2.Y )
return -1;
291 if ( s1.Y > s2.Y )
return 1;
292 if ( s1.
X < s2.
X )
return -1;
293 if ( s1.
X > s2.
X )
return 1;
void SetPoint(double x, double y)
DoubleVector2(double x, double y)
override string ToString()
GraphEdge(Vector2 point1, Vector2 point2)
VoronoiCell AdjacentCell(VoronoiCell cell)
Vector2 GetNormal(VoronoiCell cell)
Returns the normal of the edge that points outwards from the specified cell
void SetPoint(Vector2 point)
int Compare(Site p1, Site p2)
VoronoiCell(Vector2[] vertices)
Action OnDestroyed
Executed when the cell is destroyed (only applies to destructible level walls)
bool IsPointInsideAABB(Vector2 point2, float margin)
List< Vector2 > BodyVertices
bool IsPointInside(Vector2 point)