2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
24 #include "../design/BoundingSphereConverter.h"
\r
27 #include "Vector3.h"
\r
31 value class BoundingBox;
\r
36 /// A bounding sphere, specified by a center vector and a radius.
\r
38 /// <unmanaged>None</unmanaged>
\r
39 [System::Serializable]
\r
40 [System::Runtime::InteropServices::StructLayout( System::Runtime::InteropServices::LayoutKind::Sequential )]
\r
41 [System::ComponentModel::TypeConverter( SlimDX::Design::BoundingSphereConverter::typeid )]
\r
42 public value class BoundingSphere : System::IEquatable<BoundingSphere>
\r
46 /// Specifies the center point of the sphere.
\r
51 /// The radius of the sphere.
\r
56 /// Initializes a new instance of the <see cref="BoundingSphere"/> structure.
\r
58 /// <param name="center">The center of the bounding sphere.</param>
\r
59 /// <param name="radius">The radius of the sphere.</param>
\r
60 BoundingSphere( Vector3 center, float radius );
\r
63 /// Determines whether the sphere contains the specified box.
\r
65 /// <param name="sphere">The sphere that will be checked for containment.</param>
\r
66 /// <param name="box">The box that will be checked for containment.</param>
\r
67 /// <returns>A member of the <see cref="ContainmentType"/> enumeration indicating whether the two objects intersect, are contained, or don't meet at all.</returns>
\r
68 static ContainmentType Contains( BoundingSphere sphere, BoundingBox box );
\r
71 /// Determines whether the sphere contains the specified sphere.
\r
73 /// <param name="sphere1">The first sphere that will be checked for containment.</param>
\r
74 /// <param name="sphere2">The second sphere that will be checked for containment.</param>
\r
75 /// <returns>A member of the <see cref="ContainmentType"/> enumeration indicating whether the two objects intersect, are contained, or don't meet at all.</returns>
\r
76 static ContainmentType Contains( BoundingSphere sphere1, BoundingSphere sphere2 );
\r
79 /// Determines whether the sphere contains the specified point.
\r
81 /// <param name="sphere">The sphere that will be checked for containment.</param>
\r
82 /// <param name="vector">The point that will be checked for containment.</param>
\r
83 /// <returns>A member of the <see cref="ContainmentType"/> enumeration indicating whether the two objects intersect, are contained, or don't meet at all.</returns>
\r
84 static ContainmentType Contains( BoundingSphere sphere, Vector3 vector );
\r
87 /// Constructs a <see cref="BoundingSphere"/> from a given box.
\r
89 /// <param name="box">The box that will designate the extents of the sphere.</param>
\r
90 /// <returns>The newly constructed bounding sphere.</returns>
\r
91 static BoundingSphere FromBox( BoundingBox box );
\r
94 /// Constructs a <see cref="BoundingSphere"/> that fully contains the given points.
\r
96 /// <param name="points">The points that will be contained by the sphere.</param>
\r
97 /// <returns>The newly constructed bounding sphere.</returns>
\r
98 static BoundingSphere FromPoints( array<Vector3>^ points );
\r
101 /// Constructs a <see cref="BoundingSphere"/> that is the as large as the total combined area of the two specified spheres.
\r
103 /// <param name="sphere1">The first sphere to merge.</param>
\r
104 /// <param name="sphere2">The second sphere to merge.</param>
\r
105 /// <returns>The newly constructed bounding sphere.</returns>
\r
106 static BoundingSphere Merge( BoundingSphere sphere1, BoundingSphere sphere2 );
\r
109 /// Determines whether a sphere intersects the specified object.
\r
111 /// <param name="sphere">The sphere which will be tested for intersection.</param>
\r
112 /// <param name="box">The box that will be tested for intersection.</param>
\r
113 /// <returns><c>true</c> if the two objects are intersecting; otherwise, <c>false</c>.</returns>
\r
114 static bool Intersects( BoundingSphere sphere, BoundingBox box );
\r
117 /// Determines whether a sphere intersects the specified object.
\r
119 /// <param name="sphere1">The first sphere which will be tested for intersection.</param>
\r
120 /// <param name="sphere2">The second sphere that will be tested for intersection.</param>
\r
121 /// <returns><c>true</c> if the two objects are intersecting; otherwise, <c>false</c>.</returns>
\r
122 static bool Intersects( BoundingSphere sphere1, BoundingSphere sphere2 );
\r
125 /// Determines whether a sphere intersects the specified object.
\r
127 /// <param name="sphere">The sphere which will be tested for intersection.</param>
\r
128 /// <param name="ray">The ray that will be tested for intersection.</param>
\r
129 /// <param name="distance">When the method completes, contains the distance from the ray's origin in which the intersection with the sphere occured.</param>
\r
130 /// <returns><c>true</c> if the two objects are intersecting; otherwise, <c>false</c>.</returns>
\r
131 static bool Intersects( BoundingSphere sphere, Ray ray, [Out] float% distance );
\r
134 /// Finds the intersection between a plane and a sphere.
\r
136 /// <param name="sphere">The sphere to check for intersection.</param>
\r
137 /// <param name="plane">The source plane.</param>
\r
138 /// <returns>A value from the <see cref="PlaneIntersectionType"/> enumeration describing the result of the intersection test.</returns>
\r
139 static PlaneIntersectionType Intersects( BoundingSphere sphere, Plane plane );
\r
142 /// Tests for equality between two objects.
\r
144 /// <param name="left">The first value to compare.</param>
\r
145 /// <param name="right">The second value to compare.</param>
\r
146 /// <returns><c>true</c> if <paramref name="left"/> has the same value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>
\r
147 static bool operator == ( BoundingSphere left, BoundingSphere right );
\r
150 /// Tests for inequality between two objects.
\r
152 /// <param name="left">The first value to compare.</param>
\r
153 /// <param name="right">The second value to compare.</param>
\r
154 /// <returns><c>true</c> if <paramref name="left"/> has a different value than <paramref name="right"/>; otherwise, <c>false</c>.</returns>
\r
155 static bool operator != ( BoundingSphere left, BoundingSphere right );
\r
158 /// Converts the value of the object to its equivalent string representation.
\r
160 /// <returns>The string representation of the value of this instance.</returns>
\r
161 virtual System::String^ ToString() override;
\r
164 /// Returns the hash code for this instance.
\r
166 /// <returns>A 32-bit signed integer hash code.</returns>
\r
167 virtual int GetHashCode() override;
\r
170 /// Returns a value that indicates whether the current instance is equal to a specified object.
\r
172 /// <param name="obj">Object to make the comparison with.</param>
\r
173 /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns>
\r
174 virtual bool Equals( System::Object^ obj ) override;
\r
177 /// Returns a value that indicates whether the current instance is equal to the specified object.
\r
179 /// <param name="other">Object to make the comparison with.</param>
\r
180 /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns>
\r
181 virtual bool Equals( BoundingSphere other );
\r
184 /// Determines whether the specified object instances are considered equal.
\r
186 /// <param name="value1"></param>
\r
187 /// <param name="value2"></param>
\r
188 /// <returns><c>true</c> if <paramref name="value1"/> is the same instance as <paramref name="value2"/> or
\r
189 /// if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>
\r
190 static bool Equals( BoundingSphere% value1, BoundingSphere% value2 );
\r