1 //
2 // Computergraphik II
3 // Prof. Dr. Juergen Doellner
4 // Wintersemester 2001/02
5 //
6 // Rahmenprogramm zu Aufgabenzettel 8
7 //
8
9 #ifndef _TRIANGLE_H
10 #define _TRIANGLE_H
11
12 #include "vector.h"
13
14 //- Triangle
15 class Triangle {
16 //. 3D Triangle Class.
17 public:
18 //- Triangle
19 Triangle();
20 Triangle(const Vector& v0, const Vector& v1, const Vector& v2);
21
22 //- set/getVertex, set/GetNormal, triangleNormal
23 const Vector& getVertex(int i) const;
24 void setVertex(int i,const Vector& v);
25 const Vector& getNormal(int i) const;
26 void setNormal(int i,const Vector& n);
27 const Vector& triangleNormal() const;
28
29
30 void normalizeNormals();
31
32 //- operator>>
33 friend istream& operator>>(istream&, Triangle&);
34
35 private:
36 Vector v_[3];
37 Vector n_[3];
38 Vector triNrm_;
39 };
40
41
42 inline const Vector& Triangle::getVertex(int i) const { return v_[i]; }
43 inline void Triangle::setVertex(int i,const Vector& v) { v_[i] = v; }
44 inline const Vector& Triangle::getNormal(int i) const { return n_[i]; }
45 inline void Triangle::setNormal(int i,const Vector& n) { n_[i] = n; }
46 inline const Vector& Triangle::triangleNormal() const { return triNrm_;}
47
48
49 #endif // _TRIANGLE_H
50
51