Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

triangle Class Reference

#include <jtriangle.hpp>

List of all members.

Public Methods

 triangle ()
 triangle (const triangle &obj)
 ~triangle ()
void draw ()
void drawmesh ()
void drawnormals ()
void tform ()
void normalize ()
void syncnormals ()
float angle (vect3f &)
float distance (vect3f &)

Public Attributes

vect3f normal
vect3f center
myVertexType vert [3]


Constructor & Destructor Documentation

triangle::triangle   [inline]
 

Definition at line 118 of file jtriangle.hpp.

00118 {}

triangle::triangle const triangle &    obj [inline]
 

Definition at line 119 of file jtriangle.hpp.

00120    {
00121       for (int i = 0; i < 3; i++){
00122          vert[i] = obj.vert[i];
00123          center = obj.center;
00124          normal = obj.normal;
00125       }
00126    }

triangle::~triangle   [inline]
 

Definition at line 127 of file jtriangle.hpp.

00127 {}


Member Function Documentation

float triangle::angle vect3f &    point
 

Definition at line 240 of file jtriangle.hpp.

00241 {
00242    vect3f vtop = point - center;
00243    return acos((normal * vtop) / (!normal * !vtop));
00244 }

float triangle::distance vect3f &    point
 

Definition at line 248 of file jtriangle.hpp.

00249 {
00250    vect3f vtop = point - center;
00251    return normal.comp(vtop);
00252 
00253 }

void triangle::draw  
 

Definition at line 150 of file jtriangle.hpp.

00151 {
00152    myVertexType tempvert[3];
00153 
00154    glBegin(GL_TRIANGLES);
00155       for (int i = 0; i < 3; i++){
00156             tempvert[i] = vert[i];
00157             tempvert[i].tform();
00158             tempvert[i].draw();
00159       }
00160    glEnd();
00161 }

void triangle::drawmesh  
 

Definition at line 165 of file jtriangle.hpp.

00166 {
00167    myVertexType tempvert[3];
00168 
00169    glBegin(GL_LINE_LOOP);
00170       for (int i = 0; i < 3; i++){
00171             tempvert[i] = vert[i];
00172             tempvert[i].tform();
00173             tempvert[i].draw();
00174       }
00175    glEnd();
00176 }

void triangle::drawnormals  
 

Definition at line 180 of file jtriangle.hpp.

00181 {
00182    myVertexType tempvert[3];
00183 
00184    glBegin(GL_LINES);
00185 
00186       for (int i = 0; i < 3; i++){
00187             tempvert[i] = vert[i];
00188             tempvert[i].tform();
00189             tempvert[i].draw();
00190             tempvert[i].pos += tempvert[i].normal;
00191             tempvert[i].draw();
00192       }
00193 
00194       tempvert[0].pos = center;
00195       tempvert[0].normal = normal;
00196       tempvert[0].normal += tempvert[0].pos;
00197       mstack.tform(tempvert[0].pos);
00198       tempvert[0].draw();
00199       mstack.tform(tempvert[0].normal);
00200       tempvert[0].pos = tempvert[0].normal;
00201       tempvert[0].draw();
00202    glEnd();
00203 }

void triangle::normalize  
 

Definition at line 220 of file jtriangle.hpp.

00221 {
00222    vect3f edge1, edge2;
00223    edge1 = vert[1].pos - vert[0].pos;
00224    edge2 = vert[2].pos - vert[1].pos;
00225    normal = edge1 % edge2;
00226    normal.unit();
00227    center = (vert[0].pos + vert[1].pos + vert[2].pos) / 3;
00228 }

void triangle::syncnormals  
 

Definition at line 232 of file jtriangle.hpp.

00233 {
00234    for (int i = 0; i < 3; i++)
00235       vert[i].normal = normal;
00236 }

void triangle::tform  
 

Definition at line 207 of file jtriangle.hpp.

00208 {
00209    for (int i = 0; i < 3; i++)
00210       vert[i].tform();
00211 
00212    normal += center;
00213    mstack.tform(center);
00214    mstack.tform(normal);
00215    normal -= center;
00216 }


Member Data Documentation

vect3f triangle::center
 

Definition at line 131 of file jtriangle.hpp.

Referenced by triangle().

vect3f triangle::normal
 

Definition at line 130 of file jtriangle.hpp.

Referenced by triangle().

myVertexType triangle::vert[3]
 

Definition at line 133 of file jtriangle.hpp.

Referenced by triangle().


The documentation for this class was generated from the following file:
Generated on Sun Oct 14 18:50:20 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001