2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _BASE_VECTOR2F_HPP_
|
|
|
|
#define _BASE_VECTOR2F_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Config.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
struct Vector2f
|
|
|
|
{
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
typedef SQFloat Value;
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
static const Vector2f NIL;
|
|
|
|
static const Vector2f MIN;
|
|
|
|
static const Vector2f MAX;
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
static SQChar Delim;
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
Value x, y;
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f();
|
|
|
|
Vector2f(Value s);
|
|
|
|
Vector2f(Value xv, Value yv);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f(const Vector2i & v);
|
|
|
|
Vector2f(const Vector2u & v);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f(const SQChar * values, SQChar delim);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f(const Vector2f & v);
|
|
|
|
Vector2f(Vector2f && v);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
~Vector2f();
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f & operator = (const Vector2f & v);
|
|
|
|
Vector2f & operator = (Vector2f && v);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f & operator = (Value s);
|
|
|
|
Vector2f & operator = (const SQChar * values);
|
|
|
|
Vector2f & operator = (const Vector2i & v);
|
|
|
|
Vector2f & operator = (const Vector2u & v);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f & operator += (const Vector2f & v);
|
|
|
|
Vector2f & operator -= (const Vector2f & v);
|
|
|
|
Vector2f & operator *= (const Vector2f & v);
|
|
|
|
Vector2f & operator /= (const Vector2f & v);
|
|
|
|
Vector2f & operator %= (const Vector2f & v);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f & operator += (Value s);
|
|
|
|
Vector2f & operator -= (Value s);
|
|
|
|
Vector2f & operator *= (Value s);
|
|
|
|
Vector2f & operator /= (Value s);
|
|
|
|
Vector2f & operator %= (Value s);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f & operator ++ ();
|
|
|
|
Vector2f & operator -- ();
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f operator ++ (int);
|
|
|
|
Vector2f operator -- (int);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f operator + (const Vector2f & v) const;
|
|
|
|
Vector2f operator - (const Vector2f & v) const;
|
|
|
|
Vector2f operator * (const Vector2f & v) const;
|
|
|
|
Vector2f operator / (const Vector2f & v) const;
|
|
|
|
Vector2f operator % (const Vector2f & v) const;
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f operator + (Value s) const;
|
|
|
|
Vector2f operator - (Value s) const;
|
|
|
|
Vector2f operator * (Value s) const;
|
|
|
|
Vector2f operator / (Value s) const;
|
|
|
|
Vector2f operator % (Value s) const;
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f operator + () const;
|
|
|
|
Vector2f operator - () const;
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator == (const Vector2f & v) const;
|
|
|
|
bool operator != (const Vector2f & v) const;
|
|
|
|
bool operator < (const Vector2f & v) const;
|
|
|
|
bool operator > (const Vector2f & v) const;
|
|
|
|
bool operator <= (const Vector2f & v) const;
|
|
|
|
bool operator >= (const Vector2f & v) const;
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInteger Cmp(const Vector2f & v) const;
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
const SQChar * ToString() const;
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(Value ns);
|
|
|
|
void Set(Value nx, Value ny);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(const Vector2f & v);
|
|
|
|
void Set(const Vector2i & v);
|
|
|
|
void Set(const Vector2u & v);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(const SQChar * values, SQChar delim);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Generate();
|
|
|
|
void Generate(Value min, Value max);
|
|
|
|
void Generate(Value xmin, Value xmax, Value ymin, Value ymax);
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Clear() { x = 0.0, y = 0.0; }
|
2015-09-30 02:56:11 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2f Abs() const;
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _BASE_VECTOR2F_HPP_
|