Пример #1
0
void
Shape::d_markAnchorTilt()
{
	if(!pixdebug) return;

	int x1 = getmaxx();
	int y1 = gety(x1);
	// tilt check with maxx pixel offset to the center pixel using y 
	int y2 = (y1 > getcy()) ? getminy() : getmaxy();
	int x2 = getx(y2);

	int o = x1 - x2;
	int a = ( y1 > y2 ) ? y1 - y2 : y2 - y1; 

	// threshold check and return if within 
	int threshold = (o > a) ? o/10 : a/10;
	if (threshold <= 0) threshold = 5;
	if (abs(o - a) < threshold)  	return;

	if( o > 0 && a > 0 ) { 
		if( y2 > y1 ) 	d_pixmap->setPen(0, 255, 255); 
		else 		d_pixmap->setPen(255, 0, 255);
		d_pixmap->markHLine( x1, x2, y1);
		d_pixmap->markHLine( x1, x2, y1+1);
		d_pixmap->markHLine( x1, x2, y1-1);
		d_pixmap->markVLine( y1, y2, x1);
		d_pixmap->markVLine( y1, y2, x1+1);
		d_pixmap->markVLine( y1, y2, x1-1);
	}

}
int main()
{  
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
            getpoint(points+i);
    }
      
    getminy(n);
    
    qsort ( points+1, n-1, sizeof(*points), comparepolar);  
   
   
    push(points[0]);
    push(points[1]);
    
    for(int i=2;i<n;i++)
    {
            while(ccw(stack[top-1],stack[top],points[i])<=0&&top>0)
            {                          
           //   printf("stack-->");putpoint(stack[top]);printf("\n");
                                                              top--;
            }
            //printf("stack<--");putpoint(points[i]);printf("\n");
            push(points[i]);
    }
    int t=top;
    while(t>=0)
    {
              putpoint(stack[t]);
              printf("\n");
              t--;
    }
    fflush(stdin);
    getchar();   
}