137 lines
2.2 KiB
C++
137 lines
2.2 KiB
C++
#include "punkt2d.h"
|
|
|
|
Punkt2D::Punkt2D() {
|
|
x = y = 0.0f;
|
|
}
|
|
|
|
Punkt2D::Punkt2D(float _x, float _y) {
|
|
set(_x, _y);
|
|
}
|
|
|
|
void Punkt2D::set(float _x, float _y) {
|
|
x = _x;
|
|
y = _y;
|
|
}
|
|
|
|
void Punkt2D::print(std::string coordname) {
|
|
if(coordname!="")
|
|
coordname.append(" ");
|
|
std::cout << coordname << "Coord: (" << x << ", " << y << ")" << std::endl;
|
|
}
|
|
|
|
|
|
Punkt2D Punkt2D::operator+(const Punkt2D &b) {
|
|
Punkt2D c;
|
|
c.x = x + b.x;
|
|
c.y = y + b.y;
|
|
// c.z = z + b.z;
|
|
|
|
return c;
|
|
}
|
|
|
|
Punkt2D Punkt2D::operator-(const Punkt2D &b) {
|
|
Punkt2D c;
|
|
c.x = x - b.x;
|
|
c.y = y - b.y;
|
|
// c.z = z - b.z;
|
|
|
|
return c;
|
|
}
|
|
|
|
Punkt2D& Punkt2D::operator+=(const Punkt2D &b) {
|
|
x += b.x;
|
|
y += b.y;
|
|
// z += b.z;
|
|
|
|
return *this;
|
|
}
|
|
|
|
Punkt2D& Punkt2D::operator-=(const Punkt2D &b) {
|
|
x -= b.x;
|
|
y -= b.y;
|
|
// z -= b.z;
|
|
|
|
return *this;
|
|
}
|
|
|
|
Punkt2D Punkt2D::operator+(const float &_m) {
|
|
return Punkt2D(x+_m, y+_m);
|
|
}
|
|
|
|
Punkt2D Punkt2D::operator-(const float &_m) {
|
|
return Punkt2D(x-_m, y-_m);
|
|
}
|
|
|
|
Punkt2D Punkt2D::operator*(const float &_m) {
|
|
return Punkt2D(x*_m, y*_m);
|
|
}
|
|
|
|
Punkt2D Punkt2D::operator/(const float &_m) {
|
|
return Punkt2D(x/_m, y/_m);
|
|
}
|
|
|
|
Punkt2D& Punkt2D::operator+=(const float &_m) {
|
|
x += _m;
|
|
y += _m;
|
|
// z += _m;
|
|
return *this;
|
|
}
|
|
Punkt2D& Punkt2D::operator-=(const float &_m) {
|
|
x -= _m;
|
|
y -= _m;
|
|
// z -= _m;
|
|
return *this;
|
|
}
|
|
Punkt2D& Punkt2D::operator*=(const float &_m) {
|
|
x *= _m;
|
|
y *= _m;
|
|
// z *= _m;
|
|
return *this;
|
|
}
|
|
Punkt2D& Punkt2D::operator/=(const float &_m) {
|
|
x /= _m;
|
|
y /= _m;
|
|
// z /= _m;
|
|
return *this;
|
|
}
|
|
|
|
float Punkt2D::operator*(const Punkt2D& _m) {
|
|
return x * _m.x + y * _m.y;
|
|
}
|
|
|
|
Punkt2D Punkt2D::operator-() {
|
|
return Punkt2D(-x, -y);
|
|
}
|
|
|
|
bool Punkt2D::operator==(const Punkt2D& b) {
|
|
return ( x==b.x && y==b.y);
|
|
}
|
|
bool Punkt2D::operator!=(const Punkt2D& b) {
|
|
return !(*this==b);
|
|
}
|
|
// Freunde
|
|
|
|
Punkt2D operator+(const float& _m, const Punkt2D& b) {
|
|
return Punkt2D(b.x+_m, b.y+_m);
|
|
}
|
|
|
|
Punkt2D operator-(const float& _m, const Punkt2D& b) {
|
|
return Punkt2D(b.x-_m, b.y-_m);
|
|
}
|
|
|
|
Punkt2D operator*(const float& _m, const Punkt2D& b) {
|
|
return Punkt2D(b.x*_m, b.y*_m);
|
|
}
|
|
|
|
Punkt2D operator/(const float& _m, const Punkt2D& b) {
|
|
return Punkt2D(b.x/_m, b.y/_m);
|
|
}
|
|
|
|
void glTexCoord2f(Punkt2D p) {
|
|
glTexCoord2f(p.x, p.y);
|
|
}
|
|
|
|
// float abs(Punkt2D p) {
|
|
// return p.abs();
|
|
// }
|