Home
Categories
Coilguns
AVR Projects
Gumstix Projects
PIC Projects
Tutorials
The Forum
Contact Me

If you like this
site please

page counter

OLED 3-D Triangle

6/18/08
/* we need to first find what point is on the top*/
if (Poly_2D[poly_num][0][1]>=Poly_2D[poly_num][1][1]&&
Poly_2D[poly_num][0][1]>=Poly_2D[poly_num][2][1])
topt=0;
else
if (Poly_2D[poly_num][1][1]>=Poly_2D[poly_num][0][1]&&
Poly_2D[poly_num][1][1]>=Poly_2D[poly_num][2][1])
topt=1;
else
if (Poly_2D[poly_num][2][1]>=Poly_2D[poly_num][0][1]&&
Poly_2D[poly_num][2][1]>=Poly_2D[poly_num][1][1])
topt=2;
This section simply cycles through all the points and finds which points has the greatest y value.
/* we also need to know the bottom point*/
if (Poly_2D[poly_num][0][1]<=Poly_2D[poly_num][1][1]&&
Poly_2D[poly_num][0][1]<=Poly_2D[poly_num][2][1])
bott=0;
else
if (Poly_2D[poly_num][1][1]<=Poly_2D[poly_num][0][1]&&
Poly_2D[poly_num][1][1]<=Poly_2D[poly_num][2][1])
bott=1;
else
if (Poly_2D[poly_num][2][1]<=Poly_2D[poly_num][0][1]&&
Poly_2D[poly_num][2][1]<=Poly_2D[poly_num][1][1])
bott=2;
This section does the same thing except for the lowest y value.
/* the remaining point is between them and forms two sides*/
if (topt==0&&bott==1)side=2;
else if(topt==1&&bott==0)side=2;
else if(topt==1&&bott==2)side=0;
else if(topt==2&&bott==1)side=0;
else if(topt==2&&bott==0)side=1;
else if(topt==0&&bott==2)side=1;
Since there are only three points whatever point is not the top or bottom point is the middle/side point.