public bool QuerySidePositive(ref AAB2 box, float epsilon = 1E-05f) { Vector2 vector; vector.x = this.Direction.y; vector.y = -this.Direction.x; Vector2 a; if (vector.x >= 0f) { a.x = box.Min.x; } else { a.x = box.Max.x; } if (vector.y >= 0f) { a.y = box.Min.y; } else { a.y = box.Max.y; } return(vector.Dot(a - this.Center) >= -epsilon); }
public static AAB2 CreateFromPoints(Vector2[] points) { int num = points.Length; if (num > 0) { AAB2 result = AAB2.CreateFromPoint(ref points[0]); for (int i = 1; i < num; i++) { result.Include(ref points[i]); } return(result); } return(default(AAB2)); }
public static AAB2 CreateFromPoints(IList <Vector2> points) { int count = points.Count; if (count > 0) { AAB2 result = AAB2.CreateFromPoint(points[0]); for (int i = 1; i < count; i++) { result.Include(points[i]); } return(result); } return(default(AAB2)); }
public static Circle2 CreateFromPointsAAB(IList <Vector2> points) { if (points.Count == 0) { return(default(Circle2)); } Vector2 center; Vector2 vector; AAB2.CreateFromPoints(points).CalcCenterExtents(out center, out vector); Circle2 result; result.Center = center; result.Radius = vector.magnitude; return(result); }
public static AAB2 CreateFromPoints(IEnumerable <Vector2> points) { IEnumerator <Vector2> enumerator = points.GetEnumerator(); enumerator.Reset(); if (!enumerator.MoveNext()) { return(default(AAB2)); } AAB2 result = AAB2.CreateFromPoint(enumerator.Current); while (enumerator.MoveNext()) { result.Include(enumerator.Current); } return(result); }
public static Circle2 CreateFromPointsAAB(IEnumerable <Vector2> points) { IEnumerator <Vector2> enumerator = points.GetEnumerator(); enumerator.Reset(); if (!enumerator.MoveNext()) { return(default(Circle2)); } Vector2 center; Vector2 vector; AAB2.CreateFromPoints(points).CalcCenterExtents(out center, out vector); Circle2 result; result.Center = center; result.Radius = vector.magnitude; return(result); }
public int QuerySide(ref AAB2 box, float epsilon = 1E-05f) { Vector2 vector; vector.x = this.Direction.y; vector.y = -this.Direction.x; Vector2 a; Vector2 a2; if (vector.x >= 0f) { a.x = box.Min.x; a2.x = box.Max.x; } else { a.x = box.Max.x; a2.x = box.Min.x; } if (vector.y >= 0f) { a.y = box.Min.y; a2.y = box.Max.y; } else { a.y = box.Max.y; a2.y = box.Min.y; } if (vector.Dot(a - this.Center) > -epsilon) { return(1); } if (vector.Dot(a2 - this.Center) < epsilon) { return(-1); } return(0); }
public static AAB2 CreateFromTwoPoints(Vector2 point0, Vector2 point1) { return(AAB2.CreateFromTwoPoints(ref point0, ref point1)); }
public void Include(AAB2 box) { this.Include(ref box.Min); this.Include(ref box.Max); }
public Box2(AAB2 box) { box.CalcCenterExtents(out this.Center, out this.Extents); this.Axis0 = Vector2ex.UnitX; this.Axis1 = Vector2ex.UnitY; }