28-Apr-2022 21:57:20 polygon_test(): MATLAB/Octave version 9.8.0.1380330 (R2020a) Update 2 Test polygon() polygon_angles_test(): polygon_angles() computes the angles of a polygon. Number of polygonal vertices = 6 polygon vertices: 0 1 2 3 3 1 0 0 1 0 2 2 Polygonal angles in degrees: 1 63.434949 2 135.000000 3 270.000000 4 45.000000 5 90.000000 6 116.565051 polygon_area_test(): polygon_area() computes the area of a polygon. polygon_area2() computes the area of a polygon. polygon_area3() computes the area of a polygon. polygon vertices: 1 2 1 0 0 1 2 1 Exact area is 2.000000 polygon_area(): 2.000000 polygon_area_2(): 2.000000 polygon_area_3(): 2.000000 polygon vertices: 0 3 3 2 2 1 1 0 0 0 3 3 1 1 2 2 Exact area is 6.000000 polygon_area(): 6.000000 polygon_area_2(): 6.000000 polygon_area_3(): 6.000000 polygon_area_3d_test polygon_area_3d() computes the area of a polygon in 3D; polygon_area_3d_2() computes the area of a polygon in 3D; polygon vertices: 1 2 1 0 0 1 2 1 0 1 1 0 Exact area is 2.449490 polygon_area_3d(): 2.449490 polygon_area_3d_2(): 2.449490 polygon vertices: Columns 1 through 7 0 2.6268 1.4815 0.6059 1.3694 0.4938 0.1121 0 1.2601 3.9730 3.5530 1.7444 1.3243 2.2286 0 -0.7157 -0.1425 0.0960 -0.2861 -0.0475 0.1435 Column 8 -0.7635 1.8086 0.3821 Exact area is 6.000000 polygon_area_3d(): 6.000004 polygon_area_3d_2(): 6.000004 polygon_area_lattice_test(): polygon_area_lattice() computes the area of a lattice polygon based on the number of interior and boundary lattice points. interior points 1 boundary points 4 Exact area is 2.000000 Computed area 2.000000 interior points 5 boundary points 8 Exact area is 8.000000 Computed area 8.000000 interior points 13 boundary points 12 Exact area is 18.000000 Computed area 18.000000 polygon_centroid_test: polygon_centroid() computes the centroid. polygon_centroid_2() computes the centroid. polygon vertices: 1 2 1 0 0 1 2 1 polygon_centroid(): 1 1 polygon_centroid2(): 1 1 polygon_centroid_3d_test(): polygon_centroid_3d() computes the centroid of a polygon in 3D. polygon vertices: 1 2 1 0 0 1 2 1 0 1 1 0 polygon centroid: 1.0000 1.0000 0.5000 polygon_contains_point_test(): polygon_contains_point_1() determines if a point is in a polygon. polygon_contains_point_2() determines if a point is in a convex polygon. polygon_contains_point_3() determines if a point is in a simple polygon. polygon vertices: Columns 1 through 13 0 5 5 2 2 3 3 4 4 1 1 6 6 0 0 4 4 2 2 3 3 1 1 5 5 6 Column 14 0 6 P Inside Inside1 Inside2 Inside3 0.500000 5.500000 True True True True 1.500000 4.500000 False False True False 2.500000 3.500000 True True True True 3.500000 2.500000 False False True False 4.500000 1.500000 True True True True 5.500000 0.500000 False False False False polygon_data_test() For a REGULAR polygon: the inradius, outradius and side are related. polygon_data_inrad() uses the inradius; polygon_data_outrad() uses the inradius; polygon_data_side() uses the inradius; Number of polygonal sides = 3 AREA = 0.433013 RADIN = 0.288675 RADOUT = 0.577350 SIDE = 1.000000 (given) AREA = 0.433013 RADIN = 0.288675 (given) RADOUT = 0.577350 SIDE = 1.000000 AREA = 0.433013 RADIN = 0.288675 RADOUT = 0.577350 (given) SIDE = 1.000000 Number of polygonal sides = 4 AREA = 1.000000 RADIN = 0.500000 RADOUT = 0.707107 SIDE = 1.000000 (given) AREA = 1.000000 RADIN = 0.500000 (given) RADOUT = 0.707107 SIDE = 1.000000 AREA = 1.000000 RADIN = 0.500000 RADOUT = 0.707107 (given) SIDE = 1.000000 Number of polygonal sides = 5 AREA = 1.720477 RADIN = 0.688191 RADOUT = 0.850651 SIDE = 1.000000 (given) AREA = 1.720477 RADIN = 0.688191 (given) RADOUT = 0.850651 SIDE = 1.000000 AREA = 1.720477 RADIN = 0.688191 RADOUT = 0.850651 (given) SIDE = 1.000000 polygon_diameter_test(): polygon_diameter() computes the diameter of a polygon. polygon vertices: 1 2 1 0 0 1 2 1 Diameter ( computed ) 2.000000 Diameter ( exact ) 2.000000 polygon_expand_test(): polygon_expand() "expands" a polygon by an amount H. polygon vertices: 1 5 2 1 1 1 4 3 The expansion amount H = 0.500000 expanded polygon vertices: 0.5000 6.2071 2.0000 0.5000 0.5000 0.5000 4.7071 3.2071 polygon_integral_test(): polygon_integral_1 integrates 1 over a polygon. polygon_integral_x integrates x over a polygon. polygon_integral_y integrates y over a polygon. polygon_integral_xx integrates x*x over a polygon. polygon_integral_xy integrates x*y over a polygon. polygon_integral_yy integrates y*y over a polygon. polygon vertices: 0 1 1 0 0 0 1 1 F(X,Y) Integral 1 1.000000 X 0.500000 Y 0.500000 X*X 0.333333 X*Y 0.250000 Y*Y 0.333333 polygon_is_convex_test(): polygon_is_convex() determines if a polygon is convex. polygon vertices: 0 0 The polygon is degenerate and convex. polygon vertices: 0 1 0 2 The polygon is degenerate and convex. polygon vertices: 0 2 1 0 0 0 The polygon is convex and clockwise. polygon vertices: 0 1 0 0 0 2 The polygon is convex and counterclockwise. polygon vertices: 0 0 1 0 2 0 The polygon is convex and clockwise. polygon vertices: 1 2 3 0 0 0 1 1 The polygon is convex and counterclockwise. polygon vertices: 0 0.5000 1.0000 1.0000 0 0 0.5000 0 1.0000 1.0000 The polygon is not convex. polygon vertices: 1.0000 -0.8090 0.3090 0.3090 -0.8090 0 0.5878 -0.9511 0.9511 -0.5878 The polygon is not convex. polygon vertices: 1.0000 0.5000 -0.5000 -1.0000 -0.5000 0.5000 0 0.8660 0.8660 0.0000 -0.8660 -0.8660 The polygon is convex and counterclockwise. polygon vertices: 0 2 1 0 2 1 0 0 1 0 0 1 The polygon is not convex. polygon vertices: 1 3 3 0 0 2 2 1 0 0 3 3 1 1 2 2 The polygon is not convex. polygon_normal_3d_test polygon_normal_3d() computes the normal to a polygon in 3D; polygon vertices: 1 2 1 0 0 1 2 1 0 1 1 0 polygon_normal_3d(): (-0.408248,-0.408248,0.816497) polygon_area_3d(): (-0.408248,-0.408248,0.816497) polygon vertices: Columns 1 through 7 0 2.6268 1.4815 0.6059 1.3694 0.4938 0.1121 0 1.2601 3.9730 3.5530 1.7444 1.3243 2.2286 0 -0.7157 -0.1425 0.0960 -0.2861 -0.0475 0.1435 Column 8 -0.7635 1.8086 0.3821 polygon_normal_3d(): (0.295969,-0.076213,0.952152) polygon_area_3d(): (0.295969,-0.076213,0.952152) polygon_perimeter_test(): polygon_perimeter() computes the perimeter of a polygon. polygon vertices: 0 1 1 0 0 0 1 1 Perimeter of V1 = 4 polygon vertices: 1 4 2 1 3 5 Perimeter of V2 = 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. polygon vertices: 0 1 1 0 0 0 1 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 polygon vertices: 1 4 2 1 3 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 the distance to a point from a polygon. polygon vertices: 0 0 1 1 0 0 P DIST 0.250000 0.250000 0.250000 0.750000 0.250000 0.000000 1.000000 1.000000 0.707107 11.000000 0.500000 10.012492 0.000000 1.000000 0.000000 0.500000 -10.000000 10.000000 0.600000 0.600000 0.141421 polygon_point_near_test(): polygon_point_near() computes the nearest point on a polygon to a given point. polygon vertices: 0 0 1 1 0 0 P PN 0.250000 0.250000 0.000000 0.250000 0.750000 0.250000 0.750000 0.250000 1.000000 1.000000 0.500000 0.500000 11.000000 0.500000 1.000000 0.000000 0.000000 1.000000 0.000000 1.000000 0.500000 -10.000000 0.500000 0.000000 0.600000 0.600000 0.500000 0.500000 polygon_sample_test(): polygon_sample() samples a polygon. sample points: Columns 1 through 7 0.1598 1.1726 1.0088 1.0988 1.0859 0.6750 0.3848 0.9672 0.7299 0.4531 0.8718 0.7143 0.5782 1.3443 Columns 8 through 14 1.5662 0.4991 0.3467 0.3088 0.1588 0.7327 0.3594 0.1509 1.2569 0.6555 1.2769 0.0971 1.0498 0.4387 Columns 15 through 20 0.9821 1.9081 0.9693 0.8177 0.9162 0.3818 1.1869 0.4456 1.7240 1.1626 0.5016 0.5853 polygon_solid_angle_3d_test(): polygon_solid_angle_3d() computes the solid angle subtended by a planar polygon in 3D as viewed from a point P. TEST # 1 viewing point P: 0 0 0 polygon vertices: 1 0 0 0 1 0 0 0 1 Solid angle subtended: -1.570796 TEST # 2 viewing point P: 0 0 0 polygon vertices: 1 0 0 0 0 1 0 1 0 Solid angle subtended: 1.570796 TEST # 3 viewing point P: 1 2 3 polygon vertices: 2 1 1 2 3 2 3 3 4 Solid angle subtended: -1.570796 TEST # 4 viewing point P: 0 0 0 polygon vertices: 2 0 0 0 2 0 0 0 2 Solid angle subtended: -1.570796 polygon_triangulate_test(): polygon_triangulate() triangulates a polygon. Here, we triangulate the comb_10() polygon. Triangles: 1: 3 1 2 2: 5 3 4 3: 7 5 6 4: 9 7 8 5: 10 7 9 6: 3 10 1 7: 5 10 3 8: 7 10 5 polygon_test(): Normal end of execution. 28-Apr-2022 21:57:20