| 2.1.18.6 ocmath_d_polygon_reorder
 DescriptionThis function test or reorder a polygon.
 Syntaxint ocmath_d_polygon_reorder( UINT nSize, double * px, double * py, bool bCCW = true, bool bTest = false ) Parameters nSize[input] point number of the polygon px[input] x-coordinates of the polgyon, it might be modified if bTest=false py[input] y-coordinates of the polgyon, it might be modified if bTest=false bCCW[input](true) counter-clockwise or (false) clockwise bTest[input] (true) just determine the order or (false) try to order it into bCCW; default: false;
 Returnif bTest is false, return 1 if reoder was done,
 return 0 if not modified,
 return -1 if failed.
 if bTest is true, return 1 if bCCW is consistents with polygon,
 return 0 if bCCW is inconsistent with polygon,
 return -1 if unable to determine.
 ExamplesEX1
 //This example is to check order(bTest is true)
#include <wks2mat.h>
int ocmath_d_polygon_reorder_ex1()
{
	//The polygon in this example is counter-clockwise(CCW)
	double dX[]={1,2,3,4,5,6,7,8};
	double dY[]={5,4,3,1,3,5,6,9};
	UINT nSize = 8;
	//nRet=0, because the polygon is inconsistent with bCCW = false, which means clockwise 
	int nRet = ocmath_d_polygon_reorder(nSize,dX,dY,false,true); 	
	if(0 == nRet)
		out_str("This polygon is counter-clockwise");
	else if(1 == nRet)
		out_str("This polygon is clockwise");
	else
		return 0;
	
	return 1;
}EX2
 //This example is to reorder(bTest is false)
#include <wks2mat.h>
int ocmath_d_polygon_reorder_ex2()
{
	//The polygon in this example is counter-clockwise(CCW)
	double dX[]={1,2,3,4,5,6,7,8};
	double dY[]={5,4,3,1,3,5,6,9};
	UINT nSize = 8;
	// nRet = 1, and the polygon will be reordered to clockwise
	int nRet = ocmath_d_polygon_reorder(nSize,dX,dY,false);	if(0 == nRet)
		out_str("This polygon is not reordered");
	else if(1 == nRet)
	{
		out_str("This polygon is reordered");
		printf("The reordered polygon is : \n");
		for(int ii =0 ; ii< nSize; ii++)
			printf("%f\t%f\n",dX[ii],dY[ii]);
	}
	else
		return 0;
	
	return 1;
}RemarkSee AlsoHeader to Includewks2mat.h
 Reference |