35#if !(WINDOWS_PHONE || XBOX || NETFX_CORE)
48 if (
vertexes ==
null) {
throw new ArgumentNullException(
"vertexes"); }
49 if (
vertexes.Length < 3) {
throw new ArgumentOutOfRangeException(
"vertexes"); }
55 for (
int index = 0; index <
vertexes.Length; ++index, v1 = v2)
58 t1 = (v1.
Y <= point.Y);
59 if (t1 ^ (v2.
Y <= point.Y))
61 temp = ((point.Y - v1.
Y) * (v2.
X - v1.
X) - (point.X - v1.
X) * (v2.
Y - v1.
Y));
62 if (t1) {
if (temp > 0) { count++; } }
63 else {
if (temp < 0) { count--; } }
77 if (
vertexes ==
null) {
throw new ArgumentNullException(
"vertexes"); }
78 if (
vertexes.Length < 3) {
throw new ArgumentOutOfRangeException(
"vertexes"); }
82 for (
int index = 0; index <
vertexes.Length; index++, v1 = v2)
85 if (((v1.
Y <= point.Y) ^ (v2.
Y <= point.Y)) ||
86 (v1.
Y == point.Y) || (v2.
Y == point.Y))
88 Scalar xIntersection = (v1.
X + ((point.Y - v1.
Y) / (v2.
Y - v1.
Y)) * (v2.
X - v1.
X));
89 if (point.X < xIntersection)
93 else if (xIntersection == point.X)
111 if (vertexes1 ==
null) {
throw new ArgumentNullException(
"vertexes1"); }
112 if (vertexes2 ==
null) {
throw new ArgumentNullException(
"vertexes2"); }
113 if (vertexes1.Length < 2) {
throw new ArgumentOutOfRangeException(
"vertexes1"); }
114 if (vertexes2.Length < 2) {
throw new ArgumentOutOfRangeException(
"vertexes2"); }
117 v1 = vertexes1[vertexes1.Length - 1];
118 v3 = vertexes2[vertexes2.Length - 1];
120 for (
int index1 = 0; index1 < vertexes1.Length; ++index1, v1 = v2)
122 v2 = vertexes1[index1];
123 for (
int index2 = 0; index2 < vertexes2.Length; ++index2, v3 = v4)
125 v4 = vertexes2[index2];
127 if (result) {
return; }
166 if (
vertexes ==
null) {
throw new ArgumentNullException(
"vertexes"); }
167 if (
vertexes.Length < 3) {
throw new ArgumentOutOfRangeException(
"vertexes"); }
172 for (
int index = 0; index <
vertexes.Length; ++index, v1 = v2)
175 bool t1 = (v1.
Y <= point.Y);
176 if (t1 ^ (v2.
Y <= point.Y))
178 Scalar temp = ((point.Y - v1.
Y) * (v2.
X - v1.
X) - (point.X - v1.
X) * (v2.
Y - v1.
Y));
179 if (t1) {
if (temp > 0) { count++; } }
180 else {
if (temp < 0) { count--; } }
184 if (distance < goodDistance) { goodDistance = distance; }
218 if (
vertexes ==
null) {
throw new ArgumentNullException(
"vertexes"); }
219 if (
vertexes.Length < 3) {
throw new ArgumentOutOfRangeException(
"vertexes",
"There must be at least 3 vertexes"); }
225 for (
int index = 0; index <
vertexes.Length; ++index, v1 = v2)
230 centroid.X += ((v1.X + v2.X) * temp);
231 centroid.Y += ((v1.Y + v2.Y) * temp);
233 temp = 1 / (Math.Abs(area) * 3);
255 if (
vertexes ==
null) {
throw new ArgumentNullException(
"vertexes"); }
256 if (
vertexes.Length < 3) {
throw new ArgumentOutOfRangeException(
"vertexes",
"There must be at least 3 vertexes"); }
261 for (
int index = 0; index <
vertexes.Length; ++index, v1 = v2)
267 result = Math.Abs(area * .5f);
278 if (
vertexes ==
null) {
throw new ArgumentNullException(
"vertexes"); }
279 if (
vertexes.Length < 3) {
throw new ArgumentOutOfRangeException(
"vertexes",
"There must be at least 3 vertexes"); }
284 for (
int index = 0; index <
vertexes.Length; ++index, v1 = v2)
300 if (
vertexes ==
null) {
throw new ArgumentNullException(
"vertexes"); }
301 if (
vertexes.Length == 0) {
throw new ArgumentOutOfRangeException(
"vertexes"); }
313 for (
int index = 0; index <
vertexes.Length; index++, v1 = v2)
322 denom += (a + b + c) * d;
324 result = denom / (numer * 6);
330 if (
vertexes ==
null) {
throw new ArgumentNullException(
"vertexes"); }
331 if (
vertexes.Length < 3) {
throw new ArgumentOutOfRangeException(
"vertexes"); }
390 distance += circle.Radius;
395 else if (distance <= circle.Radius)
413 Contains(rect.Corners(), out result);
424 if (polygon ==
null) {
throw new ArgumentNullException(
"polygon"); }
425 Contains(polygon.vertexes, out result);
431 for (
int index = 0; index <
vertexes.Length; ++index)
436 for (
int index = 0; index < otherVertexes.Length && result !=
ContainmentType.Intersects; ++index)
444 Intersects(this.vertexes, otherVertexes, out test);
477 for (
int index = 0; index <
vertexes.Length; ++index)
479 int index2 = (index + 1) %
vertexes.Length;
482 if (temp >= 0 && (result == -1 || temp < result))
490 Intersects(this.vertexes, rect.Corners(), out result);
495 for (
int index = 0; index <
vertexes.Length; ++index)
497 int index2 = (index + 1) %
vertexes.Length;
500 if (temp <= circle.Radius)
509 if (polygon ==
null) {
throw new ArgumentNullException(
"polygon"); }
510 Intersects(this.vertexes, polygon.vertexes, out result);
static Scalar GetDistance(Vector2D[] vertexes, Vector2D point)
void Contains(ref BoundingCircle circle, out ContainmentType result)
ContainmentType Contains(Vector2D point)
static Scalar GetInertia(Vector2D[] vertexes)
void GetDistance(ref Vector2D point, out Scalar result)
Scalar GetDistance(Vector2D point)
void Intersects(ref BoundingCircle circle, out bool result)
static Vector2D GetCentroid(Vector2D[] vertexes)
Calculates the Centroid of a polygon.
static Scalar GetArea(Vector2D[] vertexes)
Calculates the area of a polygon.
ContainmentType Contains(BoundingRectangle rect)
bool Intersects(BoundingCircle circle)
void Contains(ref BoundingPolygon polygon, out ContainmentType result)
ContainmentType Contains(BoundingPolygon polygon)
void Contains(ref Vector2D point, out ContainmentType result)
static void ContainsInclusive(Vector2D[] vertexes, ref Vector2D point, out ContainmentType result)
static void GetPerimeter(Vector2D[] vertexes, out Scalar result)
static ContainmentType ContainsInclusive(Vector2D[] vertexes, Vector2D point)
static ContainmentType ContainsExclusive(Vector2D[] vertexes, Vector2D point)
static void GetCentroid(Vector2D[] vertexes, out Vector2D centroid)
Calculates the Centroid of a polygon.
void Contains(ref BoundingRectangle rect, out ContainmentType result)
static bool Intersects(Vector2D[] vertexes1, Vector2D[] vertexes2)
void Contains(Vector2D[] otherVertexes, out ContainmentType result)
void Intersects(ref Ray ray, out Scalar result)
static void Intersects(Vector2D[] vertexes1, Vector2D[] vertexes2, out bool result)
ContainmentType Contains(BoundingCircle circle)
BoundingPolygon(Vector2D[] vertexes)
Scalar Intersects(Ray ray)
static void GetInertia(Vector2D[] vertexes, out Scalar result)
static void GetArea(Vector2D[] vertexes, out Scalar result)
Calculates the area of a polygon.
static void ContainsExclusive(Vector2D[] vertexes, ref Vector2D point, out ContainmentType result)
void Intersects(ref BoundingRectangle rect, out bool result)
void Intersects(ref BoundingPolygon polygon, out bool result)
bool Intersects(BoundingRectangle rect)
static void GetDistance(Vector2D[] vertexes, ref Vector2D point, out Scalar result)
static Scalar GetPerimeter(Vector2D[] vertexes)
bool Intersects(BoundingPolygon polygon)
static Scalar Sqrt(Scalar d)
static void Intersects(ref Vector2D v1, ref Vector2D v2, ref Vector2D v3, ref Vector2D v4, out bool result)
static void GetDistance(ref Vector2D vertex1, ref Vector2D vertex2, ref Vector2D point, out Scalar result)
static void GetDistanceSq(ref Vector2D vertex1, ref Vector2D vertex2, ref Vector2D point, out Scalar result)
This is the Vector Class.
static readonly Vector2D Zero
Vector2D(0,0)
static Scalar Distance(Vector2D left, Vector2D right)
Scalar X
This is the X value. (Usually represents a horizontal position or direction.)
static Scalar Dot(Vector2D left, Vector2D right)
Does a Dot Operation Also know as an Inner Product.
Scalar Y
This is the Y value. (Usually represents a vertical position or direction.)
static Scalar ZCross(Vector2D left, Vector2D right)
Does a "2D" Cross Product also know as an Outer Product.