33using System.Runtime.InteropServices;
39 [AdvBrowsableOrder(
"Position,Radius")]
40#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE
56 result.Position.X = (rect.Min.X + rect.Max.X) * .5f;
57 result.Position.Y = (rect.Min.Y + rect.Max.Y) * .5f;
58 Scalar xRadius = (rect.Max.X - rect.Min.X) * .5f;
59 Scalar yRadius = (rect.Max.Y - rect.Min.Y) * .5f;
60 result.Radius =
MathHelper.
Sqrt(xRadius * xRadius + yRadius * yRadius);
72 for (
int index = 0; index < vertexes.Length; ++index)
76 if (result.Radius == -1 || (distSq < result.Radius))
78 result.Radius = distSq;
88 [InstanceConstructor(
"Position,Radius")]
91 this.Position = position;
147 if (-distance >= circle.
Radius)
151 else if (distance > circle.
Radius)
164 if (-distance >= circle.Radius)
168 else if (distance > circle.Radius)
217 if (polygon ==
null) {
throw new ArgumentNullException(
"polygon"); }
218 Vector2D[] vertexes = polygon.Vertexes;
220 for (
int index = 0; index < vertexes.Length && result !=
ContainmentType.Intersects; ++index)
223 Contains(ref vertexes[index], out con);
229 polygon.Intersects(ref
this, out test);
280 Vector2D rayOriginRelativeToCircle2D;
285 if ((MagSq <= radiusSq) && !discardInside)
290 Scalar a = ray.Direction.MagnitudeSq;
291 Scalar b = 2 * rayOriginRelativeToCircle2D * ray.Direction;
292 Scalar c = MagSq - radiusSq;
316 line.GetDistance(ref
Position, out distance);
317 result = Math.Abs(distance) <=
Radius;
323 result = (distance + line.D) <=
Radius;
337 result = distSq <= (
Radius *
Radius + circle.Radius * circle.Radius);
341 polygon.Intersects(ref
this, out result);
360 return Equals(ref
this, ref other);
364 return Equals(ref circle1, ref circle2);
369 return Vector2D.
Equals(ref circle1.Position, ref circle2.Position) && circle1.Radius == circle2.Radius;
373 return Equals(ref circle1, ref circle2);
377 return !
Equals(ref circle1, ref circle2);
static Vector2D GetCentroid(Vector2D[] vertexes)
Calculates the Centroid of a polygon.
static bool Intersects(Vector2D[] vertexes1, Vector2D[] vertexes2)
static bool TrySolveQuadratic(Scalar a, Scalar b, Scalar c, out Scalar plus, out Scalar minus)
Trys to Solve for x in the equation: (a * (x * x) + b * x + c == 0)
static void Sort(Scalar value1, Scalar value2, out Scalar max, out Scalar min)
static Scalar Sqrt(Scalar d)
override string ToString()
ContainmentType Contains(BoundingCircle circle)
static BoundingCircle FromRectangle(BoundingRectangle rect)
static BoundingCircle FromVectors(Vector2D[] vertexes)
void GetDistance(ref Vector2D point, out Scalar result)
static bool operator==(BoundingCircle circle1, BoundingCircle circle2)
Scalar GetDistance(Vector2D point)
bool Intersects(LineSegment line)
bool Equals(BoundingCircle other)
static void FromRectangle(ref BoundingRectangle rect, out BoundingCircle result)
void Intersects(ref BoundingPolygon polygon, out bool result)
bool Intersects(Line line)
override int GetHashCode()
void Contains(ref BoundingRectangle rect, out ContainmentType result)
static bool operator!=(BoundingCircle circle1, BoundingCircle circle2)
void Intersects(ref Ray ray, out Scalar result)
void Intersects(ref Ray ray, bool discardInside, out Scalar result)
static void FromVectors(Vector2D[] vertexes, out BoundingCircle result)
void Intersects(ref LineSegment line, out bool result)
void Contains(ref BoundingCircle circle, out ContainmentType result)
ContainmentType Contains(BoundingRectangle rect)
void Contains(ref BoundingPolygon polygon, out ContainmentType result)
static bool Equals(ref BoundingCircle circle1, ref BoundingCircle circle2)
void Intersects(ref BoundingCircle circle, out bool result)
void Intersects(ref Line line, out bool result)
ContainmentType Contains(BoundingPolygon polygon)
static bool Equals(BoundingCircle circle1, BoundingCircle circle2)
bool Intersects(BoundingCircle circle)
ContainmentType Contains(Vector2D point)
void Intersects(ref BoundingRectangle rect, out bool result)
BoundingCircle(Scalar x, Scalar y, Scalar radius)
BoundingCircle(Vector2D position, Scalar radius)
bool Intersects(BoundingPolygon polygon)
Scalar Intersects(Ray ray)
override bool Equals(object obj)
bool Intersects(BoundingRectangle rect)
void Contains(ref Vector2D point, out ContainmentType result)
This is the Vector Class.
const int Size
The Size of the class in bytes;
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.
static Vector2D Clamp(Vector2D value, Vector2D min, Vector2D max)
Binds a value to
static Scalar DistanceSq(Vector2D left, Vector2D right)
Scalar MagnitudeSq
Gets the Squared Magnitude of the Vector2D.
override int GetHashCode()
Provides a unique hash code based on the member variables of this class. This should be done because ...
static Vector2D Subtract(Vector2D left, Vector2D right)
Subtracts 2 Vector2Ds.
Scalar Y
This is the Y value. (Usually represents a vertical position or direction.)
override bool Equals(object obj)
Compares this Vector to another object. This should be done because the equality operators (==,...
static Vector2D Max(Vector2D value1, Vector2D value2)
static Vector2D Min(Vector2D value1, Vector2D value2)
static Scalar GetMagnitude(Vector2D source)
Gets the Magnitude of the Vector2D that is passed.