2020-03-22 00:45:04 +01:00
|
|
|
#pragma once
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Base/Vector2.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Class used to represent a two-dimensional circle.
|
2015-09-30 02:56:11 +02:00
|
|
|
*/
|
|
|
|
struct Circle
|
|
|
|
{
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* The type of value used by components of type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
typedef float Value;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Helper instances for common values mostly used as return types or comparison.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
static const Circle NIL;
|
|
|
|
static const Circle MIN;
|
|
|
|
static const Circle MAX;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* The delimiter character to be used when extracting values from strings.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
static SQChar Delim;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* The position and radius components of this type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Vector2 pos{};
|
|
|
|
Value rad{0};
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Default constructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Circle() noexcept = default;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Construct a circle at position 0,0 using the specified radius.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
Circle(Value rv) noexcept; // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Construct a circle at the specified position using the specified radius.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
Circle(const Vector2 & pv, Value rv) noexcept;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Construct a circle at the specified position using the specified radius.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
Circle(Value xv, Value yv, Value rv) noexcept;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy constructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
Circle(const Circle & o) noexcept = default;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Move constructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
Circle(Circle && o) noexcept = default;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Destructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
~Circle() = default;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy assignment operator.
|
|
|
|
*/
|
|
|
|
Circle & operator = (const Circle & o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move assignment operator.
|
|
|
|
*/
|
|
|
|
Circle & operator = (Circle && o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Radius assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator = (Value r);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & operator = (const Vector2 & p);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Addition assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator += (const Circle & c);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Subtraction assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator -= (const Circle & c);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Multiplication assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator *= (const Circle & c);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Division assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator /= (const Circle & c);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Modulo assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator %= (const Circle & c);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius addition assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator += (Value r);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius subtraction assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator -= (Value r);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius multiplication assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator *= (Value r);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius division assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator /= (Value r);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius modulo assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator %= (Value r);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position addition assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & operator += (const Vector2 & p);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position subtraction assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & operator -= (const Vector2 & p);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position multiplication assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & operator *= (const Vector2 & p);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position division assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & operator /= (const Vector2 & p);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position modulo assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle & operator %= (const Vector2 & p);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Pre-increment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator ++ ();
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Pre-decrement operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle & operator -- ();
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Post-increment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
Circle operator ++ (int); // NOLINT(cert-dcl21-cpp)
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Post-decrement operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
Circle operator -- (int); // NOLINT(cert-dcl21-cpp)
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Addition operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator + (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Subtraction operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator - (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Multiplication operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator * (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Division operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator / (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Modulo operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator % (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius addition operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator + (Value r) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius subtraction operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator - (Value r) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius multiplication operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator * (Value r) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius division operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator / (Value r) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Radius modulo operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator % (Value r) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position addition operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle operator + (const Vector2 & p) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position subtraction operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle operator - (const Vector2 & p) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position multiplication operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle operator * (const Vector2 & p) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position division operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle operator / (const Vector2 & p) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Position modulo operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Circle operator % (const Vector2 & p) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Unary plus operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator + () const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Unary minus operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Circle operator - () const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Equality comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator == (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Inequality comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator != (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Less than comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator < (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Greater than comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator > (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Less than or equal comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator <= (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Greater than or equal comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator >= (const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to compare two instances of this type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int32_t Cmp(const Circle & c) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
2016-08-24 22:17:01 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to compare an instance of this type with a scalar value.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int32_t Cmp(SQFloat s) const
|
2016-08-24 22:17:01 +02:00
|
|
|
{
|
2016-08-25 00:01:03 +02:00
|
|
|
return Cmp(Circle(static_cast< Value >(s)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to compare an instance of this type with a scalar value.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int32_t Cmp(SQInteger s) const
|
2016-08-25 00:01:03 +02:00
|
|
|
{
|
|
|
|
return Cmp(Circle(static_cast< Value >(s)));
|
2016-08-24 22:17:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to compare an instance of this type with a scalar value.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int32_t Cmp(bool s) const
|
2016-08-24 22:17:01 +02:00
|
|
|
{
|
|
|
|
return Cmp(Circle(static_cast< Value >(s)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to compare an instance of this type with a scalar value.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int32_t Cmp(std::nullptr_t) const
|
2016-08-24 22:17:01 +02:00
|
|
|
{
|
|
|
|
return Cmp(Circle(static_cast< Value >(0)));
|
|
|
|
}
|
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to convert an instance of this type to a string.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD String ToString() const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
2022-09-18 14:02:39 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to convert an instance of this type to a JSON string.
|
|
|
|
*/
|
|
|
|
void ToJSON(CtxJSON & ctx) const;
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the specified radius.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 22:17:47 +02:00
|
|
|
void SetRadius(Value nr);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy the circle from another instance of this type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 22:17:47 +02:00
|
|
|
void SetCircle(const Circle & nc);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-07-24 23:32:35 +02:00
|
|
|
* Set the specified position and radius.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 23:32:35 +02:00
|
|
|
void SetCircleEx(Value nx, Value ny, Value nr);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Set the specified position and radius.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 22:17:47 +02:00
|
|
|
void SetValues(const Vector2 & np, Value nr);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Set the specified position.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 23:32:35 +02:00
|
|
|
void SetPosition(const Vector2 & np);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-07-24 23:32:35 +02:00
|
|
|
* Set the specified position.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 23:32:35 +02:00
|
|
|
void SetPositionEx(Value nx, Value ny);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Set the values extracted from the specified string using the specified delimiter.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2019-02-17 16:23:59 +01:00
|
|
|
void SetStr(SQChar delim, StackStrF & values);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Generate a randomly sized and positioned circle.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2021-03-20 16:56:38 +01:00
|
|
|
Circle & Generate();
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Generate a randomly sized or positioned circle within the specified bounds.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2021-03-20 16:56:38 +01:00
|
|
|
Circle & GenerateB(Value min, Value max, bool r);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Generate a randomly positioned circle within the specified bounds.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2021-03-20 16:56:38 +01:00
|
|
|
Circle & GenerateR(Value xmin, Value xmax, Value ymin, Value ymax);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Generate a randomly sized and positioned circle within the specified bounds.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2021-03-20 16:56:38 +01:00
|
|
|
Circle & GenerateR2(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Clear the component values to default.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
|
|
|
void Clear()
|
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
pos.Clear();
|
|
|
|
rad = 0.0;
|
2015-11-01 09:55:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Retrieve a new instance of this type with absolute component values.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Circle Abs() const;
|
2016-05-22 05:20:38 +02:00
|
|
|
|
2020-04-20 15:00:47 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Transform this into an array of Vector2 points that form a circle.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Array ToPointsArray(SQInteger num_segments) const;
|
2020-04-20 15:00:47 +02:00
|
|
|
|
2020-09-03 19:33:51 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Generate a formatted string with the values from this instance.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD String Format(StackStrF & str) const;
|
2020-09-03 19:33:51 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Extract the values for components of the Circle type from a string.
|
|
|
|
*/
|
2019-02-17 16:23:59 +01:00
|
|
|
static const Circle & Get(StackStrF & str);
|
2016-05-22 05:20:38 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Extract the values for components of the Circle type from a string.
|
|
|
|
*/
|
2019-02-17 16:23:59 +01:00
|
|
|
static const Circle & GetEx(SQChar delim, StackStrF & str);
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|