2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Base/Circle.hpp"
|
|
|
|
#include "Base/Shared.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Library/Random.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const Circle Circle::NIL = Circle();
|
|
|
|
const Circle Circle::MIN = Circle(0.0);
|
2016-02-20 23:25:00 +01:00
|
|
|
const Circle Circle::MAX = Circle(NumLimit< Circle::Value >::Max);
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQChar Circle::Delim = ',';
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle::Circle()
|
2015-09-30 02:56:11 +02:00
|
|
|
: pos(0.0, 0.0), rad(0.0)
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Circle::Circle(Value rv)
|
|
|
|
: pos(0.0, 0.0), rad(rv)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Circle::Circle(const Vector2 & pv, Value rv)
|
|
|
|
: pos(pv), rad(rv)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle::Circle(Value xv, Value yv, Value rv)
|
|
|
|
: pos(xv, yv), rad(rv)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Circle::Circle(const Circle & o)
|
|
|
|
: pos(o.pos), rad(o.rad)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Circle::~Circle()
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & Circle::operator = (const Circle & o)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
pos = o.pos;
|
|
|
|
rad = o.rad;
|
2015-09-30 02:56:11 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator = (Value r)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
rad = r;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & Circle::operator = (const Vector2 & p)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos = p;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator += (const Circle & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos += c.pos;
|
|
|
|
rad += c.rad;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator -= (const Circle & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos -= c.pos;
|
|
|
|
rad -= c.rad;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator *= (const Circle & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos *= c.pos;
|
|
|
|
rad *= c.rad;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator /= (const Circle & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos /= c.pos;
|
|
|
|
rad /= c.rad;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator %= (const Circle & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos %= c.pos;
|
2016-02-20 23:25:00 +01:00
|
|
|
rad = fmod(rad, c.rad);
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator += (Value r)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
rad += r;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator -= (Value r)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
rad -= r;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator *= (Value r)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
rad *= r;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator /= (Value r)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
rad /= r;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator %= (Value r)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
rad = fmod(rad, r);
|
2015-09-30 02:56:11 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & Circle::operator += (const Vector2 & p)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos += p;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & Circle::operator -= (const Vector2 & p)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos -= p;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & Circle::operator *= (const Vector2 & p)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos *= p;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & Circle::operator /= (const Vector2 & p)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos /= p;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & Circle::operator %= (const Vector2 & p)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos %= p;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator ++ ()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
++pos;
|
|
|
|
++rad;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & Circle::operator -- ()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
--pos;
|
|
|
|
--rad;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator ++ (int)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Circle state(*this);
|
|
|
|
++pos;
|
|
|
|
++rad;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator -- (int)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Circle state(*this);
|
|
|
|
--pos;
|
|
|
|
--rad;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator + (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Circle(pos + c.pos, rad + c.rad);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator - (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Circle(pos - c.pos, rad - c.rad);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator * (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Circle(pos * c.pos, rad * c.rad);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator / (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Circle(pos / c.pos, rad / c.rad);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator % (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Circle(pos % c.pos, fmod(rad, c.rad));
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator + (Value r) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Circle(rad + r);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator - (Value r) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Circle(rad - r);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator * (Value r) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Circle(rad * r);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator / (Value r) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Circle(rad / r);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator % (Value r) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Circle(fmod(rad, r));
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle Circle::operator + (const Vector2 & p) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Circle(pos + p, rad);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle Circle::operator - (const Vector2 & p) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Circle(pos - p, rad);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle Circle::operator * (const Vector2 & p) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Circle(pos * p, rad);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle Circle::operator / (const Vector2 & p) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Circle(pos / p, rad);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle Circle::operator % (const Vector2 & p) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Circle(pos % p, rad);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator + () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Circle(pos.Abs(), fabs(rad));
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::operator - () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Circle(-pos, -rad);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Circle::operator == (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return EpsEq(rad, c.rad) && (pos == c.pos);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Circle::operator != (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return !EpsEq(rad, c.rad) && (pos != c.pos);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Circle::operator < (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return EpsLt(rad, c.rad) && (pos < c.pos);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Circle::operator > (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return EpsGt(rad, c.rad) && (pos > c.pos);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Circle::operator <= (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return EpsLtEq(rad, c.rad) && (pos <= c.pos);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Circle::operator >= (const Circle & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return EpsGtEq(rad, c.rad) && (pos >= c.pos);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Circle::Cmp(const Circle & o) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (*this == o)
|
|
|
|
return 0;
|
|
|
|
else if (*this > o)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return -1;
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr Circle::ToString() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return ToStringF("%f,%f,%f", pos.x, pos.y, rad);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Circle::Set(Value nr)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
rad = nr;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
void Circle::Set(const Circle & nc)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos = nc.pos;
|
|
|
|
rad = nc.rad;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
void Circle::Set(const Vector2 & np)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos = np;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
void Circle::Set(const Vector2 & np, Value nr)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos = np;
|
|
|
|
rad = nr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Circle::Set(Value nx, Value ny)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos.Set(nx, ny);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
void Circle::Set(Value nx, Value ny, Value nr)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos.Set(nx, ny);
|
|
|
|
rad = nr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void Circle::Set(CSStr values, SQChar delim)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Set(GetCircle(values, delim));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Circle::Generate()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos.Generate();
|
2016-02-20 23:25:00 +01:00
|
|
|
rad = GetRandomFloat32();
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
void Circle::Generate(Value min, Value max, bool r)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (EpsLt(max, min))
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
SqThrow("max value is lower than min value");
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
else if (r)
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
rad = GetRandomFloat32(min, max);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos.Generate(min, max);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
pos.Generate(xmin, xmax, ymin, ymax);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (EpsLt(rmax, rmin))
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
SqThrow("max value is lower than min value");
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos.Generate(xmin, xmax, ymin, ymax);
|
2016-02-20 23:25:00 +01:00
|
|
|
rad = GetRandomFloat32(rmin, rmax);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle Circle::Abs() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Circle(pos.Abs(), fabs(rad));
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// ================================================================================================
|
|
|
|
void Register_Circle(HSQUIRRELVM vm)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
typedef Circle::Value Val;
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
RootTable(vm).Bind(_SC("Circle"), Class< Circle >(vm, _SC("Circle"))
|
|
|
|
/* Constructors */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Ctor()
|
2016-02-20 23:25:00 +01:00
|
|
|
.Ctor< Val >()
|
|
|
|
.Ctor< const Vector2 &, Val >()
|
|
|
|
.Ctor< Val, Val, Val >()
|
|
|
|
/* Static Members */
|
|
|
|
.SetStaticValue(_SC("Delim"), &Circle::Delim)
|
|
|
|
/* Member Variables */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Var(_SC("pos"), &Circle::pos)
|
|
|
|
.Var(_SC("rad"), &Circle::rad)
|
2016-02-20 23:25:00 +01:00
|
|
|
/* Properties */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Prop(_SC("abs"), &Circle::Abs)
|
2016-02-20 23:25:00 +01:00
|
|
|
/* Core Metamethods */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Func(_SC("_tostring"), &Circle::ToString)
|
|
|
|
.Func(_SC("_cmp"), &Circle::Cmp)
|
2016-02-20 23:25:00 +01:00
|
|
|
/* Metamethods */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_add"), &Circle::operator +)
|
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_sub"), &Circle::operator -)
|
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_mul"), &Circle::operator *)
|
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_div"), &Circle::operator /)
|
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_modulo"), &Circle::operator %)
|
|
|
|
.Func<Circle (Circle::*)(void) const>(_SC("_unm"), &Circle::operator -)
|
2016-02-20 23:25:00 +01:00
|
|
|
/* Setters */
|
|
|
|
.Overload<void (Circle::*)(const Circle &)>(_SC("Set"), &Circle::Set)
|
|
|
|
.Overload<void (Circle::*)(const Vector2 &, Val)>(_SC("Set"), &Circle::Set)
|
|
|
|
.Overload<void (Circle::*)(Val, Val, Val)>(_SC("Set"), &Circle::Set)
|
|
|
|
.Overload<void (Circle::*)(Val)>(_SC("SetRad"), &Circle::Set)
|
|
|
|
.Overload<void (Circle::*)(const Vector2 &)>(_SC("SetVec2"), &Circle::Set)
|
|
|
|
.Overload<void (Circle::*)(Val, Val)>(_SC("SetVec2"), &Circle::Set)
|
|
|
|
.Overload<void (Circle::*)(CSStr, SQChar)>(_SC("SetStr"), &Circle::Set)
|
|
|
|
/* Utility Methods */
|
|
|
|
.Func(_SC("Clear"), &Circle::Clear)
|
|
|
|
/* Operator Exposure */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opAddAssign"), &Circle::operator +=)
|
|
|
|
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opSubAssign"), &Circle::operator -=)
|
|
|
|
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opMulAssign"), &Circle::operator *=)
|
|
|
|
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opDivAssign"), &Circle::operator /=)
|
|
|
|
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opModAssign"), &Circle::operator %=)
|
|
|
|
|
|
|
|
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opAddAssignR"), &Circle::operator +=)
|
|
|
|
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opSubAssignR"), &Circle::operator -=)
|
|
|
|
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opMulAssignR"), &Circle::operator *=)
|
|
|
|
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opDivAssignR"), &Circle::operator /=)
|
|
|
|
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opModAssignR"), &Circle::operator %=)
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func<Circle & (Circle::*)(const Vector2 &)>(_SC("opAddAssignP"), &Circle::operator +=)
|
|
|
|
.Func<Circle & (Circle::*)(const Vector2 &)>(_SC("opSubAssignP"), &Circle::operator -=)
|
|
|
|
.Func<Circle & (Circle::*)(const Vector2 &)>(_SC("opMulAssignP"), &Circle::operator *=)
|
|
|
|
.Func<Circle & (Circle::*)(const Vector2 &)>(_SC("opDivAssignP"), &Circle::operator /=)
|
|
|
|
.Func<Circle & (Circle::*)(const Vector2 &)>(_SC("opModAssignP"), &Circle::operator %=)
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
.Func<Circle & (Circle::*)(void)>(_SC("opPreInc"), &Circle::operator ++)
|
|
|
|
.Func<Circle & (Circle::*)(void)>(_SC("opPreDec"), &Circle::operator --)
|
|
|
|
.Func<Circle (Circle::*)(int)>(_SC("opPostInc"), &Circle::operator ++)
|
|
|
|
.Func<Circle (Circle::*)(int)>(_SC("opPostDec"), &Circle::operator --)
|
|
|
|
|
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opAdd"), &Circle::operator +)
|
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opSub"), &Circle::operator -)
|
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opMul"), &Circle::operator *)
|
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opDiv"), &Circle::operator /)
|
|
|
|
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opMod"), &Circle::operator %)
|
|
|
|
|
|
|
|
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opAddR"), &Circle::operator +)
|
|
|
|
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opSubR"), &Circle::operator -)
|
|
|
|
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opMulR"), &Circle::operator *)
|
|
|
|
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opDivR"), &Circle::operator /)
|
|
|
|
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opModR"), &Circle::operator %)
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func<Circle (Circle::*)(const Vector2 &) const>(_SC("opAddP"), &Circle::operator +)
|
|
|
|
.Func<Circle (Circle::*)(const Vector2 &) const>(_SC("opSubP"), &Circle::operator -)
|
|
|
|
.Func<Circle (Circle::*)(const Vector2 &) const>(_SC("opMulP"), &Circle::operator *)
|
|
|
|
.Func<Circle (Circle::*)(const Vector2 &) const>(_SC("opDivP"), &Circle::operator /)
|
|
|
|
.Func<Circle (Circle::*)(const Vector2 &) const>(_SC("opModP"), &Circle::operator %)
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
.Func<Circle (Circle::*)(void) const>(_SC("opUnPlus"), &Circle::operator +)
|
|
|
|
.Func<Circle (Circle::*)(void) const>(_SC("opUnMinus"), &Circle::operator -)
|
|
|
|
|
|
|
|
.Func<bool (Circle::*)(const Circle &) const>(_SC("opEqual"), &Circle::operator ==)
|
|
|
|
.Func<bool (Circle::*)(const Circle &) const>(_SC("opNotEqual"), &Circle::operator !=)
|
|
|
|
.Func<bool (Circle::*)(const Circle &) const>(_SC("opLessThan"), &Circle::operator <)
|
|
|
|
.Func<bool (Circle::*)(const Circle &) const>(_SC("opGreaterThan"), &Circle::operator >)
|
|
|
|
.Func<bool (Circle::*)(const Circle &) const>(_SC("opLessEqual"), &Circle::operator <=)
|
|
|
|
.Func<bool (Circle::*)(const Circle &) const>(_SC("opGreaterEqual"), &Circle::operator >=)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|