mr-crocs-adventures/js/geometry/GeometryCircle.js

20 lines
451 B
JavaScript
Raw Permalink Normal View History

2020-01-19 00:45:17 +01:00
import GeometryPoint from "./GeometryPoint.js";
export default class GeometryCircle
{
constructor(x, y, radius)
{
this.position = new GeometryPoint(x, y);
this.radius = radius;
}
getDistanceToCircle(circle)
{
return this.position.getDistanceToPoint(circle.position);
}
hasIntersectionWithCircle(circle)
{
return this.getDistanceToCircle(circle) <= this.radius + circle.radius;
}
}