static constexpr double CS_pid = 3.14159265358979323846;
class Circle
{
public:
Circle()
{
m_cx = m_cy = 0.0f;
m_r = 0.0;
}
Circle(float cx, float cy, double r)
{
m_cx = cx, m_cy = cy;
m_r = r;
}
float area()
{
return (float)(CS_pid * m_r * m_r);
}
float length()
{
return (float)(2.0 * CS_pid * m_r);
}
bool cross(const Circle& other)
{
float cent_dist_sqr = ((other.m_cx - m_cx) * (other.m_cx - m_cx)) + ((other.m_cy - m_cy) * (other.m_cy - m_cy));
return cent_dist_sqr < ((other.m_r + m_r) * (other.m_r + m_r));
}
void set(const Circle& other)
{
m_cx = other.m_cx, m_cy = other.m_cy;
m_r = other.m_r;
}
void get(Circle& other)
{
other.m_cx = m_cx, other.m_cy = m_cy;
other.m_r = m_r;
}
protected:
float m_cx, m_cy;
double m_r;
};