20 October 2015 01:28:24 PM POLYGON_PROPERTIES_PRB C++ version Test the POLYGON_PROPERTIES library. POLYGON_ANGLES_TEST POLYGON_ANGLES computes the angles of a polygon. Number of polygonal vertices = 6 The polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 2 1 3: 3 0 4: 3 2 5: 1 2 Polygonal angles in degrees: 0 63.4349 1 135 2 270 3 45 4 90 5 116.565 POLYGON_AREA_TEST POLYGON_AREA computes the area of a polygon. Number of polygonal vertices = 4 The polygon vertices: Row: 0 1 Col 0: 1 0 1: 2 1 2: 1 2 3: 0 1 Exact area is 2 The computed area is 2 Number of polygonal vertices = 8 The polygon vertices: Row: 0 1 Col 0: 0 0 1: 3 0 2: 3 3 3: 2 3 4: 2 1 5: 1 1 6: 1 2 7: 0 2 Exact area is 6 The computed area is 6 POLYGON_AREA_2_TEST POLYGON_AREA_2 computes the area of a polygon. Number of polygonal vertices = 4 The polygon vertices: Row: 0 1 Col 0: 1 0 1: 2 1 2: 1 2 3: 0 1 Exact area is 2 The computed area is 2 Number of polygonal vertices = 8 The polygon vertices: Row: 0 1 Col 0: 0 0 1: 3 0 2: 3 3 3: 2 3 4: 2 1 5: 1 1 6: 1 2 7: 0 2 Exact area is 6 The computed area is 6 POLYGON_CENTROID_TEST POLYGON_CENTROID computes the centroid of a polygon. The polygon vertices: Row: 0 1 Col 0: 1 0 1: 2 1 2: 1 2 3: 0 1 POLYGON_CENTROID: 0: 1 1: 1 POLYGON_CENTROID_2_TEST POLYGON_CENTROID_2 computes the centroid of a polygon. The polygon vertices: Row: 0 1 Col 0: 1 0 1: 2 1 2: 1 2 3: 0 1 POLYGON_CENTROID_2: 0: 1 1: 1 POLYGON_CONTAINS_POINT_TEST POLYGON_CONTAINS_POINT determines if a point is in a polygon. The polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 2 1 3: 1 2 4: 0 2 P Inside 1 1 1 3 4 0 0 2 1 0.5 -0.25 0 POLYGON_CONTAINS_POINT_2_TEST POLYGON_CONTAINS_POINT_2 determines if a point is in a polygon. The polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 2 1 3: 1 2 4: 0 2 P Inside 1 1 1 3 4 0 0 2 1 0.5 -0.25 0 POLYGON_DIAMETER_TEST POLYGON_DIAMETER computes the diameter of a polygon. The polygon vertices: Row: 0 1 Col 0: 1 0 1: 2 1 2: 1 2 3: 0 1 Diameter ( computed ) 2 Diameter ( exact ) 2 POLGON_EXPAND_TEST POLYGON_EXPAND expands a polygon by an amount H. The polygon vertices: Row: 0 1 Col 0: 1 1 1: 5 1 2: 2 4 3: 1 3 The expansion amount H = 0.5 The expanded polygon: Row: 0 1 Col 0: 0.5 0.5 1: 6.20711 0.5 2: 2 4.70711 3: 0.5 3.20711 POLYGON_INRAD_DATA_TEST POLYGON_INRAD_DATA uses the inradius of a regular polygon to compute the area, outradius, and side length. Number of polygonal sides = 3 Assuming RADIN = 1 AREA = 5.19615 RADOUT = 2 SIDE = 3.4641 Number of polygonal sides = 4 Assuming RADIN = 1 AREA = 4 RADOUT = 1.41421 SIDE = 2 Number of polygonal sides = 5 Assuming RADIN = 1 AREA = 3.63271 RADOUT = 1.23607 SIDE = 1.45309 POLYGON_INTEGRAL_1_TEST POLYGON_INTEGRAL_1 integrates 1 over a polygon. The polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 1 1 3: 0 1 1 1 The polygon vertices: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 1 5 POLYGON_INTEGRAL_X_TEST POLYGON_INTEGRAL_X integrates x over a polygon. The polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 1 1 3: 0 1 x 0.5 The polygon vertices: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 x 11.6667 POLYGON_INTEGRAL_XX_TEST POLYGON_INTEGRAL_XX integrates x^2 over a polygon. The polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 1 1 3: 0 1 x^2 0.333333 The polygon vertices: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 x^2 29.1667 POLYGON_INTEGRAL_XY_TEST POLYGON_INTEGRAL_XY integrates xy over a polygon. The polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 1 1 3: 0 1 x*y 0.25 The polygon vertices: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 x*y 35.8333 POLYGON_INTEGRAL_Y_TEST POLYGON_INTEGRAL_Y integrates y over a polygon. The polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 1 1 3: 0 1 y 0.5 The polygon vertices: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 y 15 POLYGON_INTEGRAL_YY_TEST POLYGON_INTEGRAL_YY integrates y^2 over a polygon. The polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 1 1 3: 0 1 y^2 0.333333 The polygon vertices: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 y^2 48.3333 POLYGON_IS_CONVEX_TEST POLYGON_IS_CONVEX determines if a polygon is convex. A point: Row: 0 1 Col 0: 0 0 The polygon is degenerate and convex. A line: Row: 0 1 Col 0: 0 0 1: 1 2 The polygon is degenerate and convex. A triangle: Row: 0 1 Col 0: 0 0 1: 2 0 2: 1 0 The polygon is convex and clockwise. A CCW triangle: Row: 0 1 Col 0: 0 0 1: 1 0 2: 0 2 The polygon is convex and counterclockwise. A CW triangle: Row: 0 1 Col 0: 0 0 1: 0 2 2: 1 0 The polygon is convex and clockwise. Polygon with large angle: Row: 0 1 Col 0: 1 0 1: 2 0 2: 3 1 3: 0 1 The polygon is convex and counterclockwise. Polygon with huge angle: Row: 0 1 Col 0: 0 0 1: 0.5 0.5 2: 1 0 3: 1 1 4: 0 1 The polygon is not convex. A five-pointed star: Row: 0 1 Col 0: 1 0 1: -0.809017 0.587785 2: 0.309017 -0.951057 3: 0.309017 0.951057 4: -0.809017 -0.587785 The polygon is not convex. A hexagon: Row: 0 1 Col 0: 1 0 1: 0.5 0.866025 2: -0.5 0.866025 3: -1 1.22465e-16 4: -0.5 -0.866025 5: 0.5 -0.866025 The polygon is convex and counterclockwise. A triangle twice: Row: 0 1 Col 0: 0 0 1: 2 0 2: 1 1 3: 0 0 4: 2 0 5: 1 1 The polygon is not convex. Square knot: Row: 0 1 Col 0: 1 0 1: 3 0 2: 3 3 3: 0 3 4: 0 1 5: 2 1 6: 2 2 7: 1 2 The polygon is not convex. POLYGON_LATTICE_AREA_TEST POLYGON_LATTICE_AREA returns the area of a polygon, measured in lattice points. Number of interior lattice points = 5 Number of boundary lattice points = 6 Area of polygon is 7 POLYGON_OUTRAD_DATA_TEST POLYGON_OUTRAD_DATA uses the outradius of a regular polygon to determine the area, inradius, and side length. Number of polygonal sides = 3 Assuming RADOUT = 1 AREA = 1.29904 RADIN = 0.5 SIDE = 1.73205 Number of polygonal sides = 4 Assuming RADOUT = 1 AREA = 2 RADIN = 0.707107 SIDE = 1.41421 Number of polygonal sides = 5 Assuming RADOUT = 1 AREA = 2.37764 RADIN = 0.809017 SIDE = 1.17557 POLYGON_PERIMETER_TEST POLYGON_PERIMETER computes the perimeter of a polygon Vertices of polygon V1: Row: 0 1 Col 0: 0 0 1: 1 0 2: 1 1 3: 0 1 Perimeter = 4 Vertices of polygon V2: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 Perimeter = 10.5571 POLYGON_PERIMETER_QUAD_TEST POLYGON_PERIMETER_QUAD estimates the integral of a function over the perimeter of a polygon using the composite midpoint rule over each side. Vertices of polygon V1: Row: 0 1 Col 0: 0 0 1: 1 0 2: 1 1 3: 0 1 Using HMAX = 0.5, estimated integral of 1 over perimeter = 4 Using HMAX = 1, estimated integral of x^2 over perimeter = 1.5 Using HMAX = 0.5, estimated integral of x^2 over perimeter = 1.625 Using HMAX = 0.25, estimated integral of x^2 over perimeter = 1.65625 Vertices of polygon V2: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 Using HMAX = 0.5, estimated integral of 1 over perimeter = 10.5571 Using HMAX = 1, estimated integral of x^2 over perimeter = 60.9706 Using HMAX = 0.5, estimated integral of x^2 over perimeter = 61.1854 Using HMAX = 0.25, estimated integral of x^2 over perimeter = 61.2383 POLYGON_POINT_DIST_TEST POLYGON_POINT_DIST computes polygon-point distance. Vertices of polygon: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 X Y DIST 4 5 1.41421 2 3 0.485071 -2 -1 3.60555 POLYGON_POINT_NEAR_TEST POLYGON_POINT_NEAR computes nearest point on polygon. Vertices of polygon: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 X Y XN YN 4 5 3 4 2 3 1.52941 3.11765 -2 -1 1 1 POLYGON_SAMPLE_TEST POLYGON_SAMPLE samples a polygon. Sample points: Row: 0 1 Col 0: 1.57165 0.0436824 1: 1.48143 0.584693 2: 1.69243 0.109957 3: 0.511266 1.44954 4: 1.44804 0.754673 5: 0.496513 0.102496 6: 0.254573 0.0136169 7: 1.86187 0.130616 8: 0.0522955 0.0875163 9: 0.180039 0.177113 10: 0.577122 1.13878 11: 1.49011 0.911977 12: 0.316961 0.238508 13: 0.117215 0.574366 14: 0.574459 1.21293 15: 0.417036 1.29933 16: 1.05162 0.886522 17: 0.866277 1.77799 18: 0.791952 1.10063 19: 0.8313 1.59303 POLYGON_SIDE_DATA_TEST POLYGON_SIDE_DATA uses the side length of a regular polygon to determine the area, inradius and outradius. Number of polygonal sides = 3 Assuming SIDE = 1 AREA = 0.433013 RADIN = 0.288675 RADOUT = 0.57735 Number of polygonal sides = 4 Assuming SIDE = 1 AREA = 1 RADIN = 0.5 RADOUT = 0.707107 Number of polygonal sides = 5 Assuming SIDE = 1 AREA = 1.72048 RADIN = 0.688191 RADOUT = 0.850651 POLYGON_TRIANGULATE_TEST POLYGON_TRIANGULATE triangulates a polygon. Here, we triangulate the comb_10 polygon. Triangles: 0: 2 0 1 1: 4 2 3 2: 6 4 5 3: 8 6 7 4: 9 6 8 5: 2 9 0 6: 4 9 2 7: 6 9 4 POLYGON_PROPERTIES_PRB Normal end of execution. 20 October 2015 01:28:24 PM