26#ifndef __SHAPE_CIRCLE_H
27#define __SHAPE_CIRCLE_H
29#include <geometry/shape.h>
30#include <geometry/circle.h>
32#include <math/vector2d.h>
46 m_circle( aCenter, aRadius )
56 m_circle( aOther.m_circle )
69 const BOX2I BBox(
int aClearance = 0 )
const override
76 bool Collide(
const SEG& aSeg,
int aClearance = 0,
int* aActual =
nullptr,
77 VECTOR2I* aLocation =
nullptr )
const override
79 int minDist = aClearance + m_circle.
Radius;
81 ecoord dist_sq = ( pn - m_circle.
Center ).SquaredEuclideanNorm();
83 if( dist_sq == 0 || dist_sq < SEG::Square( minDist ) )
89 *aActual = std::max( 0, (
int) sqrt( dist_sq ) - m_circle.
Radius );
97 void SetRadius(
int aRadius )
102 void SetCenter(
const VECTOR2I& aCenter )
104 m_circle.
Center = aCenter;
107 int GetRadius()
const
117 const CIRCLE GetCircle()
const
122 void Move(
const VECTOR2I& aVector )
override
124 m_circle.
Center += aVector;
129 m_circle.
Center -= aCenter;
131 m_circle.
Center += aCenter;
134 bool IsSolid()
const override
Represent basic circle geometry with utility geometry functions.
Definition circle.h:33
VECTOR2I Center
Public to make access simpler.
Definition circle.h:116
int Radius
Public to make access simpler.
Definition circle.h:115
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
Definition seg.cpp:227
Definition shape_circle.h:37
bool Collide(const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance,...
Definition shape_circle.h:76
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Definition shape_circle.h:69
SHAPE * Clone() const override
Return a dynamically allocated copy of the shape.
Definition shape_circle.h:62
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Definition shape_circle.h:127
An abstract shape on 2D plane.
Definition shape.h:117
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
Definition vector2d.h:365