testPoint method

  1. @override
bool testPoint(
  1. Transform transform,
  2. Vector2 point
)
override

Test a point for containment in this shape. This only works for convex shapes.

xf should be the shape world transform. point should be in world coordinates.

Implementation

@override
bool testPoint(Transform transform, Vector2 point) {
  final q = transform.q;
  final tp = transform.p;
  final centerX = -(q.cos * position.x - q.sin * position.y + tp.x - point.x);
  final centerY = -(q.sin * position.x + q.cos * position.y + tp.y - point.y);

  return centerX * centerX + centerY * centerY <= radius * radius;
}