Al's Programming Resource Homepage  Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

polygon.cpp

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include "polygon.h"
00003 
00004 
00005 POLYGON::POLYGON()
00006 {
00007 }
00008 
00009 POLYGON::~POLYGON()
00010 {
00011 }
00012 
00013 VECTOR POLYGON::GetNormal()
00014 {
00015         VECTOR temp; 
00016         float ux;
00017         float uy;
00018         float uz;
00019         float vx;
00020         float vy;
00021         float vz;
00022           ux = Vertex[1].coords.x - Vertex[0].coords.x;
00023           uy = Vertex[1].coords.y - Vertex[0].coords.y;
00024           uz = Vertex[1].coords.z - Vertex[0].coords.z;
00025           vx = Vertex[2].coords.x - Vertex[0].coords.x;
00026           vy = Vertex[2].coords.y - Vertex[0].coords.y;
00027           vz = Vertex[2].coords.z - Vertex[0].coords.z;
00028           temp.x = (uy*vz)-(vy*uz);
00029           temp.y = (uz*vx)-(vz*ux);
00030           temp.z = (ux*vy)-(vx*uy);
00031         return temp;
00032 }
00033 
00034 void POLYGON::SetNormal()
00035 {
00036         float ux;
00037         float uy;
00038         float uz;
00039         float vx;
00040         float vy;
00041         float vz;
00042           ux = Vertex[1].coords.x - Vertex[0].coords.x;
00043           uy = Vertex[1].coords.y - Vertex[0].coords.y;
00044           uz = Vertex[1].coords.z - Vertex[0].coords.z;
00045           vx = Vertex[2].coords.x - Vertex[0].coords.x;
00046           vy = Vertex[2].coords.y - Vertex[0].coords.y;
00047           vz = Vertex[2].coords.z - Vertex[0].coords.z;
00048           Vertex[0].normal.x = (uy*vz)-(vy*uz);
00049           Vertex[0].normal.y = (uz*vx)-(vz*ux);
00050           Vertex[0].normal.z = (ux*vy)-(vx*uy);
00051         Vertex[1].normal = Vertex[0].normal;
00052           Vertex[2].normal = Vertex[0].normal;
00053 }

Generated on Fri Dec 23 05:20:59 2005 for Polygon Selection by doxygen1.2.15