Small OpenGL based c++ rendering library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

punkt3d.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* libsegl - Sebas Extended GL Library
  2. * Collection of Opengl/3D-Math helpers
  3. *
  4. * Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
  5. * http://www.seba-geek.de
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  20. * Boston, MA 02110-1301, USA.
  21. */
  22. #ifndef __PUNKT3D_h
  23. #define __PUNKT3D_h
  24. #include <iostream>
  25. #include <cmath>
  26. #include "emath.h"
  27. namespace segl {
  28. class Punkt3D {
  29. public:
  30. Punkt3D();
  31. Punkt3D(float, float, float);
  32. ~Punkt3D() { };
  33. float x, y, z;
  34. void set(float, float, float);
  35. float abs() const;
  36. Punkt3D kreuzprodukt(const Punkt3D&) const;
  37. void normalize();
  38. Punkt3D getNormalized() const;
  39. bool isNormalized() const;
  40. float calcAngle(Punkt3D b) const;
  41. Punkt3D getOrtographic() const;
  42. Punkt3D getOrtographic2() const;
  43. void print(std::string="") const;
  44. // Operatoren
  45. Punkt3D operator+(const Punkt3D&) const;
  46. Punkt3D operator-(const Punkt3D&) const;
  47. Punkt3D& operator+=(const Punkt3D&);
  48. Punkt3D& operator-=(const Punkt3D&);
  49. Punkt3D operator+(const float&) const;
  50. Punkt3D operator-(const float&) const;
  51. Punkt3D operator*(const float&) const;
  52. Punkt3D operator/(const float&) const;
  53. Punkt3D& operator+=(const float&);
  54. Punkt3D& operator-=(const float&);
  55. Punkt3D& operator*=(const float&);
  56. Punkt3D& operator/=(const float&);
  57. float operator*(const Punkt3D&) const;
  58. Punkt3D operator-() const;
  59. bool operator==(const Punkt3D&) const;
  60. bool operator!=(const Punkt3D&) const;
  61. friend Punkt3D operator+(const float&, const Punkt3D&);
  62. friend Punkt3D operator-(const float&, const Punkt3D&);
  63. friend Punkt3D operator*(const float&, const Punkt3D&);
  64. friend Punkt3D operator/(const float&, const Punkt3D&);
  65. friend std::ostream &operator<<(std::ostream &ostr, const Punkt3D &r);
  66. };
  67. } // namespace segl
  68. float abs(const segl::Punkt3D&);
  69. // OpenGL-Functions for Punkt3D
  70. void glVertex3f(const segl::Punkt3D&);
  71. void glTranslatef(const segl::Punkt3D&);
  72. void glNormal3f(const segl::Punkt3D&);
  73. void glRotatef(const float&, const segl::Punkt3D&);
  74. // Funktionen mit richtgen bezeichnern
  75. void glVertexP3D(const segl::Punkt3D&);
  76. void glTranslateP3D(const segl::Punkt3D&);
  77. void glNormalP3D(const segl::Punkt3D&);
  78. void glRotateP3D(const float&, const segl::Punkt3D&);
  79. void gluLookAt(const segl::Punkt3D &pos, const segl::Punkt3D &viewport, const segl::Punkt3D &normal);
  80. #endif