|
|
|
@ -16,11 +16,11 @@ void Punkt3D::set(float _x, float _y, float _z) {
|
|
|
|
|
z = _z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Punkt3D::abs() {
|
|
|
|
|
float Punkt3D::abs() const {
|
|
|
|
|
return sqrt(x*x+y*y+z*z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::kreuzprodukt(const Punkt3D &b) {
|
|
|
|
|
Punkt3D Punkt3D::kreuzprodukt(const Punkt3D &b) const {
|
|
|
|
|
Punkt3D erg;
|
|
|
|
|
erg.x = y*b.z - z*b.y;
|
|
|
|
|
erg.y = z*b.x - x*b.z;
|
|
|
|
@ -36,23 +36,23 @@ void Punkt3D::normalize() {
|
|
|
|
|
z /= a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::getNormalized() {
|
|
|
|
|
Punkt3D Punkt3D::getNormalized() const {
|
|
|
|
|
Punkt3D ret(*this);
|
|
|
|
|
ret.normalize();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Punkt3D::isNormalized() {
|
|
|
|
|
return (abs()==1);
|
|
|
|
|
bool Punkt3D::isNormalized() const {
|
|
|
|
|
return (abs()==1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Punkt3D::calcAngle(Punkt3D b) {
|
|
|
|
|
float Punkt3D::calcAngle(Punkt3D b) const {
|
|
|
|
|
if(abs()*b.abs()==0.0f)
|
|
|
|
|
return 0.0f;
|
|
|
|
|
return rad2deg(std::acos(((*this)*b)/(abs()*b.abs())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::getOrtographic() {
|
|
|
|
|
Punkt3D Punkt3D::getOrtographic() const {
|
|
|
|
|
Punkt3D erg;
|
|
|
|
|
if(!x) {
|
|
|
|
|
erg.x = 0.0f;
|
|
|
|
@ -71,7 +71,7 @@ Punkt3D Punkt3D::getOrtographic() {
|
|
|
|
|
return erg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::getOrtographic2() {
|
|
|
|
|
Punkt3D Punkt3D::getOrtographic2() const {
|
|
|
|
|
Punkt3D nullvec;
|
|
|
|
|
Punkt3D erg;
|
|
|
|
|
erg.set(y, -x, 0.0f);
|
|
|
|
@ -84,13 +84,13 @@ Punkt3D Punkt3D::getOrtographic2() {
|
|
|
|
|
return erg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Punkt3D::print(std::string coordname) {
|
|
|
|
|
void Punkt3D::print(std::string coordname) const {
|
|
|
|
|
if(coordname!="")
|
|
|
|
|
coordname.append(" ");
|
|
|
|
|
std::cout << coordname << "Coord: (" << x << ", " << y << ", " << z << ")" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::operator+(const Punkt3D &b) {
|
|
|
|
|
Punkt3D Punkt3D::operator+(const Punkt3D &b) const {
|
|
|
|
|
Punkt3D c;
|
|
|
|
|
c.x = x + b.x;
|
|
|
|
|
c.y = y + b.y;
|
|
|
|
@ -99,7 +99,7 @@ Punkt3D Punkt3D::operator+(const Punkt3D &b) {
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::operator-(const Punkt3D &b) {
|
|
|
|
|
Punkt3D Punkt3D::operator-(const Punkt3D &b) const {
|
|
|
|
|
Punkt3D c;
|
|
|
|
|
c.x = x - b.x;
|
|
|
|
|
c.y = y - b.y;
|
|
|
|
@ -124,19 +124,19 @@ Punkt3D& Punkt3D::operator-=(const Punkt3D &b) {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::operator+(const float &_m) {
|
|
|
|
|
Punkt3D Punkt3D::operator+(const float &_m) const {
|
|
|
|
|
return Punkt3D(x+_m, y+_m, z+_m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::operator-(const float &_m) {
|
|
|
|
|
Punkt3D Punkt3D::operator-(const float &_m) const {
|
|
|
|
|
return Punkt3D(x-_m, y-_m, z-_m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::operator*(const float &_m) {
|
|
|
|
|
Punkt3D Punkt3D::operator*(const float &_m) const {
|
|
|
|
|
return Punkt3D(x*_m, y*_m, z*_m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::operator/(const float &_m) {
|
|
|
|
|
Punkt3D Punkt3D::operator/(const float &_m) const {
|
|
|
|
|
return Punkt3D(x/_m, y/_m, z/_m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -165,18 +165,18 @@ Punkt3D& Punkt3D::operator/=(const float &_m) {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Punkt3D::operator*(const Punkt3D& _m) {
|
|
|
|
|
float Punkt3D::operator*(const Punkt3D& _m) const {
|
|
|
|
|
return x * _m.x + y * _m.y + z * _m.z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Punkt3D Punkt3D::operator-() {
|
|
|
|
|
Punkt3D Punkt3D::operator-() const {
|
|
|
|
|
return Punkt3D(-x, -y, -z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Punkt3D::operator==(const Punkt3D& b) {
|
|
|
|
|
bool Punkt3D::operator==(const Punkt3D& b) const {
|
|
|
|
|
return ( x==b.x && y==b.y && z==b.z);
|
|
|
|
|
}
|
|
|
|
|
bool Punkt3D::operator!=(const Punkt3D& b) {
|
|
|
|
|
bool Punkt3D::operator!=(const Punkt3D& b) const {
|
|
|
|
|
return !(*this==b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -204,46 +204,46 @@ std::ostream &operator<<(std::ostream &ostr, const segl::Punkt3D &r) {
|
|
|
|
|
|
|
|
|
|
} // namespace segl
|
|
|
|
|
|
|
|
|
|
float abs(segl::Punkt3D p) {
|
|
|
|
|
float abs(const segl::Punkt3D &p) {
|
|
|
|
|
return p.abs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OpenGL Funktionen f<>r Punkt3D
|
|
|
|
|
|
|
|
|
|
void glVertex3f(segl::Punkt3D p) {
|
|
|
|
|
void glVertex3f(const segl::Punkt3D &p) {
|
|
|
|
|
glVertex3f(p.x, p.y, p.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glTranslatef(segl::Punkt3D p) {
|
|
|
|
|
void glTranslatef(const segl::Punkt3D &p) {
|
|
|
|
|
glTranslatef(p.x, p.y, p.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glNormal3f(segl::Punkt3D p) {
|
|
|
|
|
void glNormal3f(const segl::Punkt3D &p) {
|
|
|
|
|
glNormal3f(p.x, p.y, p.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glRotatef(float deg, segl::Punkt3D vec) {
|
|
|
|
|
void glRotatef(const float °, const segl::Punkt3D &vec) {
|
|
|
|
|
glRotatef(deg, vec.x, vec.y, vec.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Funktionen mit richtgen bezeichnern
|
|
|
|
|
void glVertexP3D(segl::Punkt3D p) {
|
|
|
|
|
void glVertexP3D(const segl::Punkt3D &p) {
|
|
|
|
|
glVertex3f(p.x, p.y, p.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glTranslateP3D(segl::Punkt3D p) {
|
|
|
|
|
void glTranslateP3D(const segl::Punkt3D &p) {
|
|
|
|
|
glTranslatef(p.x, p.y, p.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glNormalP3D(segl::Punkt3D p) {
|
|
|
|
|
void glNormalP3D(const segl::Punkt3D &p) {
|
|
|
|
|
glNormal3f(p.x, p.y, p.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glRotateP3D(float deg, segl::Punkt3D vec) {
|
|
|
|
|
void glRotateP3D(const float °, const segl::Punkt3D &vec) {
|
|
|
|
|
glRotatef(deg, vec.x, vec.y, vec.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gluLookAt(segl::Punkt3D pos, segl::Punkt3D viewport, segl::Punkt3D normal) {
|
|
|
|
|
void gluLookAt(const segl::Punkt3D &pos, const segl::Punkt3D &viewport, const segl::Punkt3D &normal) {
|
|
|
|
|
gluLookAt( pos.x, pos.y, pos.z,
|
|
|
|
|
viewport.x, viewport.y, viewport.z,
|
|
|
|
|
normal.x, normal.y, normal.z );
|
|
|
|
|