Class CollisionGm
- Namespace
- Gamem
- Assembly
- Gamem.dll
Provides static methods for basic 2D intersection and collision detection.
public static class CollisionGm
- Inheritance
-
CollisionGm
- Inherited Members
Methods
CheckAABBVsAABB(double, double, double, double, double, double, double, double)
Checks for an intersection between two Axis-Aligned Bounding Boxes (AABB).
public static bool CheckAABBVsAABB(double x1, double y1, double width1, double height1, double x2, double y2, double width2, double height2)
Parameters
x1doubleThe minimum X-coordinate (left edge) of the first box.
y1doubleThe minimum Y-coordinate (top/bottom edge) of the first box.
width1doubleThe total width of the first box.
height1doubleThe total height of the first box.
x2doubleThe minimum X-coordinate (left edge) of the second box.
y2doubleThe minimum Y-coordinate (top/bottom edge) of the second box.
width2doubleThe total width of the second box.
height2doubleThe total height of the second box.
Returns
- bool
True if the bounding boxes overlap or touch; otherwise, false.
CheckAABBVsAABB(Vector2, float, float, Vector2, float, float)
Checks for an intersection between two Axis-Aligned Bounding Boxes (AABB).
public static bool CheckAABBVsAABB(Vector2 box1, float width1, float height1, Vector2 box2, float width2, float height2)
Parameters
box1Vector2The first box.
width1floatThe total width of the first box.
height1floatThe total height of the first box.
box2Vector2The second box.
width2floatThe total width of the second box.
height2floatThe total height of the second box.
Returns
- bool
True if the bounding boxes overlap or touch; otherwise, false.
CheckAABBVsAABB(float, float, float, float, float, float, float, float)
Checks for an intersection between two Axis-Aligned Bounding Boxes (AABB).
public static bool CheckAABBVsAABB(float x1, float y1, float width1, float height1, float x2, float y2, float width2, float height2)
Parameters
x1floatThe minimum X-coordinate (left edge) of the first box.
y1floatThe minimum Y-coordinate (top/bottom edge) of the first box.
width1floatThe total width of the first box.
height1floatThe total height of the first box.
x2floatThe minimum X-coordinate (left edge) of the second box.
y2floatThe minimum Y-coordinate (top/bottom edge) of the second box.
width2floatThe total width of the second box.
height2floatThe total height of the second box.
Returns
- bool
True if the bounding boxes overlap or touch; otherwise, false.
CheckCircleVsAABB(double, double, double, double, double, double, double)
Checks for an intersection between a circle and an Axis-Aligned Bounding Box (AABB).
public static bool CheckCircleVsAABB(double circleX, double circleY, double radius, double aabbX, double aabbY, double width, double height)
Parameters
circleXdoubleThe X-coordinate of the circle's center.
circleYdoubleThe Y-coordinate of the circle's center.
radiusdoubleThe radius of the circle.
aabbXdoubleThe minimum X-coordinate (left edge) of the box.
aabbYdoubleThe minimum Y-coordinate (top/bottom edge) of the box.
widthdoubleThe total width of the box.
heightdoubleThe total height of the box.
Returns
- bool
True if the circle intersects or touches the bounding box; otherwise, false.
CheckCircleVsAABB(Vector2, float, Vector2, float, float)
Checks for an intersection between a circle and an Axis-Aligned Bounding Box (AABB).
public static bool CheckCircleVsAABB(Vector2 circle, float radius, Vector2 aabb, float width, float height)
Parameters
circleVector2The circle's center.
radiusfloatThe radius of the circle.
aabbVector2The minimum coordinate of the box.
widthfloatThe total width of the box.
heightfloatThe total height of the box.
Returns
- bool
True if the circle intersects or touches the bounding box; otherwise, false.
CheckCircleVsAABB(float, float, float, float, float, float, float)
Checks for an intersection between a circle and an Axis-Aligned Bounding Box (AABB).
public static bool CheckCircleVsAABB(float circleX, float circleY, float radius, float aabbX, float aabbY, float width, float height)
Parameters
circleXfloatThe X-coordinate of the circle's center.
circleYfloatThe Y-coordinate of the circle's center.
radiusfloatThe radius of the circle.
aabbXfloatThe minimum X-coordinate (left edge) of the box.
aabbYfloatThe minimum Y-coordinate (top/bottom edge) of the box.
widthfloatThe total width of the box.
heightfloatThe total height of the box.
Returns
- bool
True if the circle intersects or touches the bounding box; otherwise, false.
CheckCircleVsCircle(double, double, double, double, double, double)
Checks for an intersection between two circles.
public static bool CheckCircleVsCircle(double x1, double y1, double radius1, double x2, double y2, double radius2)
Parameters
x1doubleThe X-coordinate of the first circle's center.
y1doubleThe Y-coordinate of the first circle's center.
radius1doubleThe radius of the first circle.
x2doubleThe X-coordinate of the second circle's center.
y2doubleThe Y-coordinate of the second circle's center.
radius2doubleThe radius of the second circle.
Returns
- bool
True if the circles intersect or touch; otherwise, false.
CheckCircleVsCircle(Vector2, float, Vector2, float)
Checks for an intersection between two circles.
public static bool CheckCircleVsCircle(Vector2 center1, float radius1, Vector2 center2, float radius2)
Parameters
center1Vector2The first circle's center.
radius1floatThe radius of the first circle.
center2Vector2The second circle's center.
radius2floatThe radius of the second circle.
Returns
- bool
True if the circles intersect or touch; otherwise, false.
CheckCircleVsCircle(float, float, float, float, float, float)
Checks for an intersection between two circles.
public static bool CheckCircleVsCircle(float x1, float y1, float radius1, float x2, float y2, float radius2)
Parameters
x1floatThe X-coordinate of the first circle's center.
y1floatThe Y-coordinate of the first circle's center.
radius1floatThe radius of the first circle.
x2floatThe X-coordinate of the second circle's center.
y2floatThe Y-coordinate of the second circle's center.
radius2floatThe radius of the second circle.
Returns
- bool
True if the circles intersect or touch; otherwise, false.
CheckSegmentVsSegment(double, double, double, double, double, double, double, double)
Determines whether two 2D line segments intersect each other.
public static bool CheckSegmentVsSegment(double p0X, double p0Y, double p1X, double p1Y, double p2X, double p2Y, double p3X, double p3Y)
Parameters
p0XdoubleThe X-coordinate of the first point of the first segment.
p0YdoubleThe Y-coordinate of the first point of the first segment.
p1XdoubleThe X-coordinate of the second point of the first segment.
p1YdoubleThe Y-coordinate of the second point of the first segment.
p2XdoubleThe X-coordinate of the first point of the second segment.
p2YdoubleThe Y-coordinate of the first point of the second segment.
p3XdoubleThe X-coordinate of the second point of the second segment.
p3YdoubleThe Y-coordinate of the second point of the second segment.
Returns
CheckSegmentVsSegment(Vector2, Vector2, Vector2, Vector2)
Determines whether two 2D line segments defined by vectors intersect each other.
public static bool CheckSegmentVsSegment(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3)
Parameters
p0Vector2The starting point of the first line segment.
p1Vector2The ending point of the first line segment.
p2Vector2The starting point of the second line segment.
p3Vector2The ending point of the second line segment.
Returns
CheckSegmentVsSegment(float, float, float, float, float, float, float, float)
Determines whether two 2D line segments intersect each other.
public static bool CheckSegmentVsSegment(float p0X, float p0Y, float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y)
Parameters
p0XfloatThe X-coordinate of the first point of the first segment.
p0YfloatThe Y-coordinate of the first point of the first segment.
p1XfloatThe X-coordinate of the second point of the first segment.
p1YfloatThe Y-coordinate of the second point of the first segment.
p2XfloatThe X-coordinate of the first point of the second segment.
p2YfloatThe Y-coordinate of the first point of the second segment.
p3XfloatThe X-coordinate of the second point of the second segment.
p3YfloatThe Y-coordinate of the second point of the second segment.