Table of Contents

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

x1 double

The minimum X-coordinate (left edge) of the first box.

y1 double

The minimum Y-coordinate (top/bottom edge) of the first box.

width1 double

The total width of the first box.

height1 double

The total height of the first box.

x2 double

The minimum X-coordinate (left edge) of the second box.

y2 double

The minimum Y-coordinate (top/bottom edge) of the second box.

width2 double

The total width of the second box.

height2 double

The 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

box1 Vector2

The first box.

width1 float

The total width of the first box.

height1 float

The total height of the first box.

box2 Vector2

The second box.

width2 float

The total width of the second box.

height2 float

The 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

x1 float

The minimum X-coordinate (left edge) of the first box.

y1 float

The minimum Y-coordinate (top/bottom edge) of the first box.

width1 float

The total width of the first box.

height1 float

The total height of the first box.

x2 float

The minimum X-coordinate (left edge) of the second box.

y2 float

The minimum Y-coordinate (top/bottom edge) of the second box.

width2 float

The total width of the second box.

height2 float

The 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

circleX double

The X-coordinate of the circle's center.

circleY double

The Y-coordinate of the circle's center.

radius double

The radius of the circle.

aabbX double

The minimum X-coordinate (left edge) of the box.

aabbY double

The minimum Y-coordinate (top/bottom edge) of the box.

width double

The total width of the box.

height double

The 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

circle Vector2

The circle's center.

radius float

The radius of the circle.

aabb Vector2

The minimum coordinate of the box.

width float

The total width of the box.

height float

The 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

circleX float

The X-coordinate of the circle's center.

circleY float

The Y-coordinate of the circle's center.

radius float

The radius of the circle.

aabbX float

The minimum X-coordinate (left edge) of the box.

aabbY float

The minimum Y-coordinate (top/bottom edge) of the box.

width float

The total width of the box.

height float

The 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

x1 double

The X-coordinate of the first circle's center.

y1 double

The Y-coordinate of the first circle's center.

radius1 double

The radius of the first circle.

x2 double

The X-coordinate of the second circle's center.

y2 double

The Y-coordinate of the second circle's center.

radius2 double

The 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

center1 Vector2

The first circle's center.

radius1 float

The radius of the first circle.

center2 Vector2

The second circle's center.

radius2 float

The 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

x1 float

The X-coordinate of the first circle's center.

y1 float

The Y-coordinate of the first circle's center.

radius1 float

The radius of the first circle.

x2 float

The X-coordinate of the second circle's center.

y2 float

The Y-coordinate of the second circle's center.

radius2 float

The 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

p0X double

The X-coordinate of the first point of the first segment.

p0Y double

The Y-coordinate of the first point of the first segment.

p1X double

The X-coordinate of the second point of the first segment.

p1Y double

The Y-coordinate of the second point of the first segment.

p2X double

The X-coordinate of the first point of the second segment.

p2Y double

The Y-coordinate of the first point of the second segment.

p3X double

The X-coordinate of the second point of the second segment.

p3Y double

The Y-coordinate of the second point of the second segment.

Returns

bool

true if the two line segments intersect; otherwise, false.

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

p0 Vector2

The starting point of the first line segment.

p1 Vector2

The ending point of the first line segment.

p2 Vector2

The starting point of the second line segment.

p3 Vector2

The ending point of the second line segment.

Returns

bool

true if the two line segments intersect; otherwise, false.

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

p0X float

The X-coordinate of the first point of the first segment.

p0Y float

The Y-coordinate of the first point of the first segment.

p1X float

The X-coordinate of the second point of the first segment.

p1Y float

The Y-coordinate of the second point of the first segment.

p2X float

The X-coordinate of the first point of the second segment.

p2Y float

The Y-coordinate of the first point of the second segment.

p3X float

The X-coordinate of the second point of the second segment.

p3Y float

The Y-coordinate of the second point of the second segment.

Returns

bool

true if the two line segments intersect; otherwise, false.