31 namespace SiliconStudio.Core.Mathematics
80 float d1 = Vector3.Dot(ab, ap);
81 float d2 = Vector3.Dot(ac, ap);
82 if (d1 <= 0.0f && d2 <= 0.0f)
87 float d3 = Vector3.Dot(ab, bp);
88 float d4 = Vector3.Dot(ac, bp);
89 if (d3 >= 0.0f && d4 <= d3)
93 float vc = d1 * d4 - d3 * d2;
94 if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f)
96 float v = d1 / (d1 - d3);
97 result = vertex1 + v * ab;
102 float d5 = Vector3.Dot(ab, cp);
103 float d6 = Vector3.Dot(ac, cp);
104 if (d6 >= 0.0f && d5 <= d6)
108 float vb = d5 * d2 - d1 * d6;
109 if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f)
111 float w = d2 / (d2 - d6);
112 result = vertex1 + w * ac;
116 float va = d3 * d6 - d5 * d4;
117 if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f)
119 float w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
120 result = vertex2 + w * (vertex3 - vertex2);
124 float denom = 1.0f / (va + vb + vc);
125 float v2 = vb * denom;
126 float w2 = vc * denom;
127 result = vertex1 + ab * v2 + ac * w2;
142 Vector3.Dot(ref plane.Normal, ref point, out dot);
143 float t = dot - plane.D;
145 result = point - (t * plane.Normal);
160 Vector3.Max(ref point, ref box.Minimum, out temp);
161 Vector3.Min(ref temp, ref box.Maximum, out result);
177 Vector3.Subtract(ref point, ref sphere.Center, out result);
182 result *= sphere.Radius;
185 result += sphere.Center;
206 Vector3.Subtract(ref sphere2.Center, ref sphere1.Center, out result);
211 result *= sphere1.Radius;
214 result += sphere1.Center;
229 Vector3.Dot(ref plane.Normal, ref point, out dot);
230 return dot - plane.D;
246 if (point.X < box.Minimum.X)
247 distance += (box.Minimum.X - point.X) * (box.Minimum.X - point.X);
248 if (point.X > box.Maximum.X)
249 distance += (point.X - box.Maximum.X) * (point.X - box.Maximum.X);
251 if (point.Y < box.Minimum.Y)
252 distance += (box.Minimum.Y - point.Y) * (box.Minimum.Y - point.Y);
253 if (point.Y > box.Maximum.Y)
254 distance += (point.Y - box.Maximum.Y) * (point.Y - box.Maximum.Y);
256 if (point.Z < box.Minimum.Z)
257 distance += (box.Minimum.Z - point.Z) * (box.Minimum.Z - point.Z);
258 if (point.Z > box.Maximum.Z)
259 distance += (point.Z - box.Maximum.Z) * (point.Z - box.Maximum.Z);
261 return (
float)Math.Sqrt(distance);
278 if (box1.Minimum.X > box2.Maximum.X)
280 float delta = box2.Maximum.X - box1.Minimum.X;
281 distance += delta * delta;
283 else if (box2.Minimum.X > box1.Maximum.X)
285 float delta = box1.Maximum.X - box2.Minimum.X;
286 distance += delta * delta;
290 if (box1.Minimum.Y > box2.Maximum.Y)
292 float delta = box2.Maximum.Y - box1.Minimum.Y;
293 distance += delta * delta;
295 else if (box2.Minimum.Y > box1.Maximum.Y)
297 float delta = box1.Maximum.Y - box2.Minimum.Y;
298 distance += delta * delta;
302 if (box1.Minimum.Z > box2.Maximum.Z)
304 float delta = box2.Maximum.Z - box1.Minimum.Z;
305 distance += delta * delta;
307 else if (box2.Minimum.Z > box1.Maximum.Z)
309 float delta = box1.Maximum.Z - box2.Minimum.Z;
310 distance += delta * delta;
313 return (
float)Math.Sqrt(distance);
328 Vector3.Distance(ref sphere.Center, ref point, out distance);
329 distance -= sphere.Radius;
331 return Math.Max(distance, 0f);
346 Vector3.Distance(ref sphere1.Center, ref sphere2.Center, out distance);
347 distance -= sphere1.Radius + sphere2.Radius;
349 return Math.Max(distance, 0f);
364 Vector3.Subtract(ref ray.Position, ref point, out m);
368 float b = Vector3.Dot(m, ray.Direction);
371 if (c > 0f && b > 0f)
374 float discriminant = b * b - c;
376 if (discriminant < 0f)
407 Vector3.Cross(ref ray1.Direction, ref ray2.Direction, out cross);
408 float denominator = cross.Length();
411 if (Math.Abs(denominator) < MathUtil.ZeroTolerance)
414 if (Math.Abs(ray2.Position.X - ray1.Position.X) < MathUtil.ZeroTolerance &&
416 Math.Abs(ray2.Position.Z - ray1.Position.Z) < MathUtil.ZeroTolerance)
418 point = Vector3.Zero;
423 denominator = denominator * denominator;
426 float m11 = ray2.Position.X - ray1.Position.X;
427 float m12 = ray2.Position.Y - ray1.Position.Y;
428 float m13 = ray2.Position.Z - ray1.Position.Z;
429 float m21 = ray2.Direction.X;
430 float m22 = ray2.Direction.Y;
431 float m23 = ray2.Direction.Z;
446 m21 = ray1.Direction.X;
447 m22 = ray1.Direction.Y;
448 m23 = ray1.Direction.Z;
460 float s = dets / denominator;
461 float t = dett / denominator;
464 Vector3 point1 = ray1.Position + (s * ray1.Direction);
465 Vector3 point2 = ray2.Position + (t * ray2.Direction);
468 if (Math.Abs(point2.X - point1.
X) > MathUtil.ZeroTolerance ||
470 Math.Abs(point2.Z - point1.
Z) > MathUtil.ZeroTolerance)
472 point = Vector3.Zero;
494 Vector3.Dot(ref plane.Normal, ref ray.Direction, out direction);
496 if (Math.Abs(direction) < MathUtil.ZeroTolerance)
503 Vector3.Dot(ref plane.Normal, ref ray.Position, out position);
504 distance = (-plane.D - position) / direction;
534 if (!RayIntersectsPlane(ref ray, ref plane, out distance))
536 point = Vector3.Zero;
540 point = ray.Position + (ray.Direction * distance);
570 edge1.X = vertex2.X - vertex1.X;
571 edge1.Y = vertex2.Y - vertex1.Y;
572 edge1.Z = vertex2.Z - vertex1.Z;
575 edge2.X = vertex3.X - vertex1.X;
576 edge2.Y = vertex3.Y - vertex1.Y;
577 edge2.Z = vertex3.Z - vertex1.Z;
581 directioncrossedge2.X = (ray.Direction.Y * edge2.Z) - (ray.Direction.Z * edge2.
Y);
582 directioncrossedge2.Y = (ray.Direction.Z * edge2.X) - (ray.Direction.X * edge2.
Z);
583 directioncrossedge2.Z = (ray.Direction.X * edge2.Y) - (ray.Direction.Y * edge2.
X);
588 determinant = (edge1.X * directioncrossedge2.X) + (edge1.
Y * directioncrossedge2.
Y) + (edge1.Z * directioncrossedge2.Z);
599 float inversedeterminant = 1.0f / determinant;
603 distanceVector.X = ray.Position.X - vertex1.X;
604 distanceVector.Y = ray.Position.Y - vertex1.Y;
605 distanceVector.Z = ray.Position.Z - vertex1.Z;
608 triangleU = (distanceVector.X * directioncrossedge2.X) + (distanceVector.
Y * directioncrossedge2.
Y) + (distanceVector.Z * directioncrossedge2.Z);
609 triangleU *= inversedeterminant;
612 if (triangleU < 0f || triangleU > 1f)
620 distancecrossedge1.X = (distanceVector.Y * edge1.Z) - (distanceVector.
Z * edge1.
Y);
621 distancecrossedge1.Y = (distanceVector.Z * edge1.X) - (distanceVector.
X * edge1.
Z);
622 distancecrossedge1.Z = (distanceVector.X * edge1.Y) - (distanceVector.
Y * edge1.
X);
625 triangleV = ((ray.Direction.X * distancecrossedge1.X) + (ray.Direction.Y * distancecrossedge1.
Y)) + (ray.Direction.Z * distancecrossedge1.
Z);
626 triangleV *= inversedeterminant;
629 if (triangleV < 0f || triangleU + triangleV > 1f)
637 raydistance = (edge2.X * distancecrossedge1.X) + (edge2.
Y * distancecrossedge1.
Y) + (edge2.Z * distancecrossedge1.Z);
638 raydistance *= inversedeterminant;
641 if (raydistance < 0f)
647 distance = raydistance;
664 if (!RayIntersectsTriangle(ref ray, ref vertex1, ref vertex2, ref vertex3, out distance))
666 point = Vector3.Zero;
670 point = ray.Position + (ray.Direction * distance);
704 throw new ArgumentOutOfRangeException(
"normalAxis");
707 var rectanglePosition =
new Vector3(rectangleWorldMatrix.M41, rectangleWorldMatrix.M42, rectangleWorldMatrix.M43);
709 var normalRowStart = normalAxis << 2;
710 var plane =
new Plane(rectanglePosition,
new Vector3(rectangleWorldMatrix[normalRowStart], rectangleWorldMatrix[normalRowStart + 1], rectangleWorldMatrix[normalRowStart + 2]));
713 if (!plane.Intersects(ref ray, out intersectionPoint))
717 var intersectionInRectangle = intersectionPoint - rectanglePosition;
720 if (rectangleWorldMatrix.M12 == 0 && rectangleWorldMatrix.M13 == 0 &&
721 rectangleWorldMatrix.M21 == 0 && rectangleWorldMatrix.M23 == 0 &&
722 rectangleWorldMatrix.M31 == 0 && rectangleWorldMatrix.M32 == 0)
724 var halfSize1 = rectangleWorldMatrix[(testAxis1 << 2) + testAxis1] * rectangleSize[testAxis1] / 2f;
725 var halfSize2 = rectangleWorldMatrix[(testAxis2 << 2) + testAxis2] * rectangleSize[testAxis2] / 2f;
727 intersects = -halfSize1 <= intersectionInRectangle[testAxis1] && intersectionInRectangle[testAxis1] <= halfSize1 &&
728 -halfSize2 <= intersectionInRectangle[testAxis2] && intersectionInRectangle[testAxis2] <= halfSize2;
733 var normalTestIndex = 0;
734 for (
int i = 1; i < 3; i++)
736 if (Math.Abs(plane.Normal[i]) > Math.Abs(plane.Normal[normalTestIndex]))
739 var normalSign = Math.Sign(plane.Normal[normalTestIndex]);
742 var base1 = rectangleSize[testAxis1] *
new Vector3(rectangleWorldMatrix[(testAxis1 << 2)], rectangleWorldMatrix[(testAxis1 << 2) + 1], rectangleWorldMatrix[(testAxis1 << 2) + 2]) / 2;
743 var base2 = rectangleSize[testAxis2] *
new Vector3(rectangleWorldMatrix[(testAxis2 << 2)], rectangleWorldMatrix[(testAxis2 << 2) + 1], rectangleWorldMatrix[(testAxis2 << 2) + 2]) / 2;
746 var v1 = -base1 - base2 - intersectionInRectangle;
747 var v2 = +base1 - base2 - intersectionInRectangle;
748 var v3 = +base1 + base2 - intersectionInRectangle;
750 intersects = Math.Sign(Vector3.Cross(v1, v2)[normalTestIndex]) == normalSign &&
751 Math.Sign(Vector3.Cross(v2, v3)[normalTestIndex]) == normalSign &&
752 Math.Sign(Vector3.Cross(v3, v1)[normalTestIndex]) == normalSign;
759 v1 = -base1 - base2 - intersectionInRectangle;
760 v2 = +base1 + base2 - intersectionInRectangle;
761 v3 = -base1 + base2 - intersectionInRectangle;
763 intersects = Math.Sign(Vector3.Cross(v1, v2)[normalTestIndex]) == normalSign &&
764 Math.Sign(Vector3.Cross(v2, v3)[normalTestIndex]) == normalSign &&
765 Math.Sign(Vector3.Cross(v3, v1)[normalTestIndex]) == normalSign;
785 float tmax = float.MaxValue;
787 if (Math.Abs(ray.Direction.X) < MathUtil.ZeroTolerance)
789 if (ray.Position.X < box.Minimum.X || ray.Position.X > box.Maximum.X)
797 float inverse = 1.0f / ray.Direction.X;
798 float t1 = (box.Minimum.X - ray.Position.X) * inverse;
799 float t2 = (box.Maximum.X - ray.Position.X) * inverse;
808 distance = Math.Max(t1, distance);
809 tmax = Math.Min(t2, tmax);
818 if (Math.Abs(ray.Direction.Y) < MathUtil.ZeroTolerance)
820 if (ray.Position.Y < box.Minimum.Y || ray.Position.Y > box.Maximum.Y)
828 float inverse = 1.0f / ray.Direction.Y;
829 float t1 = (box.Minimum.Y - ray.Position.Y) * inverse;
830 float t2 = (box.Maximum.Y - ray.Position.Y) * inverse;
839 distance = Math.Max(t1, distance);
840 tmax = Math.Min(t2, tmax);
849 if (Math.Abs(ray.Direction.Z) < MathUtil.ZeroTolerance)
851 if (ray.Position.Z < box.Minimum.Z || ray.Position.Z > box.Maximum.Z)
859 float inverse = 1.0f / ray.Direction.Z;
860 float t1 = (box.Minimum.Z - ray.Position.Z) * inverse;
861 float t2 = (box.Maximum.Z - ray.Position.Z) * inverse;
870 distance = Math.Max(t1, distance);
871 tmax = Math.Min(t2, tmax);
894 if (!RayIntersectsBox(ref ray, ref box, out distance))
896 point = Vector3.Zero;
900 point = ray.Position + (ray.Direction * distance);
918 Vector3.Subtract(ref ray.Position, ref sphere.Center, out m);
920 float b = Vector3.Dot(m, ray.Direction);
921 float c = Vector3.Dot(m, m) - (sphere.Radius * sphere.Radius);
923 if (c > 0f && b > 0f)
929 float discriminant = b * b - c;
931 if (discriminant < 0f)
937 distance = -b - (float)Math.Sqrt(discriminant);
956 if (!RayIntersectsSphere(ref ray, ref sphere, out distance))
958 point = Vector3.Zero;
962 point = ray.Position + (ray.Direction * distance);
975 Vector3.Dot(ref plane.Normal, ref point, out distance);
979 return PlaneIntersectionType.Front;
982 return PlaneIntersectionType.Back;
984 return PlaneIntersectionType.Intersecting;
996 Vector3.Cross(ref plane1.Normal, ref plane2.Normal, out direction);
1001 Vector3.Dot(ref direction, ref direction, out denominator);
1003 if (Math.Abs(denominator) < MathUtil.ZeroTolerance)
1028 Vector3.Cross(ref plane1.Normal, ref plane2.Normal, out direction);
1033 Vector3.Dot(ref direction, ref direction, out denominator);
1038 if (Math.Abs(denominator) < MathUtil.ZeroTolerance)
1045 Vector3 temp = plane1.D * plane2.Normal - plane2.D * plane1.Normal;
1046 Vector3.Cross(ref temp, ref direction, out point);
1048 line.Position = point;
1049 line.Direction = direction;
1050 line.Direction.Normalize();
1073 return PlaneIntersectionType.Front;
1076 return PlaneIntersectionType.Back;
1078 return PlaneIntersectionType.Intersecting;
1095 max.X = (plane.Normal.X >= 0.0f) ? box.Minimum.
X : box.Maximum.X;
1096 max.
Y = (plane.Normal.Y >= 0.0f) ? box.Minimum.Y : box.Maximum.Y;
1097 max.Z = (plane.Normal.Z >= 0.0f) ? box.Minimum.Z : box.Maximum.Z;
1098 min.
X = (plane.Normal.X >= 0.0f) ? box.Maximum.X : box.Minimum.X;
1099 min.Y = (plane.Normal.Y >= 0.0f) ? box.Maximum.Y : box.Minimum.Y;
1100 min.
Z = (plane.Normal.Z >= 0.0f) ? box.Maximum.Z : box.Minimum.Z;
1103 Vector3.Dot(ref plane.Normal, ref max, out distance);
1105 if (distance + plane.D > 0.0f)
1106 return PlaneIntersectionType.Front;
1108 distance = Vector3.Dot(plane.Normal, min);
1110 if (distance + plane.D < 0.0f)
1111 return PlaneIntersectionType.Back;
1113 return PlaneIntersectionType.Intersecting;
1128 Vector3.Dot(ref plane.Normal, ref sphere.Center, out distance);
1129 distance += plane.D;
1131 if (distance > sphere.Radius)
1132 return PlaneIntersectionType.Front;
1134 if (distance < -sphere.Radius)
1135 return PlaneIntersectionType.Back;
1137 return PlaneIntersectionType.Intersecting;
1149 public static bool BoxIntersectsTriangle(ref BoundingBox box, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
1151 if (BoxContainsPoint(ref box, ref vertex1) == ContainmentType.Contains)
1154 if (BoxContainsPoint(ref box, ref vertex2) == ContainmentType.Contains)
1157 if (BoxContainsPoint(ref box, ref vertex3) == ContainmentType.Contains)
1172 if (box1.Minimum.X > box2.Maximum.X || box2.Minimum.X > box1.Maximum.X)
1175 if (box1.Minimum.Y > box2.Maximum.Y || box2.Minimum.Y > box1.Maximum.Y)
1178 if (box1.Minimum.Z > box2.Maximum.Z || box2.Minimum.Z > box1.Maximum.Z)
1196 Vector3.Clamp(ref sphere.Center, ref box.Minimum, ref box.Maximum, out vector);
1197 float distance = Vector3.DistanceSquared(sphere.Center, vector);
1199 return distance <= sphere.Radius * sphere.Radius;
1216 ClosestPointPointTriangle(ref sphere.Center, ref vertex1, ref vertex2, ref vertex3, out point);
1217 Vector3 v = point - sphere.Center;
1220 Vector3.Dot(ref v, ref v, out dot);
1222 return dot <= sphere.Radius * sphere.Radius;
1233 float radiisum = sphere1.Radius + sphere2.Radius;
1234 return Vector3.DistanceSquared(sphere1.Center, sphere2.Center) <= radiisum * radiisum;
1245 if (box.Minimum.X <= point.X && box.Maximum.X >= point.X &&
1246 box.Minimum.Y <= point.Y && box.Maximum.Y >= point.Y &&
1247 box.Minimum.Z <= point.Z && box.Maximum.Z >= point.Z)
1249 return ContainmentType.Contains;
1252 return ContainmentType.Disjoint;
1264 public static ContainmentType BoxContainsTriangle(ref BoundingBox box, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
1266 ContainmentType test1 = BoxContainsPoint(ref box, ref vertex1);
1267 ContainmentType test2 = BoxContainsPoint(ref box, ref vertex2);
1268 ContainmentType test3 = BoxContainsPoint(ref box, ref vertex3);
1270 if (test1 == ContainmentType.Contains && test2 == ContainmentType.Contains && test3 == ContainmentType.Contains)
1271 return ContainmentType.Contains;
1273 if (test1 == ContainmentType.Contains || test2 == ContainmentType.Contains || test3 == ContainmentType.Contains)
1274 return ContainmentType.Intersects;
1276 return ContainmentType.Disjoint;
1288 if (box1.Maximum.X < box2.Minimum.X || box1.Minimum.X > box2.Maximum.X)
1289 return ContainmentType.Disjoint;
1291 if (box1.Maximum.Y < box2.Minimum.Y || box1.Minimum.Y > box2.Maximum.Y)
1292 return ContainmentType.Disjoint;
1294 if (box1.Maximum.Z < box2.Minimum.Z || box1.Minimum.Z > box2.Maximum.Z)
1295 return ContainmentType.Disjoint;
1297 if (box1.Minimum.X <= box2.Minimum.X && (box2.Maximum.X <= box1.Maximum.X &&
1298 box1.Minimum.Y <= box2.Minimum.Y && box2.Maximum.Y <= box1.Maximum.Y) &&
1299 box1.Minimum.Z <= box2.Minimum.Z && box2.Maximum.Z <= box1.Maximum.Z)
1301 return ContainmentType.Contains;
1304 return ContainmentType.Intersects;
1316 Vector3.Clamp(ref sphere.Center, ref box.Minimum, ref box.Maximum, out vector);
1317 float distance = Vector3.DistanceSquared(sphere.Center, vector);
1319 if (distance > sphere.Radius * sphere.Radius)
1320 return ContainmentType.Disjoint;
1322 if ((((box.Minimum.X + sphere.Radius <= sphere.Center.X) && (sphere.Center.X <= box.Maximum.X - sphere.Radius)) && ((box.Maximum.X - box.Minimum.X > sphere.Radius) &&
1323 (box.Minimum.Y + sphere.Radius <= sphere.Center.Y))) && (((sphere.Center.Y <= box.Maximum.Y - sphere.Radius) && (box.Maximum.Y - box.Minimum.Y > sphere.Radius)) &&
1324 (((box.Minimum.Z + sphere.Radius <= sphere.Center.Z) && (sphere.Center.Z <= box.Maximum.Z - sphere.Radius)) && (box.Maximum.X - box.Minimum.X > sphere.Radius))))
1326 return ContainmentType.Contains;
1329 return ContainmentType.Intersects;
1364 return ContainmentType.Contains;
1366 if (SphereIntersectsTriangle(ref sphere, ref vertex1, ref vertex2, ref vertex3))
1367 return ContainmentType.Intersects;
1369 return ContainmentType.Disjoint;
1382 if (!BoxIntersectsSphere(ref box, ref sphere))
1383 return ContainmentType.Disjoint;
1385 float radiussquared = sphere.Radius * sphere.Radius;
1386 vector.X = sphere.Center.X - box.Minimum.X;
1387 vector.Y = sphere.Center.Y - box.Maximum.Y;
1388 vector.Z = sphere.Center.Z - box.Maximum.Z;
1393 vector.
X = sphere.Center.X - box.Maximum.X;
1394 vector.
Y = sphere.Center.Y - box.Maximum.Y;
1395 vector.
Z = sphere.Center.Z - box.Maximum.Z;
1400 vector.
X = sphere.Center.X - box.Maximum.X;
1401 vector.
Y = sphere.Center.Y - box.Minimum.Y;
1402 vector.
Z = sphere.Center.Z - box.Maximum.Z;
1407 vector.
X = sphere.Center.X - box.Minimum.X;
1408 vector.
Y = sphere.Center.Y - box.Minimum.Y;
1409 vector.
Z = sphere.Center.Z - box.Maximum.Z;
1414 vector.
X = sphere.Center.X - box.Minimum.X;
1415 vector.
Y = sphere.Center.Y - box.Maximum.Y;
1416 vector.
Z = sphere.Center.Z - box.Minimum.Z;
1421 vector.
X = sphere.Center.X - box.Maximum.X;
1422 vector.
Y = sphere.Center.Y - box.Maximum.Y;
1423 vector.
Z = sphere.Center.Z - box.Minimum.Z;
1428 vector.
X = sphere.Center.X - box.Maximum.X;
1429 vector.
Y = sphere.Center.Y - box.Minimum.Y;
1430 vector.
Z = sphere.Center.Z - box.Minimum.Z;
1435 vector.
X = sphere.Center.X - box.Minimum.X;
1436 vector.
Y = sphere.Center.Y - box.Minimum.Y;
1437 vector.
Z = sphere.Center.Z - box.Minimum.Z;
1453 float distance = Vector3.Distance(sphere1.Center, sphere2.Center);
1455 if (sphere1.Radius + sphere2.Radius < distance)
1456 return ContainmentType.Disjoint;
1458 if (sphere1.Radius - sphere2.Radius < distance)
1459 return ContainmentType.Intersects;
1461 return ContainmentType.Contains;
1476 fixed (
Plane* planeStart = &frustum.Plane1)
1478 var plane = planeStart;
1479 for (
int i = 0; i < 6; ++i)
1482 + extent.X * Math.Abs(plane->Normal.X)
1483 + extent.Y * Math.Abs(plane->Normal.Y)
1484 + extent.Z * Math.Abs(plane->Normal.Z)
static ContainmentType BoxContainsSphere(ref BoundingBox box, ref BoundingSphere sphere)
Determines whether a SiliconStudio.Core.Mathematics.BoundingBox contains a SiliconStudio.Core.Mathematics.BoundingSphere.
static float DistanceSpherePoint(ref BoundingSphere sphere, ref Vector3 point)
Determines the distance between a SiliconStudio.Core.Mathematics.BoundingSphere and a point...
Represents an axis-aligned bounding box in three dimensional space.
static PlaneIntersectionType PlaneIntersectsBox(ref Plane plane, ref BoundingBox box)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Plane and a SiliconStudio.Core.Mathematics.BoundingBox.
static ContainmentType SphereContainsTriangle(ref BoundingSphere sphere, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
Determines whether a SiliconStudio.Core.Mathematics.BoundingSphere contains a triangle.
float Y
The Y component of the vector.
static bool RayIntersectsTriangle(ref Ray ray, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out float distance)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a triangle.
static bool PlaneIntersectsPlane(ref Plane plane1, ref Plane plane2)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Plane and a SiliconStudio.Core.Mathematics.Plane.
static void Dot(ref Vector3 left, ref Vector3 right, out float result)
Calculates the dot product of two vectors.
static bool RayIntersectsRay(ref Ray ray1, ref Ray ray2, out Vector3 point)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a SiliconStudio.Core.Mathematics.Ray.
static bool RayIntersectsPoint(ref Ray ray, ref Vector3 point)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a point.
static ContainmentType SphereContainsSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2)
Determines whether a SiliconStudio.Core.Mathematics.BoundingSphere contains a SiliconStudio.Core.Mathematics.BoundingSphere.
static void ClosestPointPlanePoint(ref Plane plane, ref Vector3 point, out Vector3 result)
Determines the closest point between a SiliconStudio.Core.Mathematics.Plane and a point...
static ContainmentType BoxContainsPoint(ref BoundingBox box, ref Vector3 point)
Determines whether a SiliconStudio.Core.Mathematics.BoundingBox contains a point. ...
float X
The X component of the vector.
static void ClosestPointSpherePoint(ref BoundingSphere sphere, ref Vector3 point, out Vector3 result)
Determines the closest point between a SiliconStudio.Core.Mathematics.BoundingSphere and a point...
const float ZeroTolerance
The value for which all absolute numbers smaller than are considered equal to zero.
Represents a three dimensional mathematical vector.
static bool RayIntersectsRectangle(ref Ray ray, ref Matrix rectangleWorldMatrix, ref Vector3 rectangleSize, int normalAxis, out Vector3 intersectionPoint)
Determines whether there is an intersection between a Ray and a rectangle (2D).
static bool BoxIntersectsSphere(ref BoundingBox box, ref BoundingSphere sphere)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.BoundingBox and a SiliconStudio.Core.Mathematics.BoundingSphere.
static bool RayIntersectsPlane(ref Ray ray, ref Plane plane, out Vector3 point)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a SiliconStudio.Core.Mathematics.Plane.
static bool RayIntersectsSphere(ref Ray ray, ref BoundingSphere sphere, out float distance)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a SiliconStudio.Core.Mathematics.BoundingSphere.
Represents a bounding sphere in three dimensional space.
static bool FrustumContainsBox(ref BoundingFrustum frustum, ref Vector3 center, ref Vector3 extent)
Determines whether a BoundingFrustum intersects or contains an AABB determined by its center and exte...
static bool RayIntersectsPlane(ref Ray ray, ref Plane plane, out float distance)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a SiliconStudio.Core.Mathematics.Plane.
Represents a plane in three dimensional space.
Contains static methods to help in determining intersections, containment, etc.
ContainmentType
Describes how one bounding volume contains another.
static ContainmentType SphereContainsPoint(ref BoundingSphere sphere, ref Vector3 point)
Determines whether a SiliconStudio.Core.Mathematics.BoundingSphere contains a point.
static bool RayIntersectsTriangle(ref Ray ray, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out Vector3 point)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a triangle.
static bool SphereIntersectsTriangle(ref BoundingSphere sphere, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.BoundingSphere and a triangle.
static PlaneIntersectionType PlaneIntersectsTriangle(ref Plane plane, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Plane and a triangle.
static float DistanceSphereSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2)
Determines the distance between a SiliconStudio.Core.Mathematics.BoundingSphere and a SiliconStudio...
static bool RayIntersectsBox(ref Ray ray, ref BoundingBox box, out float distance)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a SiliconStudio.Core.Mathematics.BoundingBox.
static void ClosestPointBoxPoint(ref BoundingBox box, ref Vector3 point, out Vector3 result)
Determines the closest point between a SiliconStudio.Core.Mathematics.BoundingBox and a point...
Represents a three dimensional line based on a point in space and a direction.
static bool RayIntersectsBox(ref Ray ray, ref BoundingBox box, out Vector3 point)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a SiliconStudio.Core.Mathematics.Plane.
static float DistancePlanePoint(ref Plane plane, ref Vector3 point)
Determines the distance between a SiliconStudio.Core.Mathematics.Plane and a point.
static void ClosestPointSphereSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2, out Vector3 result)
Determines the closest point between a SiliconStudio.Core.Mathematics.BoundingSphere and a SiliconStu...
PlaneIntersectionType
Describes the result of an intersection with a plane in three dimensions.
float LengthSquared()
Calculates the squared length of the vector.
static bool BoxIntersectsBox(ref BoundingBox box1, ref BoundingBox box2)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.BoundingBox and a SiliconStudio.Core.Mathematics.BoundingBox.
static void DistanceSquared(ref Vector3 value1, ref Vector3 value2, out float result)
Calculates the squared distance between two vectors.
static PlaneIntersectionType PlaneIntersectsPoint(ref Plane plane, ref Vector3 point)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Plane and a point.
static void ClosestPointPointTriangle(ref Vector3 point, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out Vector3 result)
Determines the closest point between a point and a triangle.
static ContainmentType SphereContainsBox(ref BoundingSphere sphere, ref BoundingBox box)
Determines whether a SiliconStudio.Core.Mathematics.BoundingSphere contains a SiliconStudio.Core.Mathematics.BoundingBox.
static bool RayIntersectsSphere(ref Ray ray, ref BoundingSphere sphere, out Vector3 point)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Ray and a SiliconStudio.Core.Mathematics.BoundingSphere.
SiliconStudio.Core.Mathematics.Vector3 Vector3
static float DistanceBoxPoint(ref BoundingBox box, ref Vector3 point)
Determines the distance between a SiliconStudio.Core.Mathematics.BoundingBox and a point...
static PlaneIntersectionType PlaneIntersectsSphere(ref Plane plane, ref BoundingSphere sphere)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Plane and a SiliconStudio.Core.Mathematics.BoundingSphere.
static float DistanceBoxBox(ref BoundingBox box1, ref BoundingBox box2)
Determines the distance between a SiliconStudio.Core.Mathematics.BoundingBox and a SiliconStudio...
float Z
The Z component of the vector.
static ContainmentType BoxContainsBox(ref BoundingBox box1, ref BoundingBox box2)
Determines whether a SiliconStudio.Core.Mathematics.BoundingBox contains a SiliconStudio.Core.Mathematics.BoundingBox.
static bool SphereIntersectsSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.BoundingSphere and a SiliconStudio.Core.Mathematics.BoundingSphere.
static bool PlaneIntersectsPlane(ref Plane plane1, ref Plane plane2, out Ray line)
Determines whether there is an intersection between a SiliconStudio.Core.Mathematics.Plane and a SiliconStudio.Core.Mathematics.Plane.
Represents a 4x4 mathematical matrix.