Skip to content

area_center_xldarea_center_xldAreaCenterXldAreaCenterXldarea_center_xldarea_center_xldπŸ”—

Short descriptionπŸ”—

area_center_xldarea_center_xldAreaCenterXldAreaCenterXldarea_center_xldarea_center_xld β€” Area and center of gravity (centroid) of contours and polygons.

SignatureπŸ”—

area_center_xld( xld XLD, out real Area, out point.y Row, out point.x Column, out string PointOrder )area_center_xld( XLD : : : Area, Row, Column, PointOrder )void AreaCenterXld( const HObject& XLD, HTuple* Area, HTuple* Row, HTuple* Column, HTuple* PointOrder )static void HOperatorSet.AreaCenterXld( HObject XLD, out HTuple area, out HTuple row, out HTuple column, out HTuple pointOrder )def area_center_xld( xld: HObject ) -> Tuple[Sequence[float], Sequence[float], Sequence[float], Sequence[str]]

def area_center_xld_s( xld: HObject ) -> Tuple[float, float, float, str]Herror area_center_xld( const Hobject XLD, double* Area, double* Row, double* Column, char* PointOrder )

Herror T_area_center_xld( const Hobject XLD, Htuple* Area, Htuple* Row, Htuple* Column, Htuple* PointOrder )

HTuple HXLD::AreaCenterXld( HTuple* Row, HTuple* Column, HTuple* PointOrder ) const

double HXLD::AreaCenterXld( double* Row, double* Column, HString* PointOrder ) const

HTuple HXLD.AreaCenterXld( out HTuple row, out HTuple column, out HTuple pointOrder )

double HXLD.AreaCenterXld( out double row, out double column, out string pointOrder )

DescriptionπŸ”—

area_center_xldAreaCenterXld calculates the area and center of gravity (centroid) of the regions enclosed by the contours or polygons XLDXLDxld as well as the order of the points along the boundary. The area and centroid are computed by applying Green’s theorem using only the points on the contour or polygon, i.e., no region is generated explicitly for the purpose of calculating the features. If the points are arranged counterclockwise (i.e., in a positive mathematical sense) in the contour or polygon, PointOrderpointOrderpoint_order will be 'positive'"positive". It is assumed that the contours or polygons are closed. If this is not the case area_center_xldAreaCenterXld will artificially close the contour respectively polygon.

It should be noted that area_center_xldAreaCenterXld only returns useful results if the contour or polygon encloses a region in the plane. In particular, the contour or polygon must not intersect itself. This is particularly important if open contours or polygons are passed because they are closed automatically, which can produce a self-intersection. To test whether the contours or polygons intersect themselves, test_self_intersection_xldTestSelfIntersectionXld can be used. If the contour or polygon intersects itself, a useful value for the center of gravity can be calculated with area_center_points_xldAreaCenterPointsXld.

If more than one contour or polygon is passed, the results are stored in tuples in the same order as the respective contours or polygons in XLDXLDxld.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

ParametersπŸ”—

XLDXLDxld (input_object) xld(-array) β†’ objectobjectHObjectHXLDHObjectHobject

Contours or polygons to be examined.

Areaareaarea (output_control) real(-array) β†’ (real)(real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Area enclosed by the contour or polygon.

Rowrowrow (output_control) point.y(-array) β†’ (real)(real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Row coordinate of the centroid.

Columncolumncolumn (output_control) point.x(-array) β†’ (real)(real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Column coordinate of the centroid.

PointOrderpointOrderpoint_order (output_control) string(-array) β†’ (string)(string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

point order along the boundary (β€˜positive’/’negative’).

ComplexityπŸ”—

Let n be the number of points of the contour or polygon. Then the run time is O(n).

ResultπŸ”—

area_center_xldAreaCenterXld returns 2 (H_MSG_TRUE) if the input is not empty. If the input is empty the behavior can be set via set_system(::'no_object_result',<Result>:). If necessary, an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

gen_contours_skeleton_xldGenContoursSkeletonXld, smooth_contours_xldSmoothContoursXld, gen_polygons_xldGenPolygonsXld

Alternatives

area_center_points_xldAreaCenterPointsXld

See also

moments_xldMomentsXld, moments_any_xldMomentsAnyXld, area_centerAreaCenter, moments_region_2ndMomentsRegion2nd

ModuleπŸ”—

Foundation