Vector2 <-> Vector2i conversion operators.

This commit is contained in:
Relintai 2022-02-04 13:17:55 +01:00
parent cf8dd43fd7
commit e34079ee46
4 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,7 @@
#include "vector2.h"
#include <cmath>
#include "vector2i.h"
#define EPSILON 0.00001
@ -222,4 +223,8 @@ float &Vector2::operator[](int axis) {
Vector2::operator String() const {
return "[" + String::num(x) + "," + String::num(y) + "]";
}
}
Vector2::operator Vector2i() const {
return Vector2i(x, y);
}

View File

@ -3,6 +3,8 @@
#include "core/string.h"
class Vector2i;
class Vector2 {
public:
Vector2 abs() const;
@ -58,6 +60,7 @@ public:
float &operator[](int axis);
operator String() const;
operator Vector2i() const;
enum Axis {
AXIS_X = 0,

View File

@ -1,6 +1,7 @@
#include "vector2i.h"
#include <cmath>
#include "vector2.h"
Vector2i Vector2i::abs() const {
Vector2i b;
@ -178,4 +179,8 @@ int &Vector2i::operator[](int axis) {
Vector2i::operator String() const {
return "[" + String::num(x) + "," + String::num(y) + "]";
}
}
Vector2i::operator Vector2() const {
return Vector2(x, y);
}

View File

@ -3,6 +3,8 @@
#include "core/string.h"
class Vector2;
class Vector2i {
public:
Vector2i abs() const;
@ -52,6 +54,7 @@ public:
int &operator[](int axis);
operator String() const;
operator Vector2() const;
enum Axis {
AXIS_X = 0,