17 December 2022 04:55:47 PM polygon_test(): C++ version Test polygon(). 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 polygon_area() 2 polygon_area_2() 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 polygon_area() 6 polygon_area_2() 6 polygon_area_lattice_test(): polygon_area_lattice() returns the area of a polygon, measured in lattice points. Number of interior lattice points = 5 Number of boundary lattice points = 6 Lattice area of polygon is 7 polygon_centroid_test(): polygon_centroid() computes the centroid of a polygon. 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(): 0: 1 1: 1 polygon_centroid_2(): 0: 1 1: 1 polygon_contains_point_test(): polygon_contains_point() determines if a point is in a polygon. 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 Inside1 Inside2 1 1 1 1 3 4 0 0 0 2 1 1 0.5 -0.25 0 0 polygon_data_test(): polygon_data_inrad() uses the inradius to describe a regular polygon. polygon_data_outrad() uses the outradius to describe a regular polygon. polygon_data_side() uses the side to describe a regular polygon. Number of polygonal sides = 3 AREA = 0.433013 RADIN = 0.288675 RADOUT = 0.57735 SIDE = 1 (given) AREA = 0.433013 RADIN = 0.288675 (given) RADOUT = 0.57735 SIDE = 1 AREA = 0.433013 RADIN = 0.288675 RADOUT = 0.57735 (given) SIDE = 1 Number of polygonal sides = 4 AREA = 1 RADIN = 0.5 RADOUT = 0.707107 SIDE = 1 (given) AREA = 1 RADIN = 0.5 (given) RADOUT = 0.707107 SIDE = 1 AREA = 1 RADIN = 0.5 RADOUT = 0.707107 (given) SIDE = 1 Number of polygonal sides = 5 AREA = 1.72048 RADIN = 0.688191 RADOUT = 0.850651 SIDE = 1 (given) AREA = 1.72048 RADIN = 0.688191 (given) RADOUT = 0.850651 SIDE = 1 AREA = 1.72048 RADIN = 0.688191 RADOUT = 0.850651 (given) SIDE = 1 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_integral_test(): polygon_integral_1() integrates 1 over a polygon. polygon_integral_x() integrates x over a polygon. polygon_integral_xx() integrates x^2 over a polygon. polygon_integral_xy() integrates xy over a polygon. polygon_integral_yy() integrates y^2 over a polygon. The polygon vertices: Row: 0 1 Col 0: 1 1 1: 4 3 2: 2 5 1 5 x 11.6667 y 15 xx 29.1667 xy 35.8333 yy 48.3333 polygon_is_ccw_test(): polygon_is_cc2() determines if the vertices of a polygon are listed in counter-clockwise order. polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 1 1 3: 0 1 The polygon vertices are counter clockwise. polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 0 2: 0 1 3: 1 1 The polygon vertices are NOT counter clockwise. polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 1 2: 1 0 3: 0 1 The polygon vertices are NOT counter clockwise. polygon vertices: Row: 0 1 Col 0: 0 0 1: 1 1 2: 0 1 3: 1 0 The polygon vertices are NOT counter clockwise. polygon vertices: Row: 0 1 Col 0: 0 0 1: 0 1 2: 1 0 3: 1 1 The polygon vertices are NOT counter clockwise. polygon vertices: Row: 0 1 Col 0: 0 0 1: 0 1 2: 1 1 3: 1 0 The polygon vertices are NOT counter clockwise. 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_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_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_test(): Normal end of execution. 17 December 2022 04:55:47 PM