+ (e1 [1]>=0?y1 :y2)*e1 [1]; float xMax = ( e1 [0] >= 0 ? x2 : x1 ) * e1 [0]
+ (e1 [1]>=0?y2:y1 )*e1 [1]; float yMin = ( e2 [0] >= 0 ? x1 : x2 ) * e2 [0]
+ (e2 [1] >= 0 ? y1 :y2)*e2 [1]; float yMax = ( e2 [0] >= 0 ? x2 : x1 ) * e2 [0]
+ (e2 [1]>=0?y2:y1 )*e2 [1]; float hx =(x2-x1 )/n1; float hy = ( y2 - y1 ) / n2; Vector3D edgel, edge2, n; Point facet [3]; float x, y; int color; int i,j, k;

Компьютерная графика. Полигональные модели

if ( e2 [2] >= 0 ) {
yMin += fMin * e2 [2]; yMax += fMax * e2 [2];
}
else
{
yMin += fMax * e2 [2]; yMax += fMin * e2 [2];
}
float ax = 20 - 600 * xMin / ( xMax - xMin );
float bx = 600 / ( xMax - xMin );
float ay = 40 - 400 * yMin / ( yMax - yMin );
float by = -400 / ( yMax - yMin );
for ( i = 0; i < 64; i++ )
{
setrgbpalette ( i, 0, 0, i ); setrgbpalette ( 64 + i, 0, i, 0 );
f
for ( i = 0; i < n1; i++ ) {
curPoint [i].x = x1 + i * hx; curPoint [ij.y = y1;
curPoint [ij.z = f ( curPoint [i].x, curPoint [i].y ); curLine [i].x = (int)( ax + bx * ( curPoint [i] & e1 ) ); curLine [ij.y = (int)( ay + by * ( curPoint [i] & e2 ) );
}
for ( i = 1; i < n2; i++ ) {
for ( j = 0; j < n1; j++ ) {
nextPoint [j].x = x1 + j * hx;
nextPoint OJ.y = y1 + i * hy;
nextPoint [jj.z = f ( nextPoint [j].x, nextPoint 0].y );
nextLine [j]-* = (int)(ax + bx * ( nextPoint 0] & e1 ));
NextLine [j].y = (int)(ay + by * ( NextPoint [j] & e2 ));
}
for (j = 0; j < n1 - 1; j++ ) {
//draw 1st triangle edgel = curPoint 0+1] - curPoint [j]; edge2 = nextPoint 0] - curPoint [j]; n = edgel A edge2; if ( ( n & e3 ) >= 0 )
color = 64 + (int)( 20 + 43 * ( n & e3 ) / !n ); else
color = (int)( 20 - 43 * ( n & e3 ) / !n ); setfillstyle ( SOLID_FILL, color ); setcolor ( color );

10. Удаление невидимых линий и поверхносте

facet [0] = curtine [j]; facet [1] = curLine 0+1]; facet [2] = nextLine [j]; fillpoly ( 3, (int far *) facet);
// draw 2nd triangle edgel = nextPoint [j+1] - curPoint 0+1]; edge2 = nextPoint 0] - curPoint 0+1]; n = edgel A edge2; if (( n & e3 ) >= 0 ) { color = 127;

⇐ Предыдущая| |Следующая ⇒