Skip to content

Segment

Struct

Source: CollisionTypes.h

Description

Represents a 2D line segment for collision detection.

Properties

NameTypeDescription
x1pixelroot32::math::ScalarStart X coordinate.
y1pixelroot32::math::ScalarStart Y coordinate.
x2pixelroot32::math::ScalarEnd X coordinate.
y2pixelroot32::math::ScalarEnd Y coordinate.

Methods

bool intersects(const Circle& a, const Circle& b)

Description:

Checks intersection between two circles.

Parameters:

  • a: First circle.
  • b: Second circle.

Returns: True if circles intersect.

bool intersects(const Circle& c, const pixelroot32::core::Rect& r)

Description:

Checks intersection between a circle and a rectangle.

Parameters:

  • c: The circle.
  • r: The rectangle.

Returns: True if they intersect.

bool intersects(const Segment& s, const pixelroot32::core::Rect& r)

Description:

Checks intersection between a line segment and a rectangle.

Parameters:

  • s: The line segment.
  • r: The rectangle.

Returns: True if they intersect.

bool sweepCircleVsRect(const Circle& start, const Circle& end, const pixelroot32::core::Rect& rect, pixelroot32::math::Scalar& tHit)

Description:

Sweeps a circle against a rectangle to find time of impact.

Parameters:

  • start: Circle start position.
  • end: Circle end position.
  • rect: The static rectangle.
  • tHit: Reference to store the time of impact.

Returns: True if a hit occurs along the sweep path.

Released under the MIT License.