 |
Jypeli
9
The simple game programming library
|
Siirry tämän tiedoston dokumentaatioon.
33 using 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;
283 Scalar MagSq = rayOriginRelativeToCircle2D.MagnitudeSq;
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 BoundingCircle FromRectangle(BoundingRectangle rect)
static Scalar Sqrt(Scalar d)
void Intersects(ref Ray ray, out Scalar result)
void Intersects(ref BoundingPolygon polygon, out bool result)
static Vector2D Clamp(Vector2D value, Vector2D min, Vector2D max)
Binds a value to
bool Intersects(BoundingPolygon polygon)
override int GetHashCode()
static Vector2D Subtract(Vector2D left, Vector2D right)
Subtracts 2 Vector2Ds.
static void FromRectangle(ref BoundingRectangle rect, out BoundingCircle result)
static bool Equals(BoundingCircle circle1, BoundingCircle circle2)
ContainmentType Contains(BoundingCircle circle)
static Vector2D Min(Vector2D value1, Vector2D value2)
void Intersects(ref BoundingCircle circle, out bool result)
void Contains(ref Vector2D point, out ContainmentType result)
Scalar GetDistance(Vector2D point)
ContainmentType Contains(BoundingPolygon polygon)
void Contains(ref BoundingRectangle rect, out ContainmentType result)
override int GetHashCode()
Provides a unique hash code based on the member variables of this class. This should be done because ...
static bool operator!=(BoundingCircle circle1, BoundingCircle circle2)
static Scalar DistanceSq(Vector2D left, Vector2D right)
static Vector2D GetCentroid(Vector2D[] vertexes)
Calculates the Centroid of a polygon.
BoundingCircle(Vector2D position, Scalar radius)
override string ToString()
bool Intersects(BoundingCircle circle)
static BoundingCircle FromVectors(Vector2D[] vertexes)
void Intersects(ref BoundingRectangle rect, out bool result)
static bool Intersects(Vector2D[] vertexes1, Vector2D[] vertexes2)
ContainmentType Contains(Vector2D point)
void Intersects(ref LineSegment line, out bool result)
Scalar Intersects(Ray ray)
bool Intersects(BoundingRectangle rect)
Scalar X
This is the X value. (Usually represents a horizontal position or direction.)
void Contains(ref BoundingPolygon polygon, out ContainmentType result)
BoundingCircle(Scalar x, Scalar y, Scalar radius)
static Scalar GetMagnitude(Vector2D source)
Gets the Magnitude of the Vector2D that is passed.
static Scalar Dot(Vector2D left, Vector2D right)
Does a Dot Operation Also know as an Inner Product.
override bool Equals(object obj)
Compares this Vector to another object. This should be done because the equality operators (==,...
bool Equals(BoundingCircle other)
static bool Equals(ref BoundingCircle circle1, ref BoundingCircle circle2)
bool Intersects(Line line)
void Intersects(ref Ray ray, bool discardInside, out Scalar result)
static void Sort(Scalar value1, Scalar value2, out Scalar max, out Scalar min)
static bool operator==(BoundingCircle circle1, BoundingCircle circle2)
void GetDistance(ref Vector2D point, out Scalar result)
const int Size
The Size of the class in bytes;
bool Intersects(LineSegment line)
ContainmentType Contains(BoundingRectangle rect)
This is the Vector Class.
Scalar Y
This is the Y value. (Usually represents a vertical position or direction.)
override bool Equals(object obj)
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)
void Intersects(ref Line line, out bool result)
static Vector2D Max(Vector2D value1, Vector2D value2)
void Contains(ref BoundingCircle circle, out ContainmentType result)
static void FromVectors(Vector2D[] vertexes, out BoundingCircle result)