ocmath_d_polygon_area
Description
This function is used to calculate the signed area of a planar non-self-intersecting polygon. If the vertices of the polygon are , the area is:
/math-a25a2f7386690fbe52efad33a94c1a44.png)
/math-883efd85058df96df4d2a9a613596069.png)
For the area of a convex polygon, if the points are arranged anticlockwise, the area will be positive, and if clockwise, will be negative.
Data types supported:
double: ocmath_d_polygon_area
float: ocmath_f_polygon_area
POINT: ocmath_l_polygon_area
Syntax
double ocmath_d_polygon_area(double* pX, double* pY, uint nSize)
Parameters
- pX
- [input] buffer containing X data of polygon vertexes
- pY
- [input] buffer containing Y data of polygon vertexes
- nSize
- [input] size of pX, pY
Return
Polygon area.
Examples
EX1
//For this example to run, make sure a worksheet is active in current project
void ocmath_d_polygon_area_ex1()
{
Worksheet wks = Project.ActiveLayer();
wks.SetSize(-1,2);
DataRange dr;
dr.Add("X", wks, 0, 0, -1, 0);
dr.Add("Y", wks, 0, 1, -1, 1);
vector vxData, vyData;
DWORD dwPlotID;
if(dr.GetData(DRR_GET_MISSING | DRR_GET_DEPENDENT | DRR_NO_FACTORS, 0, &dwPlotID, NULL, &vyData, &vxData) < 0)
{
printf("get data failed!");
return;
}
uint nSize = vxData.GetSize();
double area = ocmath_d_polygon_area(vxData, vyData, nSize);
out_double("area=", area);
}
Remark
See Also
ocmath_f_polygon_area, ocmath_l_polygon_area
header to Include
origin.h
Reference
|