drag_start and drag_origin not working...

This commit is contained in:
Sebastian
2024-10-10 09:54:54 +02:00
parent 190ebe86ff
commit 7b144ed3df
2 changed files with 50 additions and 14 deletions
+49 -13
View File
@@ -14,7 +14,8 @@ class Vec2D{
T x = 0;
T y = 0;
T dist(Vec2D* v) { return sqrt(pow((v->x - x), 2) + pow((v->y - y), 2));};
T length() { return sqrt(pow(x, 2) + pow(y, 2));};
T length() { return (T)sqrt(pow(x, 2) + pow(y, 2));};
T angle(Vec2D &v){
T angle = atan2(v.y, v.x) - atan2(y,x);
@@ -33,7 +34,7 @@ class Vec2D{
return (x*v.x) + (y*v.y);
};
Vec2D& norm() { return *this * (1.0/length());};
Vec2D norm() { return *this / length();};
Vec2D& operator=(const Vec2D& vec){
if (this == &vec){
@@ -50,31 +51,66 @@ class Vec2D{
return *this;
};
friend Vec2D operator+(const Vec2D& left, const Vec2D& right){
return Vec2D(left.x + right.x, left.y + right.y);
};
Vec2D& operator-=(const Vec2D& vec){
this->x -= vec.x;
this->y -= vec.y;
return *this;
};
friend Vec2D operator-(const Vec2D& left, const Vec2D& right){
return Vec2D(left.x - right.x, left.y - right.y);
};
Vec2D& operator*(const Vec2D& vec){
Vec2D& operator*=(const Vec2D& vec){
this->x *= vec.x;
this->y *= vec.y;
return *this;
};
Vec2D& operator*(T scalar){
Vec2D& operator/=(const Vec2D& vec){
this->x /= vec.x;
this->y /= vec.y;
return *this;
};
Vec2D& operator*=(T scalar){
this->x *= scalar;
this->y *= scalar;
return *this;
};
Vec2D& operator/=(T scalar){
this->x /= scalar;
this->y /= scalar;
return *this;
};
};
template<typename T>
Vec2D<T> operator+(const Vec2D<T>& left, const Vec2D<T>& right){
return Vec2D<T>(left.x + right.x, left.y + right.y);
};
template<typename T>
Vec2D<T> operator-(const Vec2D<T>& left, const Vec2D<T>& right){
return Vec2D<T>(left.x - right.x, left.y - right.y);
};
template<typename T>
Vec2D<T> operator*(const Vec2D<T>& left, const Vec2D<T>& right){
return Vec2D<T>(left.x * right.x, left.y * right.y);
};
template<typename T>
Vec2D<T> operator/(const Vec2D<T>& left, const Vec2D<T>& right){
return Vec2D<T>(left.x / right.x, left.y / right.y);
};
template<typename T>
Vec2D<T> operator/(const Vec2D<T>& left, T scalar){
return Vec2D<T>(left.x / scalar, left.y / scalar);
};
template<typename T>
Vec2D<T> operator*(const Vec2D<T>& left, T scalar){
return Vec2D<T>(left.x * scalar, left.y * scalar);
};
struct Color{