11-May-2022 11:56:04 geometry_test(): MATLAB/Octave version 9.8.0.1380330 (R2020a) Update 2 Test geometry() angle_box_2d_test(): angle_box_2d() Compute P4 and P5, normal to line through P1 and P2, and line through P2 and P3, and DIST units from P2. P1: 0.000000 0.000000 P2: 3.000000 0.000000 P3: 4.000000 2.000000 DIST = 1.000000 P4: 2.381966 1.000000 P5: 3.618034 -1.000000 P1: 0.000000 0.000000 P2: 3.000000 0.000000 P3: 2.000000 -2.000000 DIST = 1.000000 P4: 3.618034 -1.000000 P5: 2.381966 1.000000 P1: 3.000000 0.000000 P2: 3.000000 0.000000 P3: 2.000000 -2.000000 DIST = 1.000000 P4: 2.105573 0.447214 P5: 3.894427 -0.447214 angle_contains_point_2d_test(): angle_contains_point_2d() sees if a point lies within an angle. Vertex P1 1: 1 2: 0 Vertex P2 1: 0 2: 0 Vertex P3 1: 1 2: 1 X Y Inside? 1.000000 0.000000 1 0.866025 0.500000 0 0.500000 0.866025 1 0.000000 1.000000 1 -0.500000 0.866025 1 -0.866025 0.500000 1 -1.000000 0.000000 1 -0.866025 -0.500000 1 -0.500000 -0.866025 1 -0.000000 -1.000000 1 0.500000 -0.866025 1 0.866025 -0.500000 1 1.000000 -0.000000 1 Vertex P1 1: 1 2: 0 Vertex P2 1: 0 2: 0 Vertex P3 1: 0 2: 1 X Y Inside? 1.000000 0.000000 1 0.866025 0.500000 0 0.500000 0.866025 0 0.000000 1.000000 1 -0.500000 0.866025 1 -0.866025 0.500000 1 -1.000000 0.000000 1 -0.866025 -0.500000 1 -0.500000 -0.866025 1 -0.000000 -1.000000 1 0.500000 -0.866025 1 0.866025 -0.500000 1 1.000000 -0.000000 1 Vertex P1 1: 1 2: -1 Vertex P2 1: 0 2: 0 Vertex P3 1: 0 2: 1 X Y Inside? 1.000000 0.000000 0 0.866025 0.500000 0 0.500000 0.866025 0 0.000000 1.000000 1 -0.500000 0.866025 1 -0.866025 0.500000 1 -1.000000 0.000000 1 -0.866025 -0.500000 1 -0.500000 -0.866025 1 -0.000000 -1.000000 1 0.500000 -0.866025 1 0.866025 -0.500000 0 1.000000 -0.000000 0 Vertex P1 1: 1 2: 0 Vertex P2 1: 0 2: 0 Vertex P3 1: -1 2: 0 X Y Inside? 1.000000 0.000000 1 0.866025 0.500000 0 0.500000 0.866025 0 0.000000 1.000000 0 -0.500000 0.866025 0 -0.866025 0.500000 0 -1.000000 0.000000 1 -0.866025 -0.500000 1 -0.500000 -0.866025 1 -0.000000 -1.000000 1 0.500000 -0.866025 1 0.866025 -0.500000 1 1.000000 -0.000000 1 Vertex P1 1: 1 2: 0 Vertex P2 1: 0 2: 0 Vertex P3 1: 0 2: -1 X Y Inside? 1.000000 0.000000 1 0.866025 0.500000 0 0.500000 0.866025 0 0.000000 1.000000 0 -0.500000 0.866025 0 -0.866025 0.500000 0 -1.000000 0.000000 0 -0.866025 -0.500000 0 -0.500000 -0.866025 0 -0.000000 -1.000000 0 0.500000 -0.866025 1 0.866025 -0.500000 1 1.000000 -0.000000 1 Vertex P1 1: 1 2: 0 Vertex P2 1: 0 2: 0 Vertex P3 1: 1 2: -0.01 X Y Inside? 1.000000 0.000000 1 0.866025 0.500000 0 0.500000 0.866025 0 0.000000 1.000000 0 -0.500000 0.866025 0 -0.866025 0.500000 0 -1.000000 0.000000 0 -0.866025 -0.500000 0 -0.500000 -0.866025 0 -0.000000 -1.000000 0 0.500000 -0.866025 0 0.866025 -0.500000 0 1.000000 -0.000000 1 angle_deg_2d_test(): angle_deg_2d() computes an angle; X, Y, Theta, atan2(y, x), ANGLE_DEG_2D 1.000000 0.000000 0.000000 0.000000 0.000000 0.866025 0.500000 30.000000 30.000000 330.000000 0.500000 0.866025 60.000000 60.000000 300.000000 0.000000 1.000000 90.000000 90.000000 270.000000 -0.500000 0.866025 120.000000 120.000000 240.000000 -0.866025 0.500000 150.000000 150.000000 210.000000 -1.000000 0.000000 180.000000 180.000000 180.000000 -0.866025 -0.500000 210.000000 -150.000000 150.000000 -0.500000 -0.866025 240.000000 -120.000000 120.000000 -0.000000 -1.000000 270.000000 -90.000000 90.000000 0.500000 -0.866025 300.000000 -60.000000 60.000000 0.866025 -0.500000 330.000000 -30.000000 30.000000 1.000000 -0.000000 360.000000 -0.000000 0.000000 angle_half_test(): angle_half() computes the half angle between two rays; The angle is defined by the points (P1,P2,P3) or by the rays P2-->P3, P2-->P1. Point P1: 1: 5.77646 2: 5.89778 Point P2: 1: 5 2: 3 Point P3: 1: 6.93185 2: 3.51764 End point of unit ray from P2, defining half angle, P4: 1: 5.70711 2: 3.70711 Expected value of P4: 1: 5.70711 2: 3.70711 angle_rad_test(): angle_rad() computes the angle between two rays; Angle = 5.497787 Angle = 4.712389 Angle = 3.926991 Angle = 3.141593 Angle = 1.570796 Angle = 0.010000 angle_rad_3d_test(): angle_rad_3d() computes an angle; P, ANGLE_RAD_3D, (Degrees) 1.000000 0.000000 0.000000 1.570796 90.000000 1.000000 2.000000 3.000000 0.640522 36.699225 0.000000 0.000000 1.000000 0.000000 0.000000 angle_rad_nd_test(): angle_rad_nd() computes an angle. X, Y, Theta, atan2(y, x), ANGLE_RAD_ND 1.000000 0.000000 0.000000 0.000000 0.000000 0.866025 0.500000 30.000000 30.000000 0.523599 0.500000 0.866025 60.000000 60.000000 1.047198 0.000000 1.000000 90.000000 90.000000 1.570796 -0.500000 0.866025 120.000000 120.000000 2.094395 -0.866025 0.500000 150.000000 150.000000 2.617994 -1.000000 0.000000 180.000000 180.000000 3.141593 -0.866025 -0.500000 210.000000 -150.000000 2.617994 -0.500000 -0.866025 240.000000 -120.000000 2.094395 -0.000000 -1.000000 270.000000 -90.000000 1.570796 0.500000 -0.866025 300.000000 -60.000000 1.047198 0.866025 -0.500000 330.000000 -30.000000 0.523599 1.000000 -0.000000 360.000000 -0.000000 0.000000 angle_turn_2d_test(): angle_turn_2d() computes the turning angle defined by the line segments [P1,P2] and [P2,P3]. Our three points are: P1 = (C,S) P2 = (0,0) P3 = (1,0) C = cosine ( theta), S = sine ( theta ). Test Theta Angle 1 0.000000 3.141593 2 30.000000 2.617994 3 60.000000 2.094395 4 90.000000 1.570796 5 120.000000 1.047198 6 150.000000 0.523599 7 180.000000 0.000000 8 210.000000 5.759587 9 240.000000 5.235988 10 270.000000 4.712389 11 300.000000 4.188790 12 330.000000 3.665191 13 360.000000 3.141593 annulus_area_2d_test(): annulus_area_2d() computes the centroid of a circular annulus. The circle has center 5.000000 3.000000 The inner radius is R1 = 2.000000 The outer radius is R2 = 3.000000 Area: 15.707963 annulus_sector_area_2d_test(): annulus_sector_area_2d() computes the centroid of a circular annulus. The circle has center 5.000000 3.000000 The inner radius is R1 = 2.000000 The outer radius is R2 = 3.000000 The first angle is THETA1 = 0.523599 The second angle is THETA2 = 1.047198 Area: 1.308997 annulus_sector_centroid_2d_test(): annulus_sector_centroid_2d() computes the centroid of a circular annulus. The circle has center 5.000000 3.000000 The inner radius is R1 = 2.000000 The outer radius is R2 = 3.000000 The first angle is THETA1 = 0.523599 The second angle is THETA2 = 1.047198 Centroid: 6.770944 4.770944 ball01_sample_2d_test(): ball01_sample_2d() samples the unit ball in 2d; A few sample values: 0.749055 -0.503627 0.304860 -0.184519 0.650485 0.457415 -0.504999 -0.153212 0.954807 -0.214127 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N_SAMPLE increases. Average: -0.021388 -0.005282 Now average the distance of the points from the center, which should be 1/sqrt(2) = 0.707107 Average: 0.674822 Now average the angle THETA, which should be PI. Average: -0.038868 ball01_sample_3d_test(): ball01_sample_3d() samples the unit ball in 3d; A few sample values: -0.238046 -0.229320 -0.148215 0.033277 0.119466 0.837740 -0.058223 -0.283271 -0.092529 0.199077 -0.098204 -0.385001 -0.582869 -0.096756 -0.210215 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N_SAMPLE increases. Average: 0.000108 -0.016506 -0.011463 Now average the distance of the points from the center, which should be the 1/2**(1/dim_num) = 0.793701 Average: 0.746982 Now average the angle THETA, which should be PI. Average: -0.017083 Now average the angle PHI, which should be PI/2. Average: 1.548297 ball01_sample_nd_test(): ball_unit_sample_nd() samples the unit ball in N dimensions; A few sample values: 0.534216 -0.306679 0.703575 0.556653 -0.051317 -0.630144 -0.341479 0.041476 -0.039394 -0.055744 0.045230 -0.434734 -0.344529 -0.369594 -0.217167 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N increases. Average: 0.005864 0.009677 0.019738 Now average the distance of the points from the center, which should be the 1/2^(1/dim_num) = 0.793701 Average: 0.742164 Now average the angle THETA, which should be PI. Average: -0.099920 Now average the angle PHI, which should be PI/2. Average: 1.611906 ball01_volume_test(): ball01_volume() returns the volume of the unit ball. Volume = 4.18879 basis_map_3d_test(): basis_map_3d() computes the linear transform A which maps vectors U1, U2 and U3 to vectors V1, V2 and V3. The matrix U Col: 1 2 3 Row 1 : 1 0 1 2 : 2 0 0 3 : 3 1 2 The matrix V Col: 1 2 3 Row 1 : 14 3 7 2 : 4 1 3 3 : 4 0 2 The transformation matrix Col: 1 2 3 Row 1 : 1 2 3 2 : 1 0 1 3 : 2 1 0 The product matrix A * [ U1 | U2 | U3 ] Col: 1 2 3 Row 1 : 14 3 7 2 : 4 1 3 3 : 4 0 2 box_segment_clip_2d_test(): box_segment_clip_2d() clips a line with respect to a box. The lower left box corner is: -10.000000 10.000000 The upper right box corner is: 10.000000 20.000000 We list the points PA and PB, and then the clipped values. 1.000000 2.000000 8.000000 16.000000 5.000000 10.000000 -3.000000 12.000000 5.000000 12.000000 Line is inside the box. -20.000000 20.000000 7.000000 20.000000 -10.000000 20.000000 -20.000000 40.000000 0.000000 0.000000 -10.000000 20.000000 -5.000000 10.000000 10.000000 40.000000 20.000000 30.000000 Line is outside the box. box_ray_int_2d_test(): box_ray_int_2d() computes the intersection of the box and a ray whose origin is within the box. Lower left box corner: 0.000000 0.000000 Upper right box corner: 5.000000 3.000000 Origin: 3.000000 1.000000 Point 2: 5.000000 5.000000 Intersection: 4.000000 3.000000 Correct: 4.000000 3.000000 Origin: 4.000000 1.000000 Point 2: 3.000000 1.000000 Intersection: -0.000000 1.000000 Correct: 0.000000 1.000000 Origin: 3.000000 1.000000 Point 2: 4.000000 2.000000 Intersection: 5.000000 3.000000 Correct: 5.000000 3.000000 circle_area_2d_test(): circle_area_2d() computes the area of a circle of radius R. R Area 1.000000 3.141593 2.000000 12.566371 4.000000 50.265482 8.000000 201.061930 circle_dia2imp_2d_test(): circle_dia2imp_2d() converts a diameter to an implicit circle in 2D. P1: 1: -0.0807342 2: 7.54649 P2: 1: 4.08073 2: -1.54649 The implicit circle: Radius = 5.000000 Center = 2.000000 3.000000 circle_exp_contains_point_2d_test(): circle_exp_contains_point_2d() determines if a point lies inside a circle. P1: 1: 4 2: 2 P2: 1: 1 2: 5 P3: 1: -2 2: 2 P: 1: 2 2: 3 INSIDE = -1 The point is inside the circle. P1: 1: 4 2: 2 P2: 1: 1 2: 5 P3: 1: -2 2: 2 P: 1: 1 2: -1 INSIDE = 0 The point is on the circle. P1: 1: 4 2: 2 P2: 1: 1 2: 5 P3: 1: -2 2: 2 P: 1: 4 2: 6 INSIDE = 1 The point is outside the circle circle_exp2imp_2d_test(): circle_exp2imp_2d() computes the radius and center of the circle through three points. We can use this routine to compute, for three points in space, the circle incident to those points, and hence the radius of that circle, and hence the curvature of those points. Our three points are: (0,0) (1,0) (C,S) C = cosine ( theta), S = sine ( theta ). Test R P3 PC Theta Curvature 1 0.5 ( 1, 0) ( 0.5, 0) 0 2 2 0.5 ( 0.9, 0.5) ( 0.5, 0.1) 30 1.93185 3 0.6 ( 0.5, 0.9) ( 0.5, 0.3) 60 1.73205 4 0.7 ( 6e-17, 1) ( 0.5, 0.5) 90 1.41421 5 1 ( -0.5, 0.9) ( 0.5, 0.9) 120 1 6 2 ( -0.9, 0.5) ( 0.5, 2) 150 0.517638 7 8e+15 ( -1, 1e-16) ( 0.5, 8e+15) 180 1.22465e-16 8 2 ( -0.9, -0.5) ( 0.5, -2) 210 0.517638 9 1 ( -0.5, -0.9) ( 0.5, -0.9) 240 1 10 0.7 (-2e-16, -1) ( 0.5, -0.5) 270 1.41421 11 0.6 ( 0.5, -0.9) ( 0.5, -0.3) 300 1.73205 12 0.5 ( 0.9, -0.5) ( 0.5, -0.1) 330 1.93185 13 0.5 ( 1,-2e-16) ( 0.5, -0) 360 2 circle_imp_points_test(): circle_imp_points() gets points on a circle; polygon_area() finds the area of a polygon. The implicit circle: Radius = 2.000000 Center = 5.000000 -2.000000 The area = 12.566371 Sample results: Col: 1 2 3 4 5 Row 1 : 7 6.41421 5 3.58579 3 2 : -2 -0.585786 0 -0.585786 -2 Col: 6 7 8 Row 1 : 3.58579 5 6.41421 2 : -3.41421 -4 -3.41421 For any N, the sampled points define a polygon whose area approximates the circle area. N Area 3 5.196152 4 8.000000 5 9.510565 6 10.392305 7 10.945641 8 11.313708 9 11.570177 10 11.755705 11 11.894098 12 12.000000 13 12.082802 14 12.148745 15 12.202099 16 12.245870 17 12.282217 18 12.312725 19 12.338580 20 12.360680 21 12.379717 22 12.396233 23 12.410651 24 12.423314 circle_imp_points_arc_test(): circle_imp_points_arc() returns points on a circular arc. The implicit circle: Radius = 2.000000 Center = 5.000000 -2.000000 The arc extends from THETA1 = 1.570796 to THETA2 = 4.712389 Sample results: Row: 1 2 Col 1: 5 0 2: 4.48236 -0.0681483 3: 4 -0.267949 4: 3.58579 -0.585786 5: 3.26795 -1 6: 3.06815 -1.48236 7: 3 -2 8: 3.06815 -2.51764 9: 3.26795 -3 10: 3.58579 -3.41421 11: 4 -3.73205 12: 4.48236 -3.93185 13: 5 -4 circle_imp_point_dist_2d_test(): circle_imp_point_dist_2d() checks, by finding the distance D from a point (X,Y) to a circle. The circle: Radius = 5.000000 Center = 0.000000 0.000000 X Y D 7.3061 3.3458 3.0358 -2.9742 -5.5164 1.2671 -6.5796 -9.9190 6.9029 -0.2260 -0.3874 4.5516 -4.4528 5.3396 1.9526 5.1082 -4.0043 1.4906 -0.3274 -2.0155 2.9581 -2.4268 0.1589 2.5680 5.3536 -2.2633 0.8124 2.8517 -3.8648 0.1970 circle_imp_points_3d_test(): circle_imp_points_3d() gets points on a circle in 3D; The implicit circle: Radius = 2.000000 Center = 5.000000 -2.000000 1.000000 Normal = 1.000000 1.000000 1.000000 Points on the circle: Row: 1 2 3 Col 1: 4.1835 -2.8165 2.63299 2: 3.58579 -2 2.41421 3: 3.36701 -1.1835 1.8165 4: 3.58579 -0.585786 1 5: 4.1835 -0.367007 0.183503 6: 5 -0.585786 -0.414214 7: 5.8165 -1.1835 -0.632993 8: 6.41421 -2 -0.414214 9: 6.63299 -2.8165 0.183503 10: 6.41421 -3.41421 1 11: 5.8165 -3.63299 1.8165 12: 5 -3.41421 2.41421 circle_imp_print_2d_test(): circle_imp_print_2d() prints a circle definition. An example circle: Radius = 2.000000 Center = 5.000000 -2.000000 circle_imp_segment_intersect_test(): circle_imp_segment_intersect() finds the intersection of an implicit circle and a line segment. The implicit circle: Radius = 5.000000 Center = 5.000000 2.000000 The line segment: ( 13.000000, 8.000000 ) ( 17.000000, 11.000000 ) Number of intersections found = 0 The line segment: ( -3.000000, -4.000000 ) ( 17.000000, 11.000000 ) Number of intersections found = 2 1 9.000000 5.000000 2 1.000000 -1.000000 The line segment: ( -3.000000, -4.000000 ) ( 5.000000, 2.000000 ) Number of intersections found = 1 1 1.000000 -1.000000 circle_imp2exp_2d_test(): circle_exp2imp_2d() converts an explicit circle to an implicit circle. circle_imp2exp_2d() converts an implicit circle to an explicit circle. The implicit circle: Radius = 3.000000 Center = 10.000000 5.000000 P1: 1: 13 2: 5 P2: 1: 8.5 2: 7.59808 P3: 1: 8.5 2: 2.40192 The recovered implicit circle: Radius = 3.000000 Center = 10.000000 5.000000 circle_llr2imp_2d_test() circle_llr2imp_2d() is given: a line through P1 and P2, a line through Q1 and Q2, and a radius R, and determines the centers C of 4 circles of the given radius, tangent to both lines. Radius R = 3.542465 Point #P1: -1.748743 -7.575639 Point #P2: 4.359917 0.456186 Point #Q1: -2.268081 0.067597 Point #Q2: -8.580366 1.920429 Center #1: 4.251595 -5.538029 Center #2: 8.842523 0.498243 Center #1: -3.025150 -3.402101 Center #2: 1.565778 2.634171 3.542465 3.542465 3.542465 3.542465 3.542465 3.542465 3.542465 3.542465 Radius R = 1.001202 Point #P1: -3.188438 -5.437374 Point #P2: -2.683405 -9.259280 Point #Q1: -6.410848 -7.633027 Point #Q2: 3.856810 4.483010 Center #1: -4.422833 -3.738518 Center #2: -4.068770 -6.417941 Center #1: -2.675486 -1.676614 Center #2: -2.321422 -4.356037 1.001202 1.001202 1.001202 1.001202 1.001202 1.001202 1.001202 1.001202 Radius R = 2.111466 Point #P1: 3.317185 8.997059 Point #P2: 3.279523 -9.510225 Point #Q1: -8.995411 -1.548063 Point #Q2: -7.113533 -3.349645 Center #1: 1.170399 -8.357066 Center #2: 1.158526 -14.191808 Center #1: 5.385130 -12.391963 Center #2: 5.373256 -18.226705 2.111466 2.111466 2.111466 2.111466 2.111466 2.111466 2.111466 2.111466 Radius R = 2.708926 Point #P1: 9.391477 -4.683601 Point #P2: -1.922692 -4.635429 Point #Q1: 5.607339 4.207602 Point #Q2: 5.152402 -5.307330 Center #1: 8.024046 -1.968828 Center #2: 2.601109 -1.945739 Center #1: 7.765053 -7.385626 Center #2: 2.342116 -7.362537 2.708926 2.708926 2.708926 2.708926 2.708926 2.708926 2.708926 2.708926 Radius R = 2.240216 Point #P1: -6.905639 -9.644263 Point #P2: 1.203527 -2.025309 Point #Q1: -6.418966 5.703712 Point #Q2: -3.807348 0.535440 Center #1: 1.438402 -4.878508 Center #2: -1.965501 -8.076640 Center #1: -0.668073 -0.709891 Center #2: -4.071976 -3.908023 2.240216 2.240216 2.240216 2.240216 2.240216 2.240216 2.240216 2.240216 circle_lune_angle_by_height_2d_test(): circle_lune_angle_by_height_2d() computes the angle of a circular lune based on the "height" of the circular triangle. R H Angle 2.000000 -2.000000 6.283185 2.000000 -1.666667 5.111814 2.000000 -1.333333 4.601048 2.000000 -1.000000 4.188790 2.000000 -0.666667 3.821266 2.000000 -0.333333 3.476489 2.000000 0.000000 3.141593 2.000000 0.333333 2.806696 2.000000 0.666667 2.461919 2.000000 1.000000 2.094395 2.000000 1.333333 1.682137 2.000000 1.666667 1.171371 2.000000 2.000000 0.000000 circle_lune_area_by_angle_2d_test(): circle_lune_area_by_angle_2d() computes the area of a circular lune, defined by joining the endpoints of a circular arc. R Theta1 Theta2 Area 2.000000 0.000000 0.000000 0.000000 2.000000 0.000000 0.523599 0.047198 2.000000 0.000000 1.047198 0.362344 2.000000 0.000000 1.570796 1.141593 2.000000 0.000000 2.094395 2.456739 2.000000 0.000000 2.617994 4.235988 2.000000 0.000000 3.141593 6.283185 2.000000 0.000000 3.665191 8.330383 2.000000 0.000000 4.188790 10.109631 2.000000 0.000000 4.712389 11.424778 2.000000 0.000000 5.235988 12.204026 2.000000 0.000000 5.759587 12.519173 2.000000 0.000000 6.283185 12.566371 circle_lune_area_by_height_2d_test(): circle_lune_area_by_height_2d() computes the area of a circular lune based on the "height" of the circular triangle. R H Area 2.000000 -2.000000 12.566371 2.000000 -1.666667 12.066198 2.000000 -1.333333 11.189712 2.000000 -1.000000 10.109631 2.000000 -0.666667 8.899612 2.000000 -0.333333 7.610320 2.000000 0.000000 6.283185 2.000000 0.333333 4.956051 2.000000 0.666667 3.666759 2.000000 1.000000 2.456739 2.000000 1.333333 1.376659 2.000000 1.666667 0.500173 2.000000 2.000000 0.000000 circle_lune_centroid_2d_test(): circle_lune_centroid_2d() computes the centroid of a circular lune, defined by joining the endpoints of a circular arc. The implicit circle: Radius = 2.000000 Center = 5.000000 3.000000 The first angle of our lune is always 0. THETA2 X Y 0.00000000 7.00000000 3.00000000 0.52359878 6.69667470 3.97957560 1.04719755 5.91993537 4.59337480 1.57079633 5.00000000 4.65174336 2.09439510 4.29497984 4.22113074 2.61799388 4.01733385 3.56734257 3.14159265 4.15117364 3.00000000 3.66519143 4.50031567 2.71150712 4.18879020 4.82867320 2.70325327 4.71238898 5.00000000 2.83495363 5.23598776 5.02731339 2.95269182 5.75958653 5.00639650 2.99630698 6.28318531 5.00000000 3.00000000 circle_lune_height_by_angle_2d_test(): circle_lune_height_by_angle_2d() computes the height of the triangle of a circular lune, given the subtended angle. R Angle Height 2.000000 0.000000 2.000000 2.000000 0.523599 1.931852 2.000000 1.047198 1.732051 2.000000 1.570796 1.414214 2.000000 2.094395 1.000000 2.000000 2.617994 0.517638 2.000000 3.141593 0.000000 2.000000 3.665191 -0.517638 2.000000 4.188790 -1.000000 2.000000 4.712389 -1.414214 2.000000 5.235988 -1.732051 2.000000 5.759587 -1.931852 2.000000 6.283185 -2.000000 circle_pppr2imp_3d_test(): circle_pppr2imp_3d() is given 3D points P1, P2, P3, and a radius R, and determines the centers C of two circles of the given radius, passing through P1 and P2 and lying in the plane of P1, P2 and P3. Radius R = 22.065046 Point #1: 7.525343 -8.318750 -0.437258 Point #2: -7.653038 4.220352 0.939327 Point #3: 8.978156 3.516377 -4.461173 Center #1: 10.993613 12.212710 -7.737703 Center #2: -11.121308 -16.311108 8.239772 22.708171 24.566928 16.929108 22.241028 24.199482 14.774745 21.672583 29.732698 18.707910 19.820554 28.179435 17.945297 -11.573159 12.059338 0.303579 11.066386 -6.643550 -1.749688 -11.573159 12.059338 0.303579 11.066386 -6.643550 -1.749688 Radius R = 12.878491 Point #1: 3.254068 2.430978 -8.068004 Point #2: 4.821408 7.089459 3.541789 Point #3: 4.169945 -8.066076 -2.282706 Center #1: 4.717665 -5.674624 1.832129 Center #2: 3.357811 15.195062 -6.358344 13.070746 12.294332 10.019638 2.649312 18.921701 6.284764 11.463814 29.097755 13.136727 4.012625 17.581588 20.095842 -1.552572 -2.262839 -11.322696 -0.200072 1.757091 -1.304291 -1.552572 -2.262839 -11.322696 -0.200072 1.757091 -1.304291 Radius R = 23.376121 Point #1: 5.791190 -6.285453 -3.140923 Point #2: -8.393597 6.373080 -6.783173 Point #3: 5.609854 9.402181 -2.476646 Center #1: 11.846889 16.114867 -0.312984 Center #2: -14.449296 -16.027239 -9.611112 24.291723 31.291182 8.996030 28.048513 34.926888 12.323276 24.580581 27.147807 17.033915 23.000267 25.406683 16.278021 -8.023309 -0.430731 -2.407695 0.894658 -8.389144 -0.117814 -8.023309 -0.430731 -2.407695 0.894658 -8.389144 -0.117814 Radius R = 9.551966 Point #1: -7.015331 7.618820 -0.087495 Point #2: -6.884631 3.608746 2.314400 Point #3: 2.136305 5.421529 -4.532071 Center #1: 1.197461 3.549441 -2.776410 Center #2: -15.097422 7.678125 5.003315 10.504043 11.891239 11.543809 8.507764 10.507079 9.141336 28.401511 16.619447 13.311839 26.842918 16.043792 12.267776 -11.967637 12.712023 -0.284237 -11.747218 5.949262 3.766421 -11.967637 12.712023 -0.284237 -11.747218 5.949262 3.766421 Radius R = 10.188543 Point #1: -0.932674 -1.406477 -0.015476 Point #2: -8.845410 -1.145347 -5.273360 Point #3: -6.023642 0.237542 2.784213 Center #1: -9.600107 1.350661 4.575843 Center #2: -0.177977 -3.902485 -9.864679 15.301148 3.831679 9.338743 9.527501 12.412396 17.603091 1.450926 5.491691 15.758448 10.100650 5.823540 9.906860 0.662426 0.230716 1.498140 -6.547337 0.468648 -3.292630 0.662426 0.230716 1.498140 -6.547337 0.468648 -3.292630 circle_ppr2imp_2d_test(): circle_ppr2imp_2d() is given points P1 and P2, and a radius R, and determines the centers C of two circles of the given radius, passing through P1 and P2. Radius R = 13.921137 Point #1: -4.727777 4.367406 Point #2: 0.016961 -6.771480 Center #1: -13.888677 -6.114767 Center #2: 9.177862 3.710693 20.425638 10.573538 15.621180 6.166795 14.714186 8.463985 18.393031 11.113938 Radius R = 6.526091 Point #1: -7.585905 4.386228 Point #2: -4.548584 3.582038 Center #1: -7.688479 -2.139056 Center #2: -4.446010 10.107322 12.075143 8.499853 11.699722 6.207797 9.373760 18.595193 8.028703 16.042909 Radius R = 9.027865 Point #1: -4.777049 -0.342394 Point #2: -0.350306 -1.868217 Center #1: -5.404931 -9.348399 Center #2: 0.277575 7.137788 5.101325 10.099770 6.169082 11.701230 5.092504 14.068279 2.235768 11.712372 Radius R = 14.288856 Point #1: 7.496950 -2.705689 Point #2: 1.695198 6.109034 Center #1: 15.688069 9.002299 Center #2: -6.495920 -5.598954 20.135163 11.804366 16.957545 7.859052 14.497113 13.411700 15.032608 13.794261 Radius R = 15.969394 Point #1: -5.932874 -6.315988 Point #2: -5.074696 7.462235 Center #1: 8.868973 -0.322085 Center #2: -19.876543 1.468331 21.205605 8.210227 14.014450 9.120469 19.450310 10.741204 31.088638 8.873448 circle_sector_area_2d_test(): circle_sector_area_2d() computes the area of a circular sector, defined by joining the endpoints of a circular arc. R Theta1 Theta2 Area 2.000000 0.000000 0.000000 0.000000 2.000000 0.000000 0.523599 1.047198 2.000000 0.000000 1.047198 2.094395 2.000000 0.000000 1.570796 3.141593 2.000000 0.000000 2.094395 4.188790 2.000000 0.000000 2.617994 5.235988 2.000000 0.000000 3.141593 6.283185 2.000000 0.000000 3.665191 7.330383 2.000000 0.000000 4.188790 8.377580 2.000000 0.000000 4.712389 9.424778 2.000000 0.000000 5.235988 10.471976 2.000000 0.000000 5.759587 11.519173 2.000000 0.000000 6.283185 12.566371 circle_sector_centroid_2d_test(): circle_sector_centroid_2d() computes the centroid of a circular sector, defined by joining the endpoints of a circular arc to the center. The implicit circle: Radius = 2.000000 Center = 5.000000 3.000000 The first angle of our lune and sector is always 0. THETA2 X Y 0.00000000 6.33333333 3.00000000 0.52359878 6.14155535 3.65907729 1.04719755 5.63661977 4.10265779 1.57079633 5.00000000 4.20042175 2.09439510 4.44867110 3.95492966 2.61799388 4.14793149 3.49194198 3.14159265 4.15117364 3.00000000 3.66519143 4.39137964 2.64861287 4.18879020 4.72433555 2.52253517 4.71238898 5.00000000 2.59985942 5.23598776 5.12732395 2.77946844 5.75958653 5.10377776 2.94008388 6.28318531 5.00000000 3.00000000 circle_triangle_area_2d_test(): circle_triangle_area_2d() computes the area of a circular triangle. R Theta1 Theta2 Area 2.000000 0.000000 0.000000 0.000000 2.000000 0.000000 0.523599 1.000000 2.000000 0.000000 1.047198 1.732051 2.000000 0.000000 1.570796 2.000000 2.000000 0.000000 2.094395 1.732051 2.000000 0.000000 2.617994 1.000000 2.000000 0.000000 3.141593 0.000000 2.000000 0.000000 3.665191 -1.000000 2.000000 0.000000 4.188790 -1.732051 2.000000 0.000000 4.712389 -2.000000 2.000000 0.000000 5.235988 -1.732051 2.000000 0.000000 5.759587 -1.000000 2.000000 0.000000 6.283185 -0.000000 circles_intersect_area_2d_test(): circles_intersect_area_2d() determines the area of the intersection of two circes of radius R1 and R2, with a distance D between the centers. R1 R2 D Area 1.000000 0.500000 1.500000 0.000000 1.000000 0.500000 1.000000 0.350767 1.000000 0.500000 0.500000 0.785398 1.000000 1.000000 1.500000 0.453312 1.000000 1.000000 1.000000 1.228370 1.000000 1.000000 0.000000 3.141593 circles_intersect_points_2d_test(): circles_intersect_points_2d() determines the intersections of two circles in 2D. The first circle: Radius = 5.000000 Center = 0.000000 0.000000 The second circle: Radius = 0.500000 Center = 5.000000 5.000000 The circles do not intersect. The second circle: Radius = 5.000000 Center = 7.071068 7.071068 The circles intersect at two points: X Y 3.535329 3.535739 3.535739 3.535329 The second circle: Radius = 3.000000 Center = 4.000000 0.000000 The circles intersect at two points: X Y 4.000000 3.000000 4.000000 -3.000000 The second circle: Radius = 3.000000 Center = 6.000000 0.000000 The circles intersect at two points: X Y 4.333333 2.494438 4.333333 -2.494438 The second circle: Radius = 5.000000 Center = 0.000000 0.000000 The circles coincide (infinite intersection). cone_volume_test(): cone_volume() computes the volume of a cone. R H ConeVolume 1.00000000 1.00000000 1.04719755 1.00000000 2.00000000 2.09439510 1.00000000 4.00000000 4.18879020 1.00000000 8.00000000 8.37758041 1.00000000 16.00000000 16.75516082 1.00000000 1.00000000 1.04719755 2.00000000 1.00000000 4.18879020 4.00000000 1.00000000 16.75516082 8.00000000 1.00000000 67.02064328 16.00000000 1.00000000 268.08257311 cube_shape_test(): cube_size() returns dimension information; cube_shape() returns face and order information. shape_print() prints this information. Number of points = 8 Number of edges = 12 Number of faces = 6 Maximum face order = 4 shape_print(): Information about a polytope. The number of vertices is 8 Vertices: Index X Y Z 1 -0.577350 -0.577350 -0.577350 2 0.577350 -0.577350 -0.577350 3 0.577350 0.577350 -0.577350 4 -0.577350 0.577350 -0.577350 5 -0.577350 -0.577350 0.577350 6 0.577350 -0.577350 0.577350 7 0.577350 0.577350 0.577350 8 -0.577350 0.577350 0.577350 The number of faces is 6 The maximum order of any face is 4 Index Order Indices of Nodes in Face 1 2 3 4 1 4 1 4 3 2 2 4 1 2 6 5 3 4 2 3 7 6 4 4 3 4 8 7 5 4 1 5 8 4 6 4 5 6 7 8 cube01_volume_test(): cube01_volume() returns the volume of the unit cube. Volume = 1 cylinder_point_dist_test(): cylinder_point_dist() computes the distance to a cylinder. Radius R = 1.000000 Center of bottom disk = 0.000000 -2.000000 0.000000 Center of top disk = 0.000000 2.000000 0.000000 P = 4.000000 0.500000 0.000000 DIST (computed) = 3.000000 DIST (exact) = 3.000000 P = -0.500000 -1.000000 0.000000 DIST (computed) = 0.500000 DIST (exact) = 0.500000 P = 4.000000 6.000000 0.000000 DIST (computed) = 5.000000 DIST (exact) = 5.000000 P = 0.750000 -10.000000 0.000000 DIST (computed) = 8.000000 DIST (exact) = 8.000000 P = 0.000000 0.000000 0.000000 DIST (computed) = 1.000000 DIST (exact) = 1.000000 P = 0.250000 1.750000 0.000000 DIST (computed) = 0.250000 DIST (exact) = 0.250000 cylinder_point_dist_signed_test(): cylinder_point_dist_signed() computes the signed distance to a cylinder. Radius R = 1.000000 Center of bottom disk = 0.000000 -2.000000 0.000000 Center of top disk = 0.000000 2.000000 0.000000 P = 4.000000 0.500000 0.000000 Signed distance (computed) = 3.000000 Signed distance (exact) = 3.000000 P = -0.500000 -1.000000 0.000000 Signed distance (computed) = -0.500000 Signed distance (exact) = -0.500000 P = 4.000000 6.000000 0.000000 Signed distance (computed) = 5.000000 Signed distance (exact) = 5.000000 P = 0.750000 -10.000000 0.000000 Signed distance (computed) = 8.000000 Signed distance (exact) = 8.000000 P = 0.000000 0.000000 0.000000 Signed distance (computed) = -1.000000 Signed distance (exact) = -1.000000 P = 0.250000 1.750000 0.000000 Signed distance (computed) = -0.250000 Signed distance (exact) = -0.250000 cylinder_point_inside_test(): cylinder_point_inside() determines if a point is inside a cylinder. Radius R = 1.000000 Center of bottom disk = 0.000000 -2.000000 0.000000 Center of top disk = 0.000000 2.000000 0.000000 P = 4.000000 0.500000 0.000000 INSIDE (computed) = 0 INSIDE (exact) = 0 P = -0.500000 -1.000000 0.000000 INSIDE (computed) = 1 INSIDE (exact) = 1 P = 4.000000 6.000000 0.000000 INSIDE (computed) = 0 INSIDE (exact) = 0 P = 0.750000 -10.000000 0.000000 INSIDE (computed) = 0 INSIDE (exact) = 0 P = 0.000000 0.000000 0.000000 INSIDE (computed) = 1 INSIDE (exact) = 1 P = 0.250000 1.750000 0.000000 INSIDE (computed) = 1 INSIDE (exact) = 1 cylinder_point_near_test(): cylinder_point_near() computes the nearest point on a cylinder. Radius R = 1.000000 Center of bottom disk = 0.000000 -2.000000 0.000000 Center of top disk = 0.000000 2.000000 0.000000 P = 4.000000 0.500000 0.000000 PN (computed) = 1.000000 0.500000 0.000000 PN (exact) = 1.000000 0.500000 0.000000 P = -0.500000 -1.000000 0.000000 PN (computed) = -1.000000 -1.000000 0.000000 PN (exact) = -1.000000 -1.000000 0.000000 P = 4.000000 6.000000 0.000000 PN (computed) = 1.000000 2.000000 0.000000 PN (exact) = 1.000000 2.000000 0.000000 P = 0.750000 -10.000000 0.000000 PN (computed) = 0.750000 -2.000000 0.000000 PN (exact) = 0.750000 -2.000000 0.000000 P = 0.000000 0.000000 0.000000 PN (computed) = 1.000000 0.000000 0.000000 PN (exact) = 1.000000 0.000000 0.000000 P = 0.250000 1.750000 0.000000 PN (computed) = 0.250000 2.000000 0.000000 PN (exact) = 0.250000 2.000000 0.000000 (Note that case 5 is ambiguous. The set of nearest points forms a circle, any of which will do.) cylinder_sample_test(): cylinder_sample() samples points in a cylinder. Radius R = 1.000000 Center of bottom disk = 0.000000 -2.000000 0.000000 Center of top disk = 0.000000 2.000000 0.000000 Sample points: Row: 1 2 3 Col 1: 0.329268 1.46647 0.433183 2: -0.65376 1.23137 0.0818402 3: -0.477266 -0.634829 0.599791 4: -0.829547 -1.13316 0.163709 5: 0.421992 -1.57477 0.00263962 6: 0.310246 1.21374 -0.890821 7: -0.5944 0.0488443 -0.0338537 8: -0.925324 -0.210612 -0.212528 9: 0.383941 0.338953 -0.652633 10: -0.668447 -0.749999 -0.0680703 11: -0.679774 -1.18358 -0.129016 12: -0.829011 0.550976 -0.222317 13: -0.703614 -0.0580477 -0.30175 14: -0.466047 -1.58937 0.713791 15: 0.00191664 -1.74651 0.626359 16: -0.455071 0.888393 0.824055 17: 0.691425 -1.03053 -0.694408 18: -0.735209 0.807681 -0.193606 19: 0.566397 0.18794 0.0627 20: -0.201807 1.07701 -0.0389727 cylinder_volume_test(): cylinder_volume() computes the volume of a cylinder. Radius R = 5.000000 Center of bottom disk = 1.000000 2.000000 3.000000 Center of top disk = 5.000000 6.000000 5.000000 Volume (computed) = 471.238898 Volume (exact) = 471.238898 degrees_to_radians_test(): degrees_to_radians() converts an angle from degrees to radians; Degrees Radians Degrees -60.000000 -1.047198 -60.000000 -30.000000 -0.523599 -30.000000 0.000000 0.000000 0.000000 30.000000 0.523599 30.000000 60.000000 1.047198 60.000000 90.000000 1.570796 90.000000 120.000000 2.094395 120.000000 150.000000 2.617994 150.000000 180.000000 3.141593 180.000000 210.000000 3.665191 210.000000 240.000000 4.188790 240.000000 270.000000 4.712389 270.000000 300.000000 5.235988 300.000000 330.000000 5.759587 330.000000 360.000000 6.283185 360.000000 390.000000 6.806784 390.000000 420.000000 7.330383 420.000000 direction_pert_3d_test(): direction_pert_3d() perturbs a direction vector. The base vector: 1: 1 2: 0 3: 0 Using Sigma = 0.990000 0.993692 -0.041795 0.104069 0.973892 0.186678 0.129170 0.994625 -0.038361 0.096176 0.957213 -0.162220 0.239641 0.982560 0.080839 0.167456 0.958803 0.239372 0.152965 0.979854 -0.121284 0.158669 0.992123 0.122267 -0.027253 0.962507 0.189595 -0.193995 0.973044 0.050043 -0.225127 0.996757 -0.079675 0.011328 0.982388 0.148399 -0.113537 0.987995 -0.144537 -0.054542 0.979852 0.033354 0.196919 0.984038 -0.172982 0.041781 0.995744 0.090672 -0.016486 0.975990 -0.026880 -0.216151 0.992997 0.069054 0.095853 0.980581 0.170657 0.096626 0.993806 -0.029299 0.107201 Using Sigma = 0.500000 0.487058 0.665192 -0.565945 0.654543 0.734720 0.178214 0.918371 0.277553 -0.282063 0.739969 0.233139 0.630945 0.884851 -0.378101 -0.272174 0.611916 -0.132550 -0.779736 0.858998 0.085472 0.504793 0.904429 0.379802 0.194318 0.596050 -0.315615 -0.738317 0.271324 -0.633158 -0.724909 0.571025 0.440953 -0.692453 0.696609 0.512581 -0.501994 0.847375 0.166893 -0.504086 0.203061 -0.699816 -0.684853 0.435629 -0.468061 0.768860 0.674237 -0.560119 -0.481322 -0.083948 0.657720 0.748570 0.789627 0.014531 0.613415 -0.370116 0.567323 0.735635 0.894980 0.364938 -0.256575 Using Sigma = 0.100000 0.568881 -0.113927 -0.814491 -0.623486 -0.438106 -0.647556 -0.213283 -0.911351 0.352064 -0.811309 0.456685 0.364988 0.743569 0.207897 0.635519 -0.737033 -0.068598 0.672367 -0.081341 -0.976896 -0.197630 0.846883 -0.477452 0.234154 0.247084 -0.010715 0.968935 0.748696 0.490070 0.446414 0.240616 0.351987 -0.904549 0.521371 0.521383 0.675523 -0.494859 0.741177 -0.453621 0.255672 0.735670 -0.627234 -0.968716 -0.221097 -0.112721 -0.557848 0.397073 -0.728792 -0.768782 -0.639254 -0.018125 0.864062 0.317316 -0.390779 0.317210 -0.841058 -0.438178 -0.774232 0.077723 -0.628111 direction_uniform_3d_test(): direction_uniform_3d() picks a random direction vector. -0.598266 0.064543 0.798694 0.698282 -0.342453 0.628592 0.431721 0.538801 -0.723402 -0.243431 0.618122 0.747440 0.407983 -0.633110 -0.657815 -0.973259 -0.220073 -0.065840 0.178058 0.150137 0.972499 0.653213 0.705783 0.274195 0.518493 -0.288088 0.805090 -0.461199 0.880394 0.110461 direction_uniform_nd_test(): direction_uniform_nd() picks a random direction vector in ND. 0.457143 -0.129615 0.493491 -0.728482 -0.603293 -0.796106 0.039461 -0.026383 0.179459 0.531342 0.642711 -0.521913 0.279653 0.078748 -0.245907 0.924728 0.183463 0.035751 -0.949736 -0.251125 -0.393656 0.790560 0.205566 0.421655 -0.125218 0.777642 0.596168 -0.155492 0.439845 -0.067860 -0.752320 -0.485743 -0.284196 0.195911 -0.130974 -0.929353 0.511219 0.541909 0.633454 -0.209108 disk_point_dist_3d_test(): disk_point_dist_3d() finds the distance from a disk to a point in 3D. Disk radius = 2.000000 Disk center: 1: 0 2: 1.41421 3: 1.41421 Disk axis: 1: 0 2: 1 3: 1 Point: 1: 0 2: 0 3: 0 Distance = 2.000000, Expected = 2.000000 Point: 1: 0 2: 0.707107 3: 2.12132 Distance = 0.000000, Expected = 0.000000 Point: 1: 2 2: 1.41421 3: 1.41421 Distance = 0.000000, Expected = 0.000000 Point: 1: 10 2: 1.41421 3: 1.41421 Distance = 8.000000, Expected = 8.000000 Point: 1: 10 2: 5.65685 3: 5.65685 Distance = 10.000000, Expected = 10.000000 dms_to_radians_test(): dms_to_radians() converts an angle from degrees/minutes/seconds to radians; Radians DMS Radians -0.897598 -51 -25 -43 -0.897599 -0.448799 -25 -42 -51 -0.448797 0.000000 0 0 0 0.000000 0.448799 25 42 51 0.448797 0.897598 51 25 43 0.897599 1.346397 77 8 34 1.346395 1.795196 102 51 26 1.795197 2.243995 128 34 17 2.243994 2.692794 154 17 9 2.692796 3.141593 180 0 0 3.141593 3.590392 205 42 51 3.590390 4.039191 231 25 43 4.039191 4.487990 257 8 34 4.487988 4.936788 282 51 26 4.936790 5.385587 308 34 17 5.385587 5.834386 334 17 9 5.834388 6.283185 360 0 0 6.283185 6.731984 385 42 51 6.731982 dodec_shape_test(): For the dodecahedron, dodec_size() returns dimension information; dodec_shape() returns face and order information. shape_print() prints this information. Number of points = 20 Number of edges = 30 Number of faces = 12 Maximum face order = 5 shape_print(): Information about a polytope. The number of vertices is 20 Vertices: Index X Y Z 1 0.577350 0.577350 0.577350 2 0.577350 0.577350 -0.577350 3 0.577350 -0.577350 0.577350 4 0.577350 -0.577350 -0.577350 5 -0.577350 0.577350 0.577350 6 -0.577350 0.577350 -0.577350 7 -0.577350 -0.577350 0.577350 8 -0.577350 -0.577350 -0.577350 9 0.356822 0.934172 0.000000 10 -0.356822 0.934172 0.000000 11 0.356822 -0.934172 0.000000 12 -0.356822 -0.934172 0.000000 13 0.934172 0.000000 0.356822 14 0.934172 0.000000 -0.356822 15 -0.934172 0.000000 0.356822 16 -0.934172 0.000000 -0.356822 17 0.000000 0.356822 0.934172 18 0.000000 -0.356822 0.934172 19 0.000000 0.356822 -0.934172 20 0.000000 -0.356822 -0.934172 The number of faces is 12 The maximum order of any face is 5 Index Order Indices of Nodes in Face 1 2 3 4 5 1 5 2 9 1 13 14 2 5 5 10 6 16 15 3 5 3 11 4 14 13 4 5 8 12 7 15 16 5 5 3 13 1 17 18 6 5 2 14 4 20 19 7 5 5 15 7 18 17 8 5 8 16 6 19 20 9 5 5 17 1 9 10 10 5 3 18 7 12 11 11 5 2 19 6 10 9 12 5 8 20 4 11 12 dual_shape_test(): dual_shape() finds the dual of a polyhedron. Number of points = 20 Number of edges = 30 Number of faces = 12 Maximum face order = 5 Number of points = 12 Number of edges = 30 Number of faces = 20 Maximum face order = 3 shape_print(): Information about a polytope. The number of vertices is 12 Vertices: Index X Y Z 1 0.850651 0.525731 0.000000 2 -0.850651 0.525731 0.000000 3 0.850651 -0.525731 0.000000 4 -0.850651 -0.525731 0.000000 5 0.525731 0.000000 0.850651 6 0.525731 0.000000 -0.850651 7 -0.525731 0.000000 0.850651 8 -0.525731 0.000000 -0.850651 9 0.000000 0.850651 0.525731 10 0.000000 -0.850651 0.525731 11 0.000000 0.850651 -0.525731 12 0.000000 -0.850651 -0.525731 The number of faces is 20 The maximum order of any face is 3 Index Order Indices of Nodes in Face 1 2 3 1 3 1 9 5 2 3 1 6 11 3 3 3 5 10 4 3 3 12 6 5 3 2 7 9 6 3 2 11 8 7 3 4 10 7 8 3 4 8 12 9 3 1 11 9 10 3 2 9 11 11 3 3 10 12 12 3 4 12 10 13 3 1 5 3 14 3 1 3 6 15 3 2 4 7 16 3 2 8 4 17 3 5 9 7 18 3 5 7 10 19 3 6 8 11 20 3 6 12 8 dual_size_test(): dual_size() finds the "sizes" of the dual of a polyhedron; The cube: Number of vertices: 8 Number of edges: 12 Number of faces : 6 Maximum face order: 4 The dual of the cube: Number of vertices: 6 Number of edges: 12 Number of faces : 8 Maximum face order: 3 The dodecahedron: Number of vertices: 20 Number of edges: 30 Number of faces : 12 Maximum face order: 5 The dual of the dodecahedron: Number of vertices: 12 Number of edges: 30 Number of faces : 20 Maximum face order: 3 The icosahedron: Number of vertices: 12 Number of edges: 30 Number of faces : 20 Maximum face order: 3 The dual of the icosahedron: Number of vertices: 20 Number of edges: 30 Number of faces : 12 Maximum face order: 5 The octahedron: Number of vertices: 6 Number of edges: 12 Number of faces : 8 Maximum face order: 3 The dual of the octahedron: Number of vertices: 8 Number of edges: 12 Number of faces : 6 Maximum face order: 4 The soccer ball: Number of vertices: 60 Number of edges: 90 Number of faces : 32 Maximum face order: 6 The dual of the "soccer ball": Number of vertices: 32 Number of edges: 90 Number of faces : 60 Maximum face order: 3 halfplane_contains_point_2d_test halfplane_contains_point_2d() determines whether a halfplane bounded by (XA,YA):(XB,YB) contains the point (X,Y). P1 = 0.000000 0.000000 P2 = 2.000000 0.000000 P = 1.000000 1.000000 Contains? = 1, Correct = 1 P1 = 0.000000 0.000000 P2 = 2.000000 0.000000 P = 1.000000 -1.000000 Contains? = 0, Correct = 0 P1 = -5.000000 -5.000000 P2 = 10.000000 10.000000 P = -1.000000 1.000000 Contains? = 1, Correct = 1 P1 = 3.000000 150.000000 P2 = 1.000000 50.000000 P = 2.000000 200.000000 Contains? = 0, Correct = 0 halfspace_imp_triangle_int_3d_test(): halfspace_imp_triangle_int_3d() finds intersection points of an implicit halfspace and a triangle. The implicitly defined bounding plane has the form: A*X + B*Y + C*Z + D = 0. A,B,C,D = 1.000000 -2.000000 -3.000000 6.000000 Case 1 Triangle vertices Row: 1 2 3 Col 1: 0 0 0 2: 0 -1 0 3: 0 0 -2 Number of intersection points is 0 Intersections: (None) Case 2 Triangle vertices Row: 1 2 3 Col 1: -6 0 0 2: 0 -1 0 3: 0 0 -2 Number of intersection points is 1 Intersections: Row: 1 2 3 Col 1: -6 0 0 Case 3 Triangle vertices Row: 1 2 3 Col 1: 0 0 0 2: 0 3 0 3: 0 0 2 Number of intersection points is 3 Intersections: Row: 1 2 3 Col 1: 0 3 0 2: 0 0 2 3: 0 0 1 Case 4 Triangle vertices Row: 1 2 3 Col 1: -6 0 0 2: 0 4 0 3: 0 0 3 Number of intersection points is 3 Intersections: Row: 1 2 3 Col 1: -6 0 0 2: 0 4 0 3: 0 0 3 Case 5 Triangle vertices Row: 1 2 3 Col 1: -8 0 0 2: 0 -1 0 3: 0 0 -2 Number of intersection points is 3 Intersections: Row: 1 2 3 Col 1: -8 0 0 2: -6.4 -0.2 0 3: -7 0 -0.25 Case 6 Triangle vertices Row: 1 2 3 Col 1: 0 0 0 2: 0 4 0 3: 0 0 4 Number of intersection points is 4 Intersections: Row: 1 2 3 Col 1: 0 3 0 2: 0 4 0 3: 0 0 4 4: 0 0 1.2 halfspace_normal_triangle_int_3d_test(): halfspace_normal_triangle_int_3d() finds intersection points of a normal form halfspace and a triangle. Plane point P: 1: -6 2: 0 3: 0 Plane normal: 1: 2 2: -4 3: -6 Case 1 Triangle vertices: Row: 1 2 3 Col 1: 0 0 0 2: 0 -1 0 3: 0 0 -2 Number of intersection points is 0 Intersections: (None) Case 2 Triangle vertices: Row: 1 2 3 Col 1: -6 0 0 2: 0 -1 0 3: 0 0 -2 Number of intersection points is 1 Intersections: Row: 1 2 3 Col 1: -6 0 0 Case 3 Triangle vertices: Row: 1 2 3 Col 1: 0 0 0 2: 0 3 0 3: 0 0 2 Number of intersection points is 2 Intersections: Row: 1 2 3 Col 1: 0 3 0 2: 0 0 2 Case 4 Triangle vertices: Row: 1 2 3 Col 1: -6 0 0 2: 0 4 0 3: 0 0 3 Number of intersection points is 3 Intersections: Row: 1 2 3 Col 1: -6 0 0 2: 0 4 0 3: 0 0 3 Case 5 Triangle vertices: Row: 1 2 3 Col 1: -8 0 0 2: 0 -1 0 3: 0 0 -2 Number of intersection points is 3 Intersections: Row: 1 2 3 Col 1: -8 0 0 2: -6.4 -0.2 0 3: -6.85714 0 -0.285714 Case 6 Triangle vertices: Row: 1 2 3 Col 1: 0 0 0 2: 0 4 0 3: 0 0 4 Number of intersection points is 4 Intersections: Row: 1 2 3 Col 1: 0 3 0 2: 0 4 0 3: 0 0 4 4: 0 0 2 hexagon_contains_point_2d_test(): hexagon_contains_point_2d() reports if a hexagon contains a point. We will call the function repeatedly, and draw a sketch of an irregular hexagon in the unit square. ---------------------------------------- ---------------***---------------------- --------------*****--------------------- -------------********------------------- ------------**********------------------ -----------*************---------------- ----------***************--------------- ---------******************------------- --------********************------------ --------**********************---------- --------***********************--------- --------*************************------- --------**************************------ --------****************************---- --------*****************************--- --------*******************************- --------*******************************- --------*******************************- --------*******************************- --------******************************-- --------******************************-- --------******************************-- --------*****************************--- --------*****************************--- ---------****************************--- ----------**************************---- -----------*************************---- ------------************************---- -------------**********************----- --------------*********************----- ---------------********************----- ----------------******************------ ------------------****************------ --------------------**************------ ----------------------***********------- ------------------------*********------- --------------------------*******------- ----------------------------****-------- ------------------------------**-------- ---------------------------------------- hexagon01_shape_2d_test(): hexagon01_shape_2d(): points on a unit hexagon. Angle X Y -10.000000 0.907604 -0.160035 0.000000 1.000000 0.000000 10.000000 0.907604 0.160035 20.000000 0.826352 0.300767 30.000000 0.750000 0.433013 40.000000 0.673648 0.565258 50.000000 0.592396 0.705990 60.000000 0.500000 0.866025 70.000000 0.315207 0.866025 80.000000 0.152704 0.866025 90.000000 0.000000 0.866025 100.000000 -0.152704 0.866025 110.000000 -0.315207 0.866025 120.000000 -0.500000 0.866025 130.000000 -0.592396 0.705990 140.000000 -0.673648 0.565258 150.000000 -0.750000 0.433013 160.000000 -0.826352 0.300767 170.000000 -0.907604 0.160035 180.000000 -1.000000 0.000000 190.000000 -0.907604 -0.160035 200.000000 -0.826352 -0.300767 210.000000 -0.750000 -0.433013 220.000000 -0.673648 -0.565258 230.000000 -0.592396 -0.705990 240.000000 -0.500000 -0.866025 250.000000 -0.315207 -0.866025 260.000000 -0.152704 -0.866025 270.000000 -0.000000 -0.866025 280.000000 0.152704 -0.866025 290.000000 0.315207 -0.866025 300.000000 0.500000 -0.866025 310.000000 0.592396 -0.705990 320.000000 0.673648 -0.565258 330.000000 0.750000 -0.433013 340.000000 0.826352 -0.300767 350.000000 0.907604 -0.160035 360.000000 1.000000 0.000000 370.000000 0.907604 0.160035 hexagon01_vertices_test(): hexagon01_vertices_2d(): the vertices of the unit hexagon. Vertices: Row: 1 2 Col 1: 1 0 2: 0.5 0.866025 3: -0.5 0.866025 4: -1 0 5: -0.5 -0.866025 6: 0.5 -0.866025 hyperball01_volume_test MATLAB version HYPERBALL01_VOLUME returns the volume of the unit hyperball in M dimensions. M Volume 1 2 2 3.14159 3 4.18879 4 4.9348 5 5.26379 6 5.16771 7 4.72477 8 4.05871 9 3.29851 10 2.55016 hyperball01_volume_test Normal end of execution. hyperball01_volume_pnorm_test MATLAB version hyperball01_volume_pnorm returns the volume of the unit hyperball in M dimensions under the P_norm. Compare, for P = 2: V1 = hyperball01_volume_pnorm ( m, p ) V2 = hyperball01_volume ( m ) M P V1 V2 1 2.000000 2.000000 2.000000 2 2.000000 3.141593 3.141593 3 2.000000 4.188790 4.188790 4 2.000000 4.934802 4.934802 5 2.000000 5.263789 5.263789 6 2.000000 5.167713 5.167713 7 2.000000 4.724766 4.724766 8 2.000000 4.058712 4.058712 9 2.000000 3.298509 3.298509 10 2.000000 2.550164 2.550164 Compute volume for fixed M, a range of P values: M P V 3 1.000000 1.333333 3 2.000000 4.188790 3 3.000000 5.696584 3 4.000000 6.481987 3 5.000000 6.930355 3 6.000000 7.207670 3 7.000000 7.390319 3 8.000000 7.516700 3 9.000000 7.607654 3 10.000000 7.675236 3 11.000000 7.726795 3 12.000000 7.767011 3 13.000000 7.798976 3 14.000000 7.824797 3 15.000000 7.845953 3 16.000000 7.863500 3 17.000000 7.878215 3 18.000000 7.890675 3 19.000000 7.901318 3 20.000000 7.910481 3 Inf 8.000000 Compute volume for fixed P, a range of M values: M P V 1 3.000000 2.000000 2 3.000000 3.533278 3 3.000000 5.696584 4 3.000000 8.544875 5 3.000000 12.076566 6 3.000000 16.225532 7 3.000000 20.861398 8 3.000000 25.798188 9 3.000000 30.810033 10 3.000000 35.651609 11 3.000000 40.080419 12 3.000000 43.877982 13 3.000000 46.867470 14 3.000000 48.926026 15 3.000000 49.990918 16 3.000000 50.059586 17 3.000000 49.184328 18 3.000000 47.462906 19 3.000000 45.026624 20 3.000000 42.027395 21 3.000000 38.625202 22 3.000000 34.976989 23 3.000000 31.227726 24 3.000000 27.503961 25 3.000000 23.909921 hyperball01_volume_pnorm_test Normal end of execution. i4_wrap_test(): i4_wrap() forces an integer to lie within given limits. ILO = 4 IHI = 8 I I4_WRAP(I) -10 5 -9 6 -8 7 -7 8 -6 4 -5 5 -4 6 -3 7 -2 8 -1 4 0 5 1 6 2 7 3 8 4 4 5 5 6 6 7 7 8 8 9 4 10 5 11 6 12 7 13 8 14 4 15 5 16 6 17 7 18 8 19 4 20 5 i4col_find_item_test(): i4col_find_item() finds the first occurrence of an item in an I4COL. The matrix of columns: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 Item 34 occurs in row 3 and column 4. Item 12 occurs in row 1 and column 2. Item 90 occurs in row -1 and column -1. i4col_find_pair_wrap_test(): i4col_find_pair_wrap() finds the first occurrence of a pair of item in an I4COL. Items in the array are ordered by column, and wraparound is allowed. The matrix of columns: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 Item 22 followed by item 32 occurs in row 2 and column 2 Item 32 followed by item 22 occurs in row -1 and column -1 Item 22 followed by item 23 occurs in row -1 and column -1 Item 54 followed by item 14 occurs in row 5 and column 4 Item 54 followed by item 11 occurs in row -1 and column -1 i4vec_heap_d_test(): i4vec_heap_d() puts into descending heap form. Unsorted array: 1: 10 2: 3 3: 2 4: 2 5: 9 6: 1 7: 8 8: 9 9: 5 10: 9 Descending heap form: 1: 10 2: 9 3: 8 4: 5 5: 9 6: 1 7: 2 8: 2 9: 3 10: 9 i4vec_indicator1_test(): i4vec_indicator1() returns an indicator vector. The "indicator1" vector: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 i4vec_lcm_test(): i4vec_lcm() computes the least common multiple of the entries in an I4VEC. The I4VEC: 1: 120120 2: 90090 3: 750750 4: 330330 LCM = 99099000 i4vec_print_test(): i4vec_print() prints an I4VEC The I4VEC: 1: 91 2: 92 3: 93 4: 94 icos_shape_test(): For the icosahedron, icos_size() returns dimension information; icos_shape() returns face and order information. shape_print() prints this information. Number of points = 12 Number of edges = 30 Number of faces = 20 Maximum face order = 3 shape_print(): Information about a polytope. The number of vertices is 12 Vertices: Index X Y Z 1 0.850651 0.525731 0.000000 2 0.850651 -0.525731 0.000000 3 0.525731 0.000000 0.850651 4 0.525731 0.000000 -0.850651 5 0.000000 0.850651 0.525731 6 0.000000 0.850651 -0.525731 7 0.000000 -0.850651 0.525731 8 0.000000 -0.850651 -0.525731 9 -0.525731 0.000000 0.850651 10 -0.525731 0.000000 -0.850651 11 -0.850651 0.525731 0.000000 12 -0.850651 -0.525731 0.000000 The number of faces is 20 The maximum order of any face is 3 Index Order Indices of Nodes in Face 1 2 3 1 3 1 2 4 2 3 1 3 2 3 3 1 4 6 4 3 1 5 3 5 3 1 6 5 6 3 2 3 7 7 3 2 7 8 8 3 2 8 4 9 3 3 5 9 10 3 3 9 7 11 3 4 8 10 12 3 4 10 6 13 3 5 6 11 14 3 5 11 9 15 3 6 10 11 16 3 7 9 12 17 3 7 12 8 18 3 8 12 10 19 3 9 11 12 20 3 10 12 11 line_exp_perp_2d_test(): line_exp_perp_2d() is given an explicit line (P1,P2), and another point P3. It then finds a point P4 on (P1,P2) so that (P1,P2) is perpendicular to (P3,P4). Point P1: 1: 1 2: 3 Point P2: 1: 4 2: 0 Point P3: 1: 0 2: 0 Point P4: 1: 2 2: 2 Point P3: 1: 5 2: -1 Point P4: 1: 5 2: -1 Point P3: 1: 5 2: 3 Point P4: 1: 3 2: 1 line_exp_normal_test(): line_exp_normal() determines a unit normal vector to a given explicit line. Point 1: 1: 1 2: 3 Point 2: 1: 4 2: 0 Normal vector N: 1: 0.707107 2: 0.707107 line_exp_point_dist_test(): line_exp_point_dist() finds the distance from an explicit line to a point in 2D. Point 1: 1: 1 2: 3 Point 2: 1: 4 2: 0 Point: 1: 0 2: 0 Distance = 2.828427 Point: 1: 5 2: -1 Distance = 0.000000 Point: 1: 5 2: 3 Distance = 2.828427 line_exp_point_dist_3d_test(): line_exp_point_dist_3d() finds the distance from an explicit line to a point in 3D. Point 1: 1: 1 2: 3 3: 2 Point 2: 1: 4 2: 0 3: 1 Point: 1: 0 2: 5 3: 5 Distance = 2.533980 Point: 1: 0 2: -1 3: 3 Distance = 3.825125 Point: 1: 2 2: 1 3: 3 Distance = 1.622214 line_exp_point_dist_signed_test(): line_exp_point_dist_signed() finds the signed distance to a point from an explicit line. Point 1: 1: 1 2: 3 Point 2: 1: 4 2: 0 Point: 1: 0 2: 0 Signed distance = 2.828427 Point: 1: 5 2: -1 Signed distance = 0.000000 Point: 1: 5 2: 3 Signed distance = -2.828427 line_exp_point_near_2d_test(): line_exp_point_near_2d() finds the point on a line nearest in point in 2D. The point P1: 1: 1 2: 3 The point P2: 1: 4 2: 0 The point P: 1: 0 2: 0 Nearest point PN: 1: 2 2: 2 Distance = 2.828427 Relative line position T = 0.333333 The point P: 1: 5 2: -1 Nearest point PN: 1: 5 2: -1 Distance = 0.000000 Relative line position T = 1.333333 The point P: 1: 5 2: 3 Nearest point PN: 1: 3 2: 1 Distance = 2.828427 Relative line position T = 0.666667 line_exp2imp_2d_test(): line_exp2imp_2d() converts explicit to implicit lines. Implicit line A, B, C = 1.000000 2.000000 3.000000 The point P1: 1: -0.6 2: -1.2 The point P2: 1: -1.2 2: -0.9 Recovered A, B, C = 0.238095 0.476190 0.714286 line_exp2par_2d_test(): line_exp2par_2d() converts explicit to parametric lines. line_par2exp_2d() converts parametric to explicit lines. Parametric line: F, G = 1.000000 2.000000 X0, Y0 = 3.000000 4.000000 The point P1: 1: 3 2: 4 The point P2: 1: 4 2: 6 Recovered parametric line: F, G = 0.447214 0.894427 X0, Y0 = 3.000000 4.000000 line_imp2exp_2d_test(): line_imp2exp_2d() converts implicit to explicit lines. Implicit line A, B, C = 1.000000 2.000000 3.000000 The point P1: 1: -0.6 2: -1.2 The point P2: 1: -1.2 2: -0.9 Recovered A, B, C = 0.238095 0.476190 0.714286 line_imp_point_dist_2d_test(): line_imp_point_dist_2d() finds the distance from a point X Y to a line A * X + B * Y + C = 0. X Y A B C DIST 0.000000 6.000000 2.000000 5.000000 3.000000 6.127946 0.000000 5.000000 2.000000 5.000000 3.000000 5.199469 0.000000 4.000000 2.000000 5.000000 3.000000 4.270993 line_par_point_dist_2d_test(): line_par_point_dist_2d() finds the distance of a point on a parametric line (X0,Y0,F,G) nearest a point P in 2D. Parametric line: X(t) = 1 + 1 * t Y(t) = 3 + -1 * t The point P: 1: 0 2: 0 Distance = 2.82843 Nearest point PN: 1: 2 2: 2 Distance recomputed = 2.82843 The point P: 1: 5 2: -1 Distance = 0 Nearest point PN: 1: 5 2: -1 Distance recomputed = 0 The point P: 1: 5 2: 3 Distance = 2.82843 Nearest point PN: 1: 3 2: 1 Distance recomputed = 2.82843 line_par_point_dist_3d_test(): line_par_point_dist_3d() finds the distance. from a parametric line to a point in 3D. Parametric line: X(t) = 1 + -3 * t Y(t) = 3 + -3 * t Z(t) = 2 + -1 * t The point P: 1: 0 2: 0 3: 2 Distance = 2.84697 Nearest point PN: 1: 1.94737 2: 2.05263 3: 1.68421 Distance recomputed = 2.84697 The point P: 1: 5 2: -1 3: 1 Distance = 0.324443 Nearest point PN: 1: 4.94737 2: -0.947368 3: 0.684211 Distance recomputed = 0.324443 The point P: 1: 5 2: 3 3: 3 Distance = 3.26061 Nearest point PN: 1: 2.73684 2: 1.26316 3: 1.42105 Distance recomputed = 3.26061 line_par_point_near_2d_test(): line_par_point_near_2d() finds the point on a parametric line (X0,Y0,F,G) nearest a point P in 2D. Parametric line: X(t) = 1 + 1 * t Y(t) = 3 + -1 * t The point P: 1: 0 2: 0 Distance = 2.82843 Nearest point PN: 1: 2 2: 2 Distance recomputed = 2.82843 The point P: 1: 5 2: -1 Distance = 0 Nearest point PN: 1: 5 2: -1 Distance recomputed = 0 The point P: 1: 5 2: 3 Distance = 2.82843 Nearest point PN: 1: 3 2: 1 Distance recomputed = 2.82843 line_par_point_near_3d_test(): line_par_point_near_3d() finds nearest point on a parametric line to a point in 3D. Parametric line: X(t) = 1 + -3 * t Y(t) = 3 + -3 * t Z(t) = 2 + -1 * t The point P: 1: 0 2: 0 3: 2 Distance = 2.84697 Nearest point PN: 1: 1.94737 2: 2.05263 3: 1.68421 Distance recomputed = 2.84697 The point P: 1: 5 2: -1 3: 1 Distance = 0.324443 Nearest point PN: 1: 4.94737 2: -0.947368 3: 0.684211 Distance recomputed = 0.324443 The point P: 1: 5 2: 3 3: 3 Distance = 3.26061 Nearest point PN: 1: 2.73684 2: 1.26316 3: 1.42105 Distance recomputed = 3.26061 line_par2exp_2d_test(): line_par2exp_2d() converts parametric to explicit lines. line_exp2par_2d() converts explicit to parametric lines. Parametric line: F, G = 1.000000 2.000000 X0, Y0 = 3.000000 4.000000 The point P1: 1: 3 2: 4 The point P2: 1: 4 2: 6 Recovered parametric line: F, G = 0.447214 0.894427 X0, Y0 = 3.000000 4.000000 lines_exp_angle_3d_test(): lines_exp_angle_3d() finds the angle between two explicit lines in 3D; Angle between lines is 1.892547 Angle between lines is 1.570796 lines_exp_dist_3d_test(): lines_exp_dist_3d() finds the distance between two explicit lines in 3D. lines_exp_dist_3d_2() finds the distance between two explicit lines in 3D. P1 0.000000 0.000000 0.000000 P2 1.000000 2.000000 0.000000 Q1 0.000000 3.000000 3.000000 Q2 3.000000 0.000000 3.000000 LINES_EXP_DIST_3D = 3.000000 LINES_EXP_DIST_3D_2 = 3.000000 P1 4.000000 -3.000000 0.000000 P2 -8.000000 6.000000 0.000000 Q1 3.000000 4.000000 -1.000000 Q2 3.000000 4.000000 3.000000 LINES_EXP_DIST_3D = 5.000000 LINES_EXP_DIST_3D_2 = 5.000000 lines_exp_equal_2d_test(): lines_exp_equal_2d() tries to determine if two explicit lines in 2D are equal. P1 0.000000 0.000000 P2 1.000000 2.000000 Q1 0.000000 0.000000 Q2 1.000000 2.000000 The lines are equal. P1 0.000000 0.000000 P2 1.000000 2.000000 Q1 1.000000 2.000000 Q2 0.000000 0.000000 The lines are equal. P1 0.000000 0.000000 P2 1.000000 2.000000 Q1 0.000000 0.000000 Q2 2.000000 4.000000 The lines are equal. P1 0.000000 0.000000 P2 1.000000 2.000000 Q1 7.000000 14.000000 Q2 5.500000 11.000000 The lines are equal. P1 0.000000 0.000000 P2 1.000000 2.000000 Q1 1.000000 2.000000 Q2 3.000000 5.000000 The lines are distinct. P1 0.000000 0.000000 P2 1.000000 2.000000 Q1 0.000000 10.000000 Q2 1.000000 12.000000 The lines are distinct. lines_exp_int_2d_test(): lines_exp_int_2d() finds intersections of two explicit lines in 2D. P1 0.000000 2.000000 P2 4.000000 0.000000 Q1 0.000000 -1.000000 Q2 1.000000 0.000000 Intersection at 2.000000 1.000000 P1 0.000000 2.000000 P2 4.000000 0.000000 Q1 0.000000 0.250000 Q2 0.500000 0.000000 Lines are parallel, no intersection. P1 0.000000 2.000000 P2 4.000000 0.000000 Q1 0.000000 2.000000 Q2 4.000000 0.000000 Lines are coincident. lines_exp_near_3d_test(): lines_exp_near_3d() finds nearest points on two explicit lines in 3D. P1 0.000000 0.000000 0.000000 P2 1.000000 2.000000 0.000000 Q1 0.000000 3.000000 3.000000 Q2 3.000000 0.000000 3.000000 PN 1.000000 2.000000 0.000000 QN 1.000000 2.000000 3.000000 P1 4.000000 -3.000000 0.000000 P2 -8.000000 6.000000 0.000000 Q1 3.000000 4.000000 -1.000000 Q2 3.000000 4.000000 3.000000 PN 0.000000 0.000000 0.000000 QN 3.000000 4.000000 0.000000 lines_imp_angle_2d_test(): lines_imp_angle_2d() finds the angle between two lines written in implicit form. Line 1 coefficients: 1.000000 2.000000 -4.000000 Line 2 coefficients: 1.000000 -1.000000 -1.000000 Angle between lines is 108.434949 Line 1 coefficients: 1.000000 2.000000 -4.000000 Line 2 coefficients: 2.000000 4.000000 -1.000000 Angle between lines is 0.000001 Line 1 coefficients: 1.000000 2.000000 -4.000000 Line 2 coefficients: -3.000000 -6.000000 12.000000 Angle between lines is 179.999999 lines_imp_int_2d_test(): lines_imp_int_2d() finds the intersection of two lines written in implicit form. Line 1 coefficients: 1.000000 2.000000 -4.000000 Line 2 coefficients: 1.000000 -1.000000 -1.000000 Intersection at 2.000000 1.000000 Line 1 coefficients: 1.000000 2.000000 -4.000000 Line 2 coefficients: 2.000000 4.000000 -1.000000 Lines are parallel, no intersection. Line 1 coefficients: 1.000000 2.000000 -4.000000 Line 2 coefficients: -3.000000 -6.000000 12.000000 Lines are coincident. lines_imp_dist_3d_test(): lines_imp_dist_3d() finds the distance between two implicit lines in 2D. A1 B1 C1 A2 B2 C2 DIST 4.000000 -1.000000 3.000000 4.000000 -1.000000 12.000000 2.182821 2.000000 -1.000000 0.000000 4.000000 -2.000000 6.000000 1.341641 1.000000 2.000000 2.000000 2.000000 3.000000 1.000000 0.000000 lines_par_int_2d_test(): lines_par_int_2d() finds the intersection of two lines written in parametric form. Line 1 parameters: 0.000000 1.000000 2.000000 1.000000 Line 2 parameters: 10.000000 -2.000000 1.000000 1.000000 Line 1 evaluated at T1: T1 = 13.000000 X(T1)= 26.000000 Y(T1)= 14.000000 Line 2 evaluated at T2: T2 = 16.000000 X(T2)= 26.000000 Y(T2)= 14.000000 Reported intersection: PINT(1) = 26.000000 PINT(2) = 14.000000 minabs_test() minabs() finds the minimum of a function F(X) = a * ABS ( X ) + B within an interval, given three data points. The points lie on a straight line. XMIN, YMIN = 9.000000 2.000000 The points straddle a minimum. XMIN, YMIN = 7.000000 2.000000 The points straddle a maximum. XMIN, YMIN = 2.000000 5.000000 minquad_test(): minquad() finds the minimum of a function F(X) = A * X * X + B * X + C within an interval, given three data points. The minimum lies in the interval. X1, Y1 = 0.000000 5.000000 X2, Y2 = 2.000000 5.000000 X3, Y3 = 3.000000 8.000000 XMIN, YMIN = 1.000000 4.000000 The minimum is to the left of the interval X1, Y1 = 2.000000 5.000000 X2, Y2 = 4.000000 13.000000 X3, Y3 = 5.000000 20.000000 XMIN, YMIN = 2.000000 5.000000 The function is flat. X1, Y1 = 11.000000 6.000000 X2, Y2 = 6.000000 6.000000 X3, Y3 = 2.000000 6.000000 XMIN, YMIN = 11.000000 6.000000 The function has a maximum. X1, Y1 = 0.000000 3.000000 X2, Y2 = 2.000000 3.000000 X3, Y3 = 3.000000 0.000000 XMIN, YMIN = 3.000000 0.000000 octahedron_shape_test(): octahedron_size() returns dimension information; octahedron_shape() returns face and order information. We will use this information to compute the areas and centers of each face. Number of points = 6 Number of edges = 12 Number of faces = 8 Maximum face order = 3 Face Order Area 1 3 0.866025 2 3 0.866025 3 3 0.866025 4 3 0.866025 5 3 0.866025 6 3 0.866025 7 3 0.866025 8 3 0.866025 Face Center 1 0.333333 -0.333333 -0.333333 2 0.333333 0.333333 -0.333333 3 -0.333333 0.333333 -0.333333 4 -0.333333 -0.333333 -0.333333 5 0.333333 -0.333333 0.333333 6 0.333333 0.333333 0.333333 7 -0.333333 0.333333 0.333333 8 -0.333333 -0.333333 0.333333 parabola_ex_test(): parabola_ex() finds the extreme value of a parabola determined by three points. parabola_ex2() finds the extreme value of a parabola determined by three points. Parabolic coefficients (A,B,C) = 2.000000 -4.000000 10.000000 X, Y data X1, Y1 = 1.000000 8.000000 X2, Y2 = 2.000000 10.000000 X3, Y3 = 3.000000 16.000000 PARABOLA_EX returns (XMIN,YMIN) = 1.000000 8.000000 PARABOLA_EX2 returns (XMIN,YMIN) = 1.000000 8.000000 and (A,B,C) = 2.000000 -4.000000 10.000000 parallelipiped_point_dist_3d_test() parallelipiped_point_dist_3d() computes the distance from a point to a box (parallelipiped) in 3D. The 4 box corners that are specified: 1 0.000000 0.000000 0.000000 2 2.000000 0.000000 0.000000 3 0.000000 8.000000 0.000000 4 0.000000 0.000000 1.000000 I P Distance to box 1 1.000000 4.000000 0.500000 1.118034 2 1.000000 0.000000 0.500000 0.000000 3 0.000000 4.000000 1.000000 0.000000 4 2.000000 8.000000 1.000000 0.000000 5 -0.500000 4.000000 0.500000 0.707107 6 1.000000 -1.000000 -1.000000 1.414214 7 3.000000 9.000000 2.000000 1.732051 parallelogram_area_test(): parallelogram_area() finds the area of a parallelogram. Vertices: Row: 1 2 Col 1: 2 7 2: 5 7 3: 6 9 4: 3 9 AREA = 6.000000 parallelogram_area_3d_test(): parallelogram_area_3d() finds the area of a parallelogram in 3D. Vertices: Row: 1 2 3 Col 1: 1 2 3 2: 2.41421 3.41421 3 3: 1.70711 2.70711 4 4: 0.292893 0.292893 4 AREA = 2.000000 parallelogram_contains_point_3d_test(): parallelogram_contains_point_3d() determines if a point is within a parallelogram in 3D. P Inside? 1.000000 1.000000 0.500000 1 3.000000 3.000000 0.000000 0 0.500000 0.500000 -0.100000 0 0.100000 0.100000 0.500000 0 1.500000 1.600000 0.500000 0 parallelogram_contains_point_2d_test(): parallelogram_contains_point_2d() determines if a point is within a parallelogram in 2D. P Inside? 1.000000 0.500000 1 2.000000 0.000000 0 0.500000 -0.100000 0 0.100000 0.500000 0 plane_exp_normal_test() plane_exp_normal() finds the normal to a plane. Three points on the plane: P1: -10.560000 -10.560000 78.090000 P2: 44.660000 -65.770000 0.000000 P3: 44.660000 44.660000 0.000000 The normal vector: 1: 0.816487 2: 0 3: 0.577364 plane_exp2imp_3d_test(): plane_exp2imp_3d() puts a plane defined by 3 points into A*X+B*Y+C*Z+D = 0 form. P1, P2, P3: -1.000000 0.000000 -1.000000 -4.000000 0.000000 0.000000 -20.000000 2.000000 4.000000 (A,B,C,D)= -2.000000 -4.000000 -6.000000 -8.000000 Correct answer is a multiple of 1, 2, 3, 4. P1, P2, P3: -16.000000 2.000000 4.000000 0.000000 0.000000 0.000000 4.000000 -2.000000 0.000000 (A,B,C,D)= -8.000000 -16.000000 -24.000000 0.000000 Correct answer is a multiple of 1, 2, 3, 0. plane_exp2normal_3d_test(): plane_exp2normal_3d() puts a plane defined by 3 points into point, normal form. P1, P2, P3: -1.000000 0.000000 -1.000000 -4.000000 0.000000 0.000000 -20.000000 2.000000 4.000000 The point PP: 1: -1 2: 0 3: -1 Normal vector: 1: -0.267261 2: -0.534522 3: -0.801784 P1, P2, P3: -16.000000 2.000000 4.000000 0.000000 0.000000 0.000000 4.000000 -2.000000 0.000000 The point PP: 1: -16 2: 2 3: 4 Normal vector: 1: -0.267261 2: -0.534522 3: -0.801784 plane_exp_project_test(): plane_exp_project() projects a point through a focus point into a plane. PO, PP, IVIS 0.000000 2.000000 2.000000 0.000000 0.500000 0.500000 3 4.000000 5.000000 -8.000000 4.000000 5.000000 -8.000000 3 0.250000 0.250000 0.250000 0.333333 0.333333 0.333333 1 5.000000 -2.000000 -3.000000 7647803531873692.000000 -3059121412749477.000000 -4588682119124216.000000 1 -2.000000 0.000000 0.000000 1.000000 0.000000 0.000000 -1 plane_imp2exp_3d_test(): plane_imp2exp_3d() converts a plane in implicit (A,B,C,D) form to explicit form. (A,B,C,D) = 1.000000 -2.000000 -3.000000 6.000000 P1, P2, P3: -6.000000 0.000000 0.000000 -6.963624 -0.148250 -0.222375 -6.000000 -0.832050 0.554700 plane_imp2normal_3d_test(): plane_imp2normal_3d() converts a plane in implicit (A,B,C,D) form to point, normal form. Input: (A,B,C,D) = 1.000000 -2.000000 -3.000000 6.000000 The point PP: 1: -6 2: 0 3: 0 Normal vector: 1: 0.267261 2: -0.534522 3: -0.801784 plane_imp_line_par_int_3d_test(): plane_imp_line_par_int_3d() finds the intersection of an implicit plane and a parametric line, in 3D. The plane and line intersect at 7.000000 2.000000 3.000000 Expected answer: The plane and line intersect at 7, 2, 3. plane_imp_point_dist_3d_test(): plane_imp_point_dist_3d() computes the distance between an implicit plane and a point in 3D; For all tests, we use the implicit plane with (A,B,C,D) = 0.000000 0.000000 1.000000 -10.000000 (X,Y,Z) DISTANCE -12.000000 14.000000 0.000000 10.000000 7.000000 8.000000 9.000000 1.000000 1.000000 2.000000 10.000000 0.000000 0.000000 0.000000 12.000000 2.000000 plane_imp_point_dist_signed_3d_test(): plane_imp_point_dist_signed_3d() computes the signed distance between an implicit plane and a point in 3D. For all tests, we use the implicit plane with (A,B,C,D) = 0.000000 0.000000 1.000000 -10.000000 (X,Y,Z) SIGNED_DISTANCE -12.000000 14.000000 0.000000 -10.000000 7.000000 8.000000 9.000000 -1.000000 1.000000 2.000000 10.000000 0.000000 0.000000 0.000000 12.000000 2.000000 plane_imp_segment_near_3d_test(): plane_imp_segment_near_3d() finds the point on a line segment nearest a plane. The distance between the plane and the line segment is 0.000000 A nearest point on the line segment is 7.000000 2.000000 3.000000 A nearest point on the plane is 7.000000 2.000000 3.000000 The distance between the plane and the line segment is 4.008919 A nearest point on the line segment is 5.000000 1.000000 -2.000000 A nearest point on the plane is 3.928571 3.142857 1.214286 plane_imp_triangle_near_3d_test(): plane_imp_triangle_near_3d() finds the nearest points on an implicit plane and a triangle. Implicit plane: A*X + B*Y + C*Z + D = 0. A,B,C,D = 1.000000 -2.000000 -3.000000 6.000000 Triangle vertices: Row: 1 2 3 Col 1: 3 0 -7 2: 13 -4 -1 3: 5 1 -2 Triangle to plane distance is 4.008919 Nearest points: Row: 1 2 3 Col 1: 5 1 -2 2: 3.92857 3.14286 1.21429 3: 5 1 -2 4: 3.92857 3.14286 1.21429 Triangle vertices: Row: 1 2 3 Col 1: 3 0 -7 2: 13 -4 -1 3: 9 3 8 Triangle to plane distance is 0.000000 Nearest points: Row: 1 2 3 Col 1: 10.3333 0.666667 5 2: 7 2 3 plane_imp_triangle_int_3d_test plane_imp_triangle_int_3d() finds the intersection points of an implicit plane and a triangle. The implicit plane: A*X + B*Y + C*Z + D = 0. A,B,C,D = 1.000000 -2.000000 -3.000000 6.000000 Case 1 Triangle vertices: Row: 1 2 3 Col 1: 3 0 -7 2: 13 -4 -1 3: 5 1 -2 Number of intersection points is 0 Intersection points: (None) Case 2 Triangle vertices: Row: 1 2 3 Col 1: 3 0 -7 2: 13 -4 -1 3: 9 3 8 Number of intersection points is 2 Intersection points: Row: 1 2 3 Col 1: 7 2 3 2: 10.3333 0.666667 5 Case 3 Triangle vertices: Row: 1 2 3 Col 1: -6 0 0 2: 0 3 0 3: 0 0 2 Number of intersection points is 3 Intersection points: Row: 1 2 3 Col 1: -6 0 0 2: 0 3 0 3: 0 0 2 Case 4 Triangle vertices: Row: 1 2 3 Col 1: -4 1 0 2: 0 6 -2 3: 0 0 1 Number of intersection points is 2 Intersection points: Row: 1 2 3 Col 1: -4 1 0 2: 0 6 -2 plane_normal_basis_3d_test(): plane_normal_basis_3d(), given a plane in point, normal form (P,N), finds two unit vectors Q and R that "lie" in the plane and are mutually orthogonal. Data for test 1: Point PP: 1: 0.5219 2: 0.4122 3: 0.539978 Normal vector N: 1: 0.340288 2: 0.806919 3: 0.48279 Vector PQ: 1: 0.940321 2: -0.292011 3: -0.174714 Vector PR: 1: 0 2: -0.513431 3: 0.858131 Dot product matrix: Col: 1 2 3 Row 1 : 1 0 5.55112e-17 2 : 0 1 0 3 : 5.55112e-17 0 1 Dot product matrix: Col: 1 2 3 Row 1 : 1 2.77556e-17 -5.55112e-17 2 : 2.77556e-17 1 2.77556e-17 3 :-5.55112e-17 2.77556e-17 1 Dot product matrix: Col: 1 2 3 Row 1 : 1 -1.11022e-16 -5.55112e-17 2 :-1.11022e-16 1 -2.77556e-17 3 :-5.55112e-17 -2.77556e-17 1 Dot product matrix: Col: 1 2 3 Row 1 : 1 2.77556e-17 0 2 : 2.77556e-17 1 -6.93889e-18 3 : 0 -6.93889e-18 1 Dot product matrix: Col: 1 2 3 Row 1 : 1 0 -5.55112e-17 2 : 0 1 0 3 :-5.55112e-17 0 1 plane_normal_line_exp_int_3d_test(): plane_normal_line_exp_int_3d() finds the intersection of a normal plane and an explicit line, in 3D. Plane point PP: 1: -1 2: 1 3: 1 Plane Normal: 1: 0.267261 2: -0.534522 3: -0.801784 Line point P1: 1: 3 2: 0 3: -7 Line point P2: 1: 5 2: 1 3: -2 The plane and line intersect at 7.000000 2.000000 3.000000 Expected answer: The plane and line intersect at 7, 2, 3. plane_normal_qr_to_xyz_test For a normal plane, with point PP and NORMAL vector, and in-plane basis vectors PQ and PR, plane_normal_qr_to_xyz() converts QR to XYZ coordinates; plane_normal_xyz_to_qr() converts XYZ to QR coordinates. Maximum difference for 5 points was 0.000000 plane_normal_xyz_to_qr_test(): For a normal plane, with point PP and NORMAL vector, and in-plane basis vectors PQ and PR, plane_normal_xyz_to_qr() converts XYZ to QR coordinates. plane_normal_qr_to_xyz() converts QR to XYZ coordinates; Maximum difference for 5 points was 0.000000 plane_normal_tetrahedron_intersect_test(): plane_normal_tetrahedron_intersect() determines the intersection of a plane and tetrahedron. Plane normal vector number 1 0.000000 0.000000 1.000000 Point on plane: 0.000000 0.000000 0.000000 Number of intersection points = 3 1 0.000000 0.000000 0.000000 2 1.000000 0.000000 0.000000 3 0.000000 1.000000 0.000000 Point on plane: 0.000000 0.000000 0.200000 Number of intersection points = 3 1 0.000000 0.000000 0.200000 2 0.800000 0.000000 0.200000 3 0.000000 0.800000 0.200000 Point on plane: 0.000000 0.000000 0.400000 Number of intersection points = 3 1 0.000000 0.000000 0.400000 2 0.600000 0.000000 0.400000 3 0.000000 0.600000 0.400000 Point on plane: 0.000000 0.000000 0.600000 Number of intersection points = 3 1 0.000000 0.000000 0.600000 2 0.400000 0.000000 0.600000 3 0.000000 0.400000 0.600000 Point on plane: 0.000000 0.000000 0.800000 Number of intersection points = 3 1 0.000000 0.000000 0.800000 2 0.200000 0.000000 0.800000 3 0.000000 0.200000 0.800000 Point on plane: 0.000000 0.000000 1.000000 Number of intersection points = 1 1 0.000000 0.000000 1.000000 Point on plane: 0.000000 0.000000 1.200000 Number of intersection points = 0 Plane normal vector number 2 0.707107 0.707107 0.000000 Point on plane: 0.000000 0.000000 0.000000 Number of intersection points = 2 1 0.000000 0.000000 0.000000 2 0.000000 0.000000 1.000000 Point on plane: 0.141421 0.141421 0.000000 Number of intersection points = 4 1 0.282843 0.000000 0.000000 2 0.000000 0.282843 0.000000 3 0.000000 0.282843 0.717157 4 0.282843 0.000000 0.717157 Point on plane: 0.282843 0.282843 0.000000 Number of intersection points = 4 1 0.565685 0.000000 0.000000 2 0.000000 0.565685 0.000000 3 0.000000 0.565685 0.434315 4 0.565685 0.000000 0.434315 Point on plane: 0.424264 0.424264 0.000000 Number of intersection points = 4 1 0.848528 0.000000 0.000000 2 0.000000 0.848528 0.000000 3 0.000000 0.848528 0.151472 4 0.848528 0.000000 0.151472 Point on plane: 0.565685 0.565685 0.000000 Number of intersection points = 0 Point on plane: 0.707107 0.707107 0.000000 Number of intersection points = 0 Point on plane: 0.848528 0.848528 0.000000 Number of intersection points = 0 plane_normal_triangle_int_3d_test(): plane_normal_triangle_int_3d() finds the intersection points of a normal form plane and a triangle. The point PP: 1: 0 2: 0 3: 2 The normal vector N: 1: 1 2: -2 3: -3 Case 1 Triangle vertices: Row: 1 2 3 Col 1: 3 0 -7 2: 13 -4 -1 3: 5 1 -2 Number of intersection points is 0 Intersection points: (None) Case 2 Triangle vertices: Row: 1 2 3 Col 1: 3 0 -7 2: 13 -4 -1 3: 9 3 8 Number of intersection points is 2 Intersection points: Row: 1 2 3 Col 1: 7 2 3 2: 10.3333 0.666667 5 Case 3 Triangle vertices: Row: 1 2 3 Col 1: -6 0 0 2: 0 3 0 3: 0 0 2 Number of intersection points is 3 Intersection points: Row: 1 2 3 Col 1: -6 0 0 2: 0 3 0 3: 0 0 2 Case 4 Triangle vertices: Row: 1 2 3 Col 1: -4 1 0 2: 0 6 -2 3: 0 0 1 Number of intersection points is 2 Intersection points: Row: 1 2 3 Col 1: -4 1 0 2: 0 6 -2 plane_normal2exp_3d_test(): plane_normal2exp_3d() puts a plane defined by point, normal form into explicit form. The point PP: 1: -1 2: 0 3: -1 Normal vector: 1: -0.267261 2: -0.534523 3: -0.801784 P1, P2, P3: -1.000000 0.000000 -1.000000 -1.963624 0.148250 -0.777625 -1.000000 -0.832050 -0.445300 plane_normal2imp_3d_test(): plane_normal2imp_3d() puts a plane defined by point, normal form into implicit ABCD form. The point PP: 1: -1 2: 0 3: -1 Normal vector: 1: -0.267261 2: -0.534523 3: -0.801784 Output: (A,B,C,D)= -0.267261 -0.534523 -0.801784 -1.069045 The point PP: 1: -16 2: 2 3: 4 Normal vector: 1: -0.267261 2: -0.534523 3: -0.801784 Output: (A,B,C,D)= -0.267261 -0.534523 -0.801784 0.000001 points_centroid_2d_test(): points_centroid_2d() computes the centroid of a discrete set of points. The points: Row: 1 2 Col 1: 7 3 2: 4 7 3: 5 13 4: 2 7 5: 6 9 6: 12 8 7: 3 4 8: 6 6 9: 3 10 10: 8 7 11: 5 13 12: 10 6 The centroid is point #:5 points_colin_2d_test(): points_colin_2d() estimates the colinearity of three points. Points almost on a line: Expect COLIN to be close to 0 0.000000 0.000000 10.000000 10.000000 5.000000 4.990000 Colinearity index = 0.001299 Two points close, one far: Expect COLIN to be close to 0 0.000000 0.000000 0.000000 1.000000 100.000000 0.000000 Colinearity index = 0.025722 Points on an equilateral triangle: Expect COLIN to be close to 1 0.000000 0.000000 1.000000 0.000000 0.500000 0.866025 Colinearity index = 1.000000 polar_to_xy_test(): polar_to_xy() converts (R,Theta) to (X,Y); xy_to_polar() converts (X,Y) to (R,Theta). X Y ===> R T => X Y -0.502686 0.274290 0.572650 2.642096 -0.502686 0.274290 0.386657 0.521274 0.649022 0.932593 0.386657 0.521274 -0.477889 -0.609294 0.774349 -2.235911 -0.477889 -0.609294 0.680334 -0.574467 0.890430 -0.701228 0.680334 -0.574467 0.440823 0.195430 0.482201 0.417293 0.440823 0.195430 -0.699610 0.146010 0.714684 2.935844 -0.699610 0.146010 -0.196637 -0.321139 0.376558 -2.120218 -0.196637 -0.321139 0.098702 0.711792 0.718602 1.433008 0.098702 0.711792 -0.092501 -0.290769 0.305128 -1.878798 -0.092501 -0.290769 -0.171134 -0.356589 0.395528 -2.018250 -0.171134 -0.356589 polyhedron_area_3d_test(): polyhedron_area_3d() computes surface area for a polyhedron in 3D. Number of faces is 4 Order of each face: 1: 3 2: 3 3: 3 4: 3 Nodes per face: 1 3 2 1 2 1 2 4 3 1 4 3 4 2 3 4 Polyhedron nodes Row: 1 2 3 Col 1: 0 0 0 2: 1 0 0 3: 0 1 0 4: 0 0 1 Surface area = 2.366025 Exact area = 2.366025 polyhedron_centroid_3d_test(): polyhedron_centroid_3d() computes the centroid of a polyhedron in 3D. Number of faces is 4 Order of each face: 1: 3 2: 3 3: 3 4: 3 Nodes per face: 1 3 2 1 2 1 2 4 3 1 4 3 4 2 3 4 Polyhedron nodes: Row: 1 2 3 Col 1: 0 0 0 2: 1 0 0 3: 0 1 0 4: 0 0 1 Computed centroid: 1: 0.25 2: 0.25 3: 0.25 Exact centroid: 1: 0.25 2: 0.25 3: 0.25 polyhedron_contains_point_3d_test() polyhedron_contains_point_3d() determines if a point is inside a polyhedron. We test this routine by using a tetrahedron as the polyhedron. For this shape, an independent check can be made, using barycentric coordinates. We label these checks IN1 and IN2, and we expect them to agree. The vertices: Row: 1 2 3 Col 1: 0 0 0 2: 1 0 0 3: 0 1 0 4: 0 0 1 The face orders: 1: 3 2: 3 3: 3 4: 3 The nodes making each face: Row: 1 2 3 Col 1: 1 2 4 2: 1 3 2 3: 1 4 3 4: 2 3 4 X Y Z IN1 IN2 1 0.908034 0.949823 0.705127 0 0 2 0.092712 0.809127 0.270910 0 0 3 0.686818 0.913362 0.093724 0 0 4 0.296964 0.770117 0.518973 0 0 5 0.617104 0.119180 0.560546 0 0 6 0.956474 0.727426 0.923324 0 0 7 0.053315 0.725329 0.082218 1 1 8 0.723739 0.046013 0.585463 0 0 9 0.301187 0.414614 0.958604 0 0 10 0.198470 0.493991 0.089440 1 1 11 0.840810 0.644451 0.007577 0 0 12 0.958096 0.223987 0.229781 0 0 13 0.778080 0.992296 0.546847 0 0 14 0.102572 0.056159 0.226458 1 1 15 0.309543 0.812212 0.855900 0 0 16 0.144305 0.213037 0.026683 1 1 17 0.336916 0.676327 0.955312 0 0 18 0.050019 0.711659 0.231649 1 1 19 0.160009 0.743779 0.971007 0 0 20 0.370248 0.655211 0.681565 0 0 21 0.126673 0.967532 0.242464 0 0 22 0.532757 0.831442 0.682295 0 0 23 0.517143 0.409770 0.145103 0 0 24 0.245447 0.698868 0.418337 0 0 25 0.152318 0.813383 0.096070 0 0 26 0.873282 0.515467 0.163709 0 0 27 0.745842 0.430237 0.157694 0 0 28 0.085008 0.863948 0.777137 0 0 29 0.267016 0.284650 0.606987 0 0 30 0.047323 0.835552 0.968805 0 0 31 0.750099 0.924233 0.107002 0 0 32 0.909173 0.819581 0.643611 0 0 33 0.998836 0.214788 0.990736 0 0 34 0.022532 0.395219 0.563025 1 1 35 0.563885 0.469445 0.443562 0 0 36 0.201572 0.196177 0.852231 0 0 37 0.691139 0.378856 0.190250 0 0 38 0.255625 0.296934 0.895806 0 0 39 0.990960 0.083994 0.347041 0 0 40 0.088489 0.630638 0.251839 1 1 41 0.425897 0.509122 0.278465 0 0 42 0.538284 0.802519 0.122272 0 0 43 0.750470 0.479909 0.998873 0 0 44 0.467013 0.541109 0.088269 0 0 45 0.969897 0.622368 0.449769 0 0 46 0.910040 0.906431 0.126485 0 0 47 0.257116 0.603376 0.188140 0 0 48 0.265717 0.173815 0.508511 1 1 49 0.626585 0.414564 0.093889 0 0 50 0.349815 0.529131 0.992406 0 0 51 0.105609 0.630544 0.604035 0 0 52 0.774605 0.468811 0.146116 0 0 53 0.217221 0.871435 0.942321 0 0 54 0.107124 0.503180 0.304810 1 1 55 0.775986 0.727620 0.268043 0 0 56 0.768497 0.841389 0.402734 0 0 57 0.940376 0.015570 0.614082 0 0 58 0.158757 0.381189 0.424770 1 1 59 0.681174 0.386247 0.253976 0 0 60 0.768899 0.182140 0.998522 0 0 61 0.321244 0.120657 0.777145 0 0 62 0.962255 0.392393 0.675611 0 0 63 0.296859 0.229252 0.840676 0 0 64 0.389843 0.622379 0.815036 0 0 65 0.957021 0.495669 0.843765 0 0 66 0.544223 0.601901 0.443624 0 0 67 0.681931 0.672829 0.918900 0 0 68 0.613000 0.232763 0.143404 1 1 69 0.173156 0.752996 0.075456 0 0 70 0.073975 0.254969 0.154131 1 1 71 0.190445 0.647049 0.788235 0 0 72 0.008241 0.983649 0.007854 1 1 73 0.811520 0.108752 0.919952 0 0 74 0.029213 0.607310 0.721582 0 0 75 0.078076 0.724386 0.916474 0 0 76 0.697822 0.887139 0.602332 0 0 77 0.976875 0.808546 0.967741 0 0 78 0.440782 0.700025 0.609180 0 0 79 0.393230 0.132993 0.649266 0 0 80 0.557880 0.295924 0.049130 1 1 81 0.707802 0.126990 0.898756 0 0 82 0.055555 0.264020 0.077889 1 1 83 0.931760 0.007330 0.127142 0 0 84 0.999144 0.322914 0.021409 0 0 85 0.182991 0.224222 0.955768 0 0 86 0.131934 0.349740 0.920668 0 0 87 0.395699 0.877898 0.599994 0 0 88 0.523797 0.092441 0.956320 0 0 89 0.537690 0.811033 0.542094 0 0 90 0.699663 0.986274 0.090131 0 0 91 0.949381 0.048659 0.949645 0 0 92 0.193112 0.201633 0.338184 1 1 93 0.023182 0.364416 0.488462 1 1 94 0.176567 0.830928 0.024942 0 0 95 0.667334 0.727743 0.057534 0 0 96 0.607153 0.008835 0.651076 0 0 97 0.441432 0.610481 0.152960 0 0 98 0.145852 0.975867 0.729807 0 0 99 0.020607 0.322209 0.369825 1 1 100 0.203027 0.491666 0.150886 1 1 polyhedron_volume_3d_test(): polyhedron_volume_3d() computes the volume of a polyhedron in 3D. Number of faces is 4 Order of each face: 1: 3 2: 3 3: 3 4: 3 Nodes per face: 1 3 2 1 2 1 2 4 3 1 4 3 4 2 3 4 Polyhedron nodes Row: 1 2 3 Col 1: 0 0 0 2: 1 0 0 3: 0 1 0 4: 0 0 1 Volume ( computed ) = 0.166667 Volume ( exact ) = 0.166667 polyhedron_volume_3d_2_test(): polyhedron_volume_3d_2() computes the volume of a polyhedron in 3D. Number of faces is 4 Order of each face: 1: 3 2: 3 3: 3 4: 3 Nodes per face: 1 3 2 1 2 1 2 4 3 1 4 3 4 2 3 4 Polyhedron nodes Row: 1 2 3 Col 1: 0 0 0 2: 1 0 0 3: 0 1 0 4: 0 0 1 Volume ( computed ) = 0.166667 Volume ( exact ) = 0.166667 polyline_arclength_nd_test(): polyline_index_point_nd() finds a point on a polyline with given arclength. polyline_arclength_nd() computes the arclength of the polyline, and its nodes. The line we examine is defined by these points: P Arclength(X,Y) 0.000000 0.000000 0.000000 1.000000 1.000000 1.414214 2.000000 0.000000 2.828427 0.000000 0.000000 4.828427 We search for the point with coordinate 2.000000 The computed point: 1: 1.41421 2: 0.585786 polyline_points_nd_test(): polyline_points_nd() computes points on a polyline. The defining points: Row: 1 2 Col 1: 0 1 2: 0 0 3: 1 0 4: 1 2 The computed points: Row: 1 2 Col 1: 0 1 2: 0 0.666667 3: 0 0.333333 4: 0 0 5: 0.333333 0 6: 0.666667 0 7: 1 0 8: 1 0.333333 9: 1 0.666667 10: 1 1 11: 1 1.33333 12: 1 1.66667 13: 1 2 polyloop_arclength_nd_test(): polyloop_arclength_nd() computes the arclength of the nodes of a polyloop. P Arclength(P) 0.000000 0.000000 0.000000 1.000000 1.000000 1.414214 2.000000 0.000000 2.828427 0.000000 0.000000 4.828427 0.000000 0.000000 4.828427 polyloop_points_nd_test(): polyloop_points_nd() computes points on a polyloop. The defining points: Row: 1 2 Col 1: 0 2 2: 0 0 3: 1 0 4: 1 2 The computed points: Row: 1 2 Col 1: 0 2 2: 0 1.45455 3: 0 0.909091 4: 0 0.363636 5: 0.181818 0 6: 0.727273 0 7: 1 0.272727 8: 1 0.818182 9: 1 1.36364 10: 1 1.90909 11: 0.545455 2 12: 0 2 provec_test(): provec() projects a vector onto a subspace. Base vectors Row: 1 2 3 4 Col 1: 4 3 2 1 2: 1 2 3 4 Vector to be projected: 1: 1 2: 1 3: 1 4: 2 Projected vector in BASE coordinates: 1: 2.00832 2: 1.63299 Projected vector in original coordinates: 1: 0.8 2: 1.1 3: 1.4 4: 1.7 pyramid_volume_3d_test(): pyramid_volume_3d() returns the volume of a pyramid. Radius Height Volume 8.5999 5.7686 568.8447 6.3743 3.8222 207.0735 4.0837 5.1317 114.1080 1.5955 3.6530 12.3994 7.2035 2.3154 160.1948 pyramid01_volume_3d_test(): pyramid01_volume_3d() returns the volume of the unit pyramid. Volume = 1.33333 r8_haversine_test(): r8_haversine() computes the haversine of an angle. Degrees Radians Haversine 0.000000 0.000000 0.000000 30.000000 0.523599 0.066987 60.000000 1.047198 0.250000 90.000000 1.570796 0.500000 120.000000 2.094395 0.750000 150.000000 2.617994 0.933013 180.000000 3.141593 1.000000 210.000000 3.665191 0.933013 240.000000 4.188790 0.750000 270.000000 4.712389 0.500000 300.000000 5.235988 0.250000 330.000000 5.759587 0.066987 360.000000 6.283185 0.000000 r82vec_part_quick_a_test(): r82vec_part_quick_a() reorders an R82VEC as part of a quick sort. Before rearrangement: 1: 9.786 9.90193 2: 1.46376 4.21966 3: 6.91343 6.02278 4: 9.05658 1.64265 5: 3.45835 4.74934 6: 3.48738 5.77056 7: 5.6085 9.61406 8: 4.84255 4.74723 9: 5.58883 6.99392 10: 9.00073 2.82247 11: 7.02969 6.22674 12: 2.86727 9.08545 Rearranged array Left index = 11 Key index = 12 Right index = 13 Left half: 1: 1.46376 4.21966 2: 6.91343 6.02278 3: 9.05658 1.64265 4: 3.45835 4.74934 5: 3.48738 5.77056 6: 5.6085 9.61406 7: 4.84255 4.74723 8: 5.58883 6.99392 9: 9.00073 2.82247 10: 7.02969 6.22674 11: 2.86727 9.08545 Key: 1: 9.786 9.90193 Right half: r82vec_permute_test(): r82vec_permute() permutes an R82VEC. Original array XY[]: 1: 1 11 2: 2 22 3: 3 33 4: 4 44 5: 5 55 Permutation vector P[]: 1: 2 2: 4 3: 5 4: 1 5: 3 Permuted array X[P[]]: 1: 2 22 2: 4 44 3: 5 55 4: 1 11 5: 3 33 r82vec_print_test(): r82vec_print() prints an R82VEC. The R82VEC: 1: 5.69851 8.73021 2: 7.83499 -3.28164 3: 2.38203 -0.689392 4: -7.57318 8.72359 r82vec_sort_quick_a_test(): r82vec_sort_quick_a() sorts an R82VEC using quick sort. Before rearrangement: 1: 5.28669 9.12121 2: 2.38373 4.25414 3: 6.67783 3.90034 4: 9.72805 7.88909 5: 6.67783 6.1717 6: 0.814307 9.12121 7: 9.52334 1.87562 8: 2.34934 1.77794 9: 3.98759 4.25414 10: 6.01451 0.91545 11: 9.52334 1.87562 12: 9.72805 3.60724 Sorted array: 1: 0.814307 9.12121 2: 2.34934 1.77794 3: 2.38373 4.25414 4: 3.98759 4.25414 5: 5.28669 9.12121 6: 6.01451 0.91545 7: 6.67783 3.90034 8: 6.67783 6.1717 9: 9.52334 1.87562 10: 9.52334 1.87562 11: 9.72805 3.60724 12: 9.72805 7.88909 r82vec_sort_heap_index_a_test(): r82vec_sort_heap_index_a() index sorts an R82VEC using heapsort. Before rearrangement: 1: 9.77246 1.40846 2: 2.52859 1.29695 3: 4.75707 4.88473 4: 2.57313 5.75153 5: 4.75707 5.3806 6: 0.401738 1.40846 7: 1.38694 0.493241 8: 9.71044 6.62558 9: 1.51639 1.29695 10: 9.10227 9.19821 11: 1.38694 0.493241 12: 2.57313 9.41199 I Index A(Index) 1 6 4.017377e-01 1.408464e+00 2 11 1.386940e+00 4.932412e-01 3 7 1.386940e+00 4.932412e-01 4 9 1.516386e+00 1.296949e+00 5 2 2.528587e+00 1.296949e+00 6 4 2.573133e+00 5.751534e+00 7 12 2.573133e+00 9.411987e+00 8 3 4.757074e+00 4.884726e+00 9 5 4.757074e+00 5.380602e+00 10 10 9.102274e+00 9.198208e+00 11 8 9.710437e+00 6.625582e+00 12 1 9.772463e+00 1.408464e+00 After rearrangement by R82VEC_PERMUTE: 1: 0.401738 1.40846 2: 1.38694 0.493241 3: 1.38694 0.493241 4: 1.51639 1.29695 5: 2.52859 1.29695 6: 2.57313 5.75153 7: 2.57313 9.41199 8: 4.75707 4.88473 9: 4.75707 5.3806 10: 9.10227 9.19821 11: 9.71044 6.62558 12: 9.77246 1.40846 r8mat_inverse_3d_test(): r8mat_inverse_3d() inverts a 3 by 3 matrix. Matrix A to be inverted: Col: 1 2 3 Row 1 : 1 2 3 2 : 4 5 6 3 : 7 8 0 Inverse matrix B: Col: 1 2 3 Row 1 : -1.77778 0.888889 -0.111111 2 : 1.55556 -0.777778 0.222222 3 : -0.111111 0.222222 -0.111111 Product C = A * B: Col: 1 2 3 Row 1 : 1 -1.11022e-16 0 2 : 3.33067e-16 1 1.11022e-16 3 : 1.77636e-15 -8.88178e-16 1 r8vec_any_normal_test(): r8vec_any_normal() computes a vector V2 that is normal to a given vector V1. Test |V1| |V2| V1.V2 1 1.77482 1 0 2 1.72716 1 0 3 1.98481 1 0 4 1.94604 1 0 5 2.01561 1 0 r8vec_scalar_triple_product_test(): r8vec_scalar_triple_product() computes the scalar triple product of three R8VEC's. S = V1 dot ( V2 x V3 ). V1, V2 and V3: 1: -1 -2 0 2: 3 3 4 3: 3 1 0 Computed = -20, Exact = -20 r8vec3_print_test(): r8vec3_print() prints three R8VEC's. n, n^2, sqrt(n): 1: 1 1 1 2: 2 4 1.41421 3: 3 9 1.73205 4: 4 16 2 5: 5 25 2.23607 radec_distance_3d_test(): radec_distance_3d() computes the angular separation between two points on a sphere described in terms of right ascension and declination. RA1 DEC1 RA2 DEC2 Radians Degrees 0.000000 0.000000 6.000000 0.000000 1.570796 90.000000 0.000000 0.000000 0.000000 90.000000 1.570796 90.000000 0.000000 0.000000 3.000000 35.264390 0.955317 54.735610 0.000000 0.000000 -1.453427 -10.519735 0.420534 24.094843 0.000000 0.000000 -9.000000 -35.264390 2.186276 125.264390 6.000000 0.000000 0.000000 90.000000 1.570796 90.000000 6.000000 0.000000 3.000000 35.264390 0.955317 54.735610 6.000000 0.000000 -1.453427 -10.519735 1.944589 111.416714 6.000000 0.000000 -9.000000 -35.264390 2.186276 125.264390 0.000000 90.000000 3.000000 35.264390 0.955317 54.735610 0.000000 90.000000 -1.453427 -10.519735 1.754400 100.519735 0.000000 90.000000 -9.000000 -35.264390 2.186276 125.264390 3.000000 35.264390 -1.453427 -10.519735 1.358384 77.829677 3.000000 35.264390 -9.000000 -35.264390 3.141593 180.000000 -1.453427 -10.519735 -9.000000 -35.264390 1.783209 102.170323 radec_to_xyz_test(): radec_to_xyz() converts XYZ to RADEC coordinates. xyz_to_radec() converts RADEC to XYZ coordinates. P1 RA DEC P2 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 6.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 90.000000 0.000000 0.000000 1.000000 1.000000 1.000000 1.000000 3.000000 35.264390 0.577350 0.577350 0.577350 5.000000 -2.000000 -1.000000 -1.453427 -10.519735 0.912871 -0.365148 -0.182574 -2.000000 -2.000000 -2.000000 -9.000000 -35.264390 -0.577350 -0.577350 -0.577350 radians_to_degrees_test(): radians_to_degrees() converts an angle from radians to degrees; Degrees Radians Degrees -60.000000 -1.047198 -60.000000 -30.000000 -0.523599 -30.000000 0.000000 0.000000 0.000000 30.000000 0.523599 30.000000 60.000000 1.047198 60.000000 90.000000 1.570796 90.000000 120.000000 2.094395 120.000000 150.000000 2.617994 150.000000 180.000000 3.141593 180.000000 210.000000 3.665191 210.000000 240.000000 4.188790 240.000000 270.000000 4.712389 270.000000 300.000000 5.235988 300.000000 330.000000 5.759587 330.000000 360.000000 6.283185 360.000000 390.000000 6.806784 390.000000 420.000000 7.330383 420.000000 radians_to_dms_test(): radians_to_dms() converts an angle from radians to degrees/minutes/seconds; Radians DMS Radians -0.897598 -51 -25 -43 -0.897599 -0.448799 -25 -42 -51 -0.448797 0.000000 0 0 0 0.000000 0.448799 25 42 51 0.448797 0.897598 51 25 43 0.897599 1.346397 77 8 34 1.346395 1.795196 102 51 26 1.795197 2.243995 128 34 17 2.243994 2.692794 154 17 9 2.692796 3.141593 180 0 0 3.141593 3.590392 205 42 51 3.590390 4.039191 231 25 43 4.039191 4.487990 257 8 34 4.487988 4.936788 282 51 26 4.936790 5.385587 308 34 17 5.385587 5.834386 334 17 9 5.834388 6.283185 360 0 0 6.283185 6.731984 385 42 51 6.731982 rtp_to_xyz_test(): rtp_to_xyz() converts XYZ to (R,Theta,Phi) coordinates. xyz_to_rtp() converts (R,Theta,Phi) to XYZ coordinates. X1 Y1 Z1 R THETA PHI X2 Y2 Z2 -0.5311 -0.3352 1.6031 1.7218 -2.5787 0.3734 -0.5311 -0.3352 1.6031 -1.2812 1.7815 2.1255 3.0550 2.1943 0.8013 -1.2812 1.7815 2.1255 1.3662 -0.9417 2.9846 3.4149 -0.6035 0.5074 1.3662 -0.9417 2.9846 2.3596 2.0330 0.4879 3.1526 0.7112 1.4154 2.3596 2.0330 0.4879 0.6433 -0.8705 0.6140 1.2444 -0.9343 1.0548 0.6433 -0.8705 0.6140 segment_contains_point_1d_test(): segment_contains_point_1d() determines if a point lies within a line segment in 1D. P1 P T 2.000000 6.000000 3.000000 0.250000 10.000000 -10.000000 7.500000 0.125000 8.000000 10.000000 20.000000 6.000000 88.000000 88.000000 5.000000 -Inf segment_point_dist_test(): segment_point_dist() computes the distance between a line segment and point in 2D. TEST = 1 P1 = 0.225759 0.322639 P2 = 0.215900 0.478137 P = 0.498401 0.833516 DIST = 0.453983 TEST = 2 P1 = 0.346034 0.043692 P2 = 0.804295 0.680996 P = 0.823886 0.132544 DIST = 0.336094 TEST = 3 P1 = 0.055362 0.839518 P2 = 0.789196 0.989123 P = 0.028383 0.755971 DIST = 0.087796 segment_point_near_test(): segment_point_near() computes the nearest point from a line segment to a point. TEST = 1 P1 = 0.165010 0.306988 P2 = 0.363936 0.426262 P = 0.911934 0.763025 PN = 0.363936 0.426262 DIST = 0.643203 T = 1.000000 TEST = 2 P1 = 0.661571 0.845344 P2 = 0.062101 0.006700 P = 0.067299 0.079722 PN = 0.098405 0.057488 DIST = 0.038235 T = 0.939440 TEST = 3 P1 = 0.892788 0.299391 P2 = 0.116922 0.149209 P = 0.759699 0.407083 PN = 0.784599 0.278449 DIST = 0.131021 T = 0.139444 segment_point_dist_3d_test(): segment_point_dist_3d() computes the distance between a line segment and point in 3D. TEST = 1 P1 = 0.627789 0.076095 0.708175 P2 = 0.897093 0.253273 0.900364 P = 0.161242 0.898326 0.689731 DIST = 0.944531 TEST = 2 P1 = 0.968659 0.408226 0.923152 P2 = 0.327626 0.053934 0.633029 P = 0.196258 0.025951 0.580641 DIST = 0.144170 TEST = 3 P1 = 0.509934 0.636414 0.815610 P2 = 0.791716 0.417551 0.279136 P = 0.657654 0.522128 0.040861 DIST = 0.292718 segment_point_near_3d_test(): segment_point_near_3d() computes the nearest point from a line segment to a point in 3D. TEST = 1 P1 = 0.677241 0.272854 0.365029 P2 = 0.807321 0.950363 0.387503 P = 0.975756 0.099489 0.922638 PN = 0.677241 0.272854 0.365029 DIST = 0.655817 T = 0.000000 TEST = 2 P1 = 0.003784 0.818431 0.873722 P2 = 0.778633 0.905755 0.352489 P = 0.869232 0.611621 0.999552 PN = 0.520772 0.876695 0.525950 DIST = 0.644971 T = 0.667211 TEST = 3 P1 = 0.277499 0.294403 0.866888 P2 = 0.332022 0.209272 0.462375 P = 0.591313 0.010521 0.099790 PN = 0.332022 0.209272 0.462375 DIST = 0.488059 T = 1.000000 segments_curvature_2d_test(): segments_curvature_2d() computes the local curvature defined by the line segments [P1,P2] and [P2,P3]. Our three points are: P1 = (0,0) P2 = (1,0) P3 = (C,S) C = cosine ( theta), S = sine ( theta ). Test Theta Curvature 1 0.000000 2.000000 2 30.000000 1.931852 3 60.000000 1.732051 4 90.000000 1.414214 5 120.000000 1.000000 6 150.000000 0.517638 7 180.000000 0.000000 8 210.000000 0.517638 9 240.000000 1.000000 10 270.000000 1.414214 11 300.000000 1.732051 12 330.000000 1.931852 13 360.000000 2.000000 segments_dist_2d_test(): segments_dist_2d() computes the distance between line segments in 2D. Same slope, different intercepts. P1 = 2.000000 3.000000 P2 = 8.000000 6.000000 Q1 = 8.000000 3.000000 Q2 = 14.000000 6.000000 Distance([P1,P2],[Q1,Q2]) = 2.683282 Same slope, same intercepts, overlapping. Distance should be 0. P1 = 2.000000 3.000000 P2 = 8.000000 6.000000 Q1 = 4.000000 4.000000 Q2 = 14.000000 9.000000 Distance([P1,P2],[Q1,Q2]) = 0.000000 Same slope, same intercepts, disjoint. Distance should be sqrt(45)=6.7082038 P1 = 2.000000 3.000000 P2 = 8.000000 6.000000 Q1 = 14.000000 9.000000 Q2 = 16.000000 10.000000 Distance([P1,P2],[Q1,Q2]) = 6.708204 Different slopes, intersecting. Distance should be 0. P1 = 2.000000 3.000000 P2 = 8.000000 6.000000 Q1 = 0.000000 8.000000 Q2 = 5.000000 3.000000 Distance([P1,P2],[Q1,Q2]) = 0.000000 Different slopes, not intersecting. P1 = 2.000000 3.000000 P2 = 8.000000 6.000000 Q1 = 7.000000 3.000000 Q2 = 9.000000 -1.000000 Distance([P1,P2],[Q1,Q2]) = 2.236068 Simple problem. Distance should be 0 P1 = 57.000000 53.000000 P2 = 58.000000 53.000000 Q1 = 65.000000 45.000000 Q2 = 57.000000 53.000000 Distance([P1,P2],[Q1,Q2]) = 0.000000 Same data, translated by 50. Distance should be 0 P1 = 7.000000 3.000000 P2 = 8.000000 3.000000 Q1 = 15.000000 -5.000000 Q2 = 7.000000 3.000000 Distance([P1,P2],[Q1,Q2]) = 0.000000 Diagonal and horizontal. Distance should be sqrt(2500/2)=35.355339 P1 = 0.000000 0.000000 P2 = 100.000000 100.000000 Q1 = 50.000000 0.000000 Q2 = 60.000000 0.000000 Distance([P1,P2],[Q1,Q2]) = 35.355339 Same data, except first segment extended. Distance should be sqrt(2500/2)=35.355339 P1 = -10.000000 -10.000000 P2 = 100.000000 100.000000 Q1 = 50.000000 0.000000 Q2 = 60.000000 0.000000 Distance([P1,P2],[Q1,Q2]) = 35.355339 segments_dist_3d_test(): segments_dist_3d() computes the distance between line segments in 3D. Case Computed True 1 5.000000 5.0 1 0.000000 0.0 3 3.000000 3.0 4 0.000000 0.0 5 1.000000 1.0 6 3.000000 3.0 7 1.000000 1.0 8 10.000000 10.0 9 4.000000 4.0 segments_int_1d_test() segments_int_1d() determines the intersection [R1,R2] of line segments [P1,P2] and [Q1,Q2] in 1D. DIST is negative for overlap, 0 for point intersection, positive if there is no overlap. Test P1 P2 Q1 Q2 R1 R2 DIST 1 -1.000000 1.000000 -1.000000 1.000000 -1.000000 1.000000 -2.000000 2 -1.000000 1.000000 3.000000 2.000000 2.000000 1.000000 1.000000 3 -1.000000 1.000000 1.000000 2.000000 1.000000 1.000000 0.000000 4 -1.000000 1.000000 0.500000 -3.000000 -1.000000 0.500000 -1.500000 5 -1.000000 1.000000 0.250000 0.500000 0.250000 0.500000 -0.250000 6 -1.000000 1.000000 0.500000 0.500000 0.500000 0.500000 0.000000 7 -1.000000 1.000000 2.000000 2.000000 2.000000 1.000000 1.000000 segments_int_2d_test(): segments_int_2d() searches for an intersection of two line segments in 2D. All tests use the same line segment 1: P1 = -1.000000 3.000000 P2 = 1.000000 1.000000 Q1 = -1.000000 1.000000 Q2 = 1.000000 -1.000000 The line segments do not intersect. Q1 = 3.000000 -1.000000 Q2 = 2.000000 0.000000 The line segments do not intersect. Q1 = 0.000000 0.000000 Q2 = 0.000000 9.000000 The line segments do not intersect. Q1 = 1.000000 2.000000 Q2 = 3.000000 2.000000 The line segments do not intersect. shape_point_dist_2d_test(): shape_point_dist_2d() computes the distance from a general shape to a point; Number of sides: 4 Center of square: 1: 3 2: 0 Square vertex #1 1: 5 2: 0 I X Y DIST 1 3.000000 0.000000 1.414214 2 5.000000 0.000000 0.000000 3 4.000000 0.000000 0.707107 4 10.000000 0.000000 5.000000 5 8.000000 5.000000 5.830952 6 6.000000 6.000000 6.082763 7 1.000000 2.000000 2.000000 8 2.500000 -0.500000 1.414214 9 4.000000 -1.000000 1.414214 shape_point_near_2d_test(): shape_point_near_2d() computes the nearest point on a shape to a given point; Number of sides: 6 Hexagon center: 1: 3 2: 0 Hexagon vertex #1: 5.000000 0.000000 I X Y PN Dist 1 3.000000 0.000000 3.000000 0.000000 1.732051 2 5.000000 0.000000 5.000000 0.000000 0.000000 3 4.000000 0.000000 4.750000 0.433013 0.866025 4 10.000000 0.000000 5.000000 0.000000 5.000000 5 4.000000 1.732051 5.000000 -0.000000 2.000000 6 5.000000 3.464102 5.000000 -0.000000 3.464102 7 3.000000 1.732051 3.000000 -1.732051 3.464102 8 3.000000 0.866025 3.000000 -1.732051 2.598076 shape_ray_int_2d_test(): shape_ray_int_2d() computes the intersection of a shape and a ray whose origin is within the shape. Number of sides: 6 Hexagon center: 1: 3 2: 0 Hexagon vertex #1: 5.000000 0.000000 I XA YA XB YB XI YI 1 3.000000 0.000000 4.000000 0.000000 5.000000 0.000000 2 3.000000 0.000000 3.000000 1.000000 3.000000 3.464102 3 3.000000 -1.000000 3.000000 1.000000 3.000000 3.464102 4 3.000000 -1.000000 7.000000 5.000000 4.821367 1.732051 simplex_lattice_layer_point_next_test(): simplex_lattice_layer_point_next() returns the next point in an N-dimensional simplex lattice layer defined by: C(N+1) - 1 <= X(1)/C(1) + X(2)/C(2) + ... + X(N)/C(N) <= C(N+1). N = 1 C = 2 Layer 0 1 0 No more. Layer 1 1 1 2 2 No more. Layer 2 1 3 2 4 No more. N = 2 C = 2 3 Layer 0 1 0 0 No more. Layer 1 1 1 0 2 2 0 3 0 1 4 1 1 5 0 2 6 0 3 No more. Layer 2 1 3 0 2 4 0 3 2 1 4 3 1 5 1 2 6 2 2 7 1 3 8 2 3 9 0 4 10 1 4 11 0 5 12 0 6 No more. N = 3 C = 2 3 4 Layer 0 1 0 0 0 No more. Layer 1 1 1 0 0 2 2 0 0 3 0 1 0 4 1 1 0 5 0 2 0 6 0 3 0 7 0 0 1 8 1 0 1 9 0 1 1 10 0 2 1 11 0 0 2 12 1 0 2 13 0 1 2 14 0 0 3 15 0 0 4 No more. Layer 2 1 3 0 0 2 4 0 0 3 2 1 0 4 3 1 0 5 1 2 0 6 2 2 0 7 1 3 0 8 2 3 0 9 0 4 0 10 1 4 0 11 0 5 0 12 0 6 0 13 2 0 1 14 3 0 1 15 1 1 1 16 2 1 1 17 1 2 1 18 2 2 1 19 0 3 1 20 1 3 1 21 0 4 1 22 0 5 1 23 2 0 2 24 3 0 2 25 1 1 2 26 2 1 2 27 0 2 2 28 1 2 2 29 0 3 2 30 1 3 2 31 0 4 2 32 1 0 3 33 2 0 3 34 0 1 3 35 1 1 3 36 0 2 3 37 1 2 3 38 0 3 3 39 1 0 4 40 2 0 4 41 0 1 4 42 1 1 4 43 0 2 4 44 0 3 4 45 0 0 5 46 1 0 5 47 0 1 5 48 0 2 5 49 0 0 6 50 1 0 6 51 0 1 6 52 0 0 7 53 0 0 8 No more. N = 4 C = 2 3 4 5 Layer 0 1 0 0 0 0 No more. Layer 1 1 1 0 0 0 2 2 0 0 0 3 0 1 0 0 4 1 1 0 0 5 0 2 0 0 6 0 3 0 0 7 0 0 1 0 8 1 0 1 0 9 0 1 1 0 10 0 2 1 0 11 0 0 2 0 12 1 0 2 0 13 0 1 2 0 14 0 0 3 0 15 0 0 4 0 16 0 0 0 1 17 1 0 0 1 18 0 1 0 1 19 0 2 0 1 20 0 0 1 1 21 1 0 1 1 22 0 1 1 1 23 0 0 2 1 24 0 0 3 1 25 0 0 0 2 26 1 0 0 2 27 0 1 0 2 28 0 0 1 2 29 0 1 1 2 30 0 0 2 2 31 0 0 0 3 32 0 1 0 3 33 0 0 1 3 34 0 0 0 4 35 0 0 0 5 No more. Layer 2 1 3 0 0 0 2 4 0 0 0 3 2 1 0 0 4 3 1 0 0 5 1 2 0 0 6 2 2 0 0 7 1 3 0 0 8 2 3 0 0 9 0 4 0 0 10 1 4 0 0 11 0 5 0 0 12 0 6 0 0 13 2 0 1 0 14 3 0 1 0 15 1 1 1 0 16 2 1 1 0 17 1 2 1 0 18 2 2 1 0 19 0 3 1 0 20 1 3 1 0 21 0 4 1 0 22 0 5 1 0 23 2 0 2 0 24 3 0 2 0 25 1 1 2 0 26 2 1 2 0 27 0 2 2 0 28 1 2 2 0 29 0 3 2 0 30 1 3 2 0 31 0 4 2 0 32 1 0 3 0 33 2 0 3 0 34 0 1 3 0 35 1 1 3 0 36 0 2 3 0 37 1 2 3 0 38 0 3 3 0 39 1 0 4 0 40 2 0 4 0 41 0 1 4 0 42 1 1 4 0 43 0 2 4 0 44 0 3 4 0 45 0 0 5 0 46 1 0 5 0 47 0 1 5 0 48 0 2 5 0 49 0 0 6 0 50 1 0 6 0 51 0 1 6 0 52 0 0 7 0 53 0 0 8 0 54 2 0 0 1 55 3 0 0 1 56 1 1 0 1 57 2 1 0 1 58 1 2 0 1 59 2 2 0 1 60 0 3 0 1 61 1 3 0 1 62 0 4 0 1 63 0 5 0 1 64 2 0 1 1 65 3 0 1 1 66 1 1 1 1 67 2 1 1 1 68 0 2 1 1 69 1 2 1 1 70 0 3 1 1 71 1 3 1 1 72 0 4 1 1 73 1 0 2 1 74 2 0 2 1 75 0 1 2 1 76 1 1 2 1 77 0 2 2 1 78 1 2 2 1 79 0 3 2 1 80 1 0 3 1 81 2 0 3 1 82 0 1 3 1 83 1 1 3 1 84 0 2 3 1 85 0 3 3 1 86 0 0 4 1 87 1 0 4 1 88 0 1 4 1 89 0 2 4 1 90 0 0 5 1 91 1 0 5 1 92 0 1 5 1 93 0 0 6 1 94 0 0 7 1 95 2 0 0 2 96 3 0 0 2 97 1 1 0 2 98 2 1 0 2 99 0 2 0 2 100 1 2 0 2 101 0 3 0 2 102 1 3 0 2 103 0 4 0 2 104 1 0 1 2 105 2 0 1 2 106 1 1 1 2 107 2 1 1 2 108 0 2 1 2 109 1 2 1 2 110 0 3 1 2 111 0 4 1 2 112 1 0 2 2 113 2 0 2 2 114 0 1 2 2 115 1 1 2 2 116 0 2 2 2 117 0 3 2 2 118 0 0 3 2 119 1 0 3 2 120 0 1 3 2 121 1 1 3 2 122 0 2 3 2 123 0 0 4 2 124 1 0 4 2 125 0 1 4 2 126 0 0 5 2 127 0 1 5 2 128 0 0 6 2 129 1 0 0 3 130 2 0 0 3 131 1 1 0 3 132 2 1 0 3 133 0 2 0 3 134 1 2 0 3 135 0 3 0 3 136 0 4 0 3 137 1 0 1 3 138 2 0 1 3 139 0 1 1 3 140 1 1 1 3 141 0 2 1 3 142 0 3 1 3 143 0 0 2 3 144 1 0 2 3 145 0 1 2 3 146 1 1 2 3 147 0 2 2 3 148 0 0 3 3 149 1 0 3 3 150 0 1 3 3 151 0 0 4 3 152 0 1 4 3 153 0 0 5 3 154 1 0 0 4 155 2 0 0 4 156 0 1 0 4 157 1 1 0 4 158 0 2 0 4 159 1 2 0 4 160 0 3 0 4 161 0 0 1 4 162 1 0 1 4 163 0 1 1 4 164 1 1 1 4 165 0 2 1 4 166 0 0 2 4 167 1 0 2 4 168 0 1 2 4 169 0 2 2 4 170 0 0 3 4 171 0 1 3 4 172 0 0 4 4 173 1 0 0 5 174 2 0 0 5 175 0 1 0 5 176 1 1 0 5 177 0 2 0 5 178 0 3 0 5 179 0 0 1 5 180 1 0 1 5 181 0 1 1 5 182 0 2 1 5 183 0 0 2 5 184 1 0 2 5 185 0 1 2 5 186 0 0 3 5 187 0 0 4 5 188 0 0 0 6 189 1 0 0 6 190 0 1 0 6 191 0 2 0 6 192 0 0 1 6 193 1 0 1 6 194 0 1 1 6 195 0 0 2 6 196 0 0 3 6 197 0 0 0 7 198 1 0 0 7 199 0 1 0 7 200 0 0 1 7 201 0 1 1 7 202 0 0 2 7 203 0 0 0 8 204 0 1 0 8 205 0 0 1 8 206 0 0 0 9 207 0 0 0 10 No more. simplex_lattice_point_next_test(): simplex_lattice_point_next() returns the next lattice point in an N-dimensional simplex defined by: 0 <= X(1)/C(1) + X(2)/C(2) + ... + X(N)/C(N) <= C(N+1). N = 1 C = 2 1 1 0 2 1 3 2 No more. N = 2 C = 3 2 1 1 0 0 2 1 0 3 2 0 4 3 0 5 0 1 6 1 1 7 0 2 No more. N = 3 C = 4 3 2 1 1 0 0 0 2 1 0 0 3 2 0 0 4 0 1 0 5 1 1 0 No more. N = 4 C = 5 4 3 2 1 1 0 0 0 0 2 1 0 0 0 3 2 0 0 0 4 3 0 0 0 5 0 1 0 0 6 1 1 0 0 7 0 2 0 0 8 0 0 1 0 9 1 0 1 0 No more. simplex_volume_nd_test(): simplex_volume_nd() computes the volume of an ND simplex. Simplex vertices: Row: 1 2 3 Col 1: 0 0.942809 -0.333333 2: -0.816496 -0.816496 -0.333333 3: 0.816496 -0.816496 -0.333333 4: 0 0 1 Volume computed by tetrahedron_volume_3d(): 0.638429 Volume computed by SIMPLEX_VOLUME_ND: 0.638429 simplex01_volume_nd_test(): simplex01_volume_nd() gets volume of the unit M-dimensional simplex. M Volume 1 1.00000000 2 0.50000000 3 0.16666667 4 0.04166667 5 0.00833333 6 0.00138889 7 0.00019841 8 0.00002480 9 0.00000276 10 0.00000028 soccer_shape_test For the truncated icosahedron, or soccer ball, soccer_size() returns dimension information; soccer_shape() returns face and order information. We will use this information to compute the areas and centers of each face. Number of points = 60 Number of edges = 90 Number of faces = 32 Maximum face order = 6 Face Order Area 1 6 0.441056 2 6 0.441056 3 5 0.292073 4 6 0.441057 5 5 0.292073 6 6 0.441056 7 5 0.292073 8 6 0.441056 9 6 0.441056 10 6 0.441056 11 5 0.292073 12 6 0.441056 13 5 0.292072 14 6 0.441056 15 5 0.292073 16 6 0.441056 17 6 0.441056 18 6 0.441056 19 5 0.292072 20 6 0.441056 21 5 0.292073 22 5 0.292073 23 6 0.441056 24 6 0.441056 25 6 0.441056 26 5 0.292073 27 6 0.441056 28 5 0.292073 29 6 0.441057 30 6 0.441056 31 5 0.292073 32 6 0.441056 Face Center 1 0.176084 0.333333 0.854729 2 -0.374587 -0.042441 0.854729 3 0.185551 -0.271913 0.900685 4 0.681916 -0.042441 0.637077 5 -0.371103 0.543825 0.697234 6 -0.209088 -0.650456 0.637077 7 0.616466 0.543825 0.493784 8 0.443866 -0.650456 0.502561 9 -0.804597 0.222222 0.419426 10 0.086406 0.830237 0.419426 11 -0.731143 -0.375774 0.493784 12 0.904859 0.222222 0.067258 13 0.866776 -0.375774 0.164595 14 -0.519688 0.761567 0.150394 15 0.033908 -0.944118 0.164595 16 -0.536815 -0.761567 0.067258 17 0.536815 0.761567 -0.067258 18 0.519688 -0.761567 -0.150394 19 -0.866776 0.375774 -0.164595 20 -0.904859 -0.222222 -0.067258 21 -0.033908 0.944118 -0.164595 22 0.731143 0.375774 -0.493784 23 0.804597 -0.222222 -0.419426 24 -0.443867 0.650456 -0.502561 25 -0.086406 -0.830237 -0.419426 26 -0.616466 -0.543825 -0.493784 27 0.209088 0.650456 -0.637077 28 0.371103 -0.543825 -0.697234 29 -0.681916 0.042441 -0.637077 30 0.374587 0.042441 -0.854729 31 -0.185551 0.271913 -0.900685 32 -0.176084 -0.333333 -0.854729 sort_heap_external_test(): sort_heap_external() sorts objects externally. Unsorted array: 1: 15 2: 2 3: 7 4: 6 5: 19 6: 15 7: 3 8: 6 9: 5 10: 7 11: 8 12: 17 13: 3 14: 3 15: 5 16: 1 17: 12 18: 17 19: 7 20: 1 Sorted array: 1: 1 2: 1 3: 2 4: 3 5: 3 6: 3 7: 5 8: 5 9: 6 10: 6 11: 7 12: 7 13: 7 14: 8 15: 12 16: 15 17: 15 18: 17 19: 17 20: 19 sphere_cap_area_3d_test(): sphere_cap_area_3d() computes the volume of a 3D spherical cap, defined by a plane that cuts the sphere to a thickness of H units. sphere_cap_area_nd() computes the volume of an ND spherical cap, defined by a plane that cuts the sphere to a thickness of H units. R H Cap Cap area_3d area_nd 1.000000 0.000000 0.000000 0.000000 1.000000 0.166667 1.047198 1.047198 1.000000 0.333333 2.094395 2.094395 1.000000 0.500000 3.141593 3.141593 1.000000 0.666667 4.188790 4.188790 1.000000 0.833333 5.235988 5.235988 1.000000 1.000000 6.283185 6.283185 1.000000 1.166667 7.330383 7.330383 1.000000 1.333333 8.377580 8.377580 1.000000 1.500000 9.424778 9.424778 1.000000 1.666667 10.471976 10.471976 1.000000 1.833333 11.519173 11.519173 1.000000 2.000000 12.566371 12.566371 sphere_cap_volume_3d_test(): sphere_cap_volume_3d() computes the volume of a spherical cap, defined by a plane that cuts the sphere to a thickness of H units. sphere_cap_volume_nd() does the same operation, but in N dimensions. Using a radius R = 1.000000 H Cap Cap volume_3d volume_nd 0.000000 0.000000 0.000000 0.166667 0.082418 0.082418 0.333333 0.310281 0.310281 0.500000 0.654498 0.654498 0.666667 1.085983 1.085983 0.833333 1.575644 1.575644 1.000000 2.094395 2.094395 1.166667 2.613146 2.613146 1.333333 3.102808 3.102808 1.500000 3.534292 3.534292 1.666667 3.878509 3.878509 1.833333 4.106372 4.106372 2.000000 4.188790 4.188790 sphere_dia2imp_3d_test(): sphere_dia2imp_3d() converts a sphere from diameter to implicit form. Point P1: 1: -1 2: -1 3: 4 Point P2: 1: 5 2: 7 3: 4 Radius: 5.000000 The center: 1: 2 2: 3 sphere_distance_test(): sphere_distance1() measures the distance between two points on a sphere. sphere_distance2() measures the distance between two points on a sphere. sphere_distance3() measures the distance between two points on a sphere. All tests uses RADIUS = 3957.000000 which is the radius of the earth in miles. Distance from Atlanta, Georgia to North Pole is 3923.91118352 3923.91118352 3923.91118352 to South Pole is 8507.37094673 8507.37094673 8507.37094673 to Timbuktu is 4995.76351265 4995.76351265 4995.76351265 to San Antonio, Texas is 974.43026414 974.43026414 974.43026414 to Savannah, Georgia is 114.22379279 114.22379279 114.22379279 Distance from North Pole to South Pole is 12431.28213025 12431.28213025 12431.28213025 to Timbuktu is 5054.23702166 5054.23702166 5054.23702166 to San Antonio, Texas is 4184.04727254 4184.04727254 4184.04727254 to Savannah, Georgia is 3999.88012987 3999.88012987 3999.88012987 Distance from South Pole to Timbuktu is 7377.04510859 7377.04510859 7377.04510859 to San Antonio, Texas is 8247.23485771 8247.23485771 8247.23485771 to Savannah, Georgia is 8431.40200038 8431.40200038 8431.40200038 Distance from Timbuktu to San Antonio, Texas is 5969.44112133 5969.44112133 5969.44112133 to Savannah, Georgia is 4922.93556095 4922.93556095 4922.93556095 Distance from San Antonio, Texas to Savannah, Georgia is 1047.81549868 1047.81549868 1047.81549868 sphere_exp_contains_point_3d_test sphere_exp_contains_point_3d() determines if a point is within an explicit sphere; Inside, P 1 1.000000 2.000000 3.000000 0 7.000000 2.000000 3.000000 1 1.000000 5.000000 3.000000 1 2.500000 3.500000 4.500000 sphere_exp_point_near_3d_test(): sphere_exp_point_near_3d() finds the nearest point on an explicit sphere; Sphere radius 3.000000 Sphere center: 1: 1 2: 2 3: 3 P, PN 1.000000 2.000000 3.000000 2.471587 2.000000 1.528413 7.000000 2.000000 3.000000 3.090576 3.646817 4.203059 1.000000 5.000000 3.000000 3.000984 3.242730 3.484476 2.500000 3.500000 4.500000 3.402403 3.549233 3.696064 sphere_exp2imp_3d_test(): sphere_exp2imp_3d: explicit sphere => implicit form; sphere_imp2exp_3d: implicit sphere => explicit form. Initial form of explicit sphere: 4.000000 2.000000 3.000000 1.000000 5.000000 3.000000 1.000000 2.000000 6.000000 -2.000000 2.000000 3.000000 Computed form of implicit sphere: Imputed radius = 3.000000 Imputed center 1: 1 2: 2 3: 3 Computed form of explicit sphere: 1.000000 2.000000 6.000000 3.598076 2.000000 1.500000 -0.299038 4.250000 1.500000 -0.299038 -0.250000 1.500000 sphere_exp2imp_nd_test(): sphere_exp2imp_nd(): explicit sphere => implicit form; Initial form of explicit sphere: Row: 1 2 3 Col 1: 4 2 3 2: 1 5 3 3: 1 2 6 4: -2 2 3 Computed form of implicit sphere: Imputed radius = 3.000000 True radius = 3.000000 Imputed center 1: 1 2: 2 3: 3 True center 1: 1 2: 2 3: 3 sphere_imp_area_nd_test sphere_imp_area_nd() computes the area of an implicit sphere in N dimensions; We use a radius of R = 1.000000 DIM_NUM Area 2 6.283185 3 12.566371 4 19.739209 5 26.318945 6 31.006277 7 33.073362 8 32.469697 9 29.686580 10 25.501640 sphere_imp_contains_point_3d_test() sphere_imp_contains_point_3d() determines if a point is within an implicit sphere; Inside, P 1 1.000000 2.000000 3.000000 0 7.000000 2.000000 3.000000 1 1.000000 5.000000 3.000000 1 2.500000 3.500000 4.500000 sphere_imp_gridfaces_3d_test(): sphere_imp_gridfaces_3d() computes gridfaces on a sphere in 3D. Number of intermediate latitudes is 3 Number of longitudes is 4 The number of triangles is 32 Triangle vertices: Row: 1 2 3 Col 1: 2 3 1 2: 3 4 1 3: 4 5 1 4: 5 2 1 5: 6 7 2 6: 3 2 7 7: 7 8 3 8: 4 3 8 9: 8 9 4 10: 5 4 9 11: 9 6 5 12: 2 5 6 13: 10 11 6 14: 7 6 11 15: 11 12 7 16: 8 7 12 17: 12 13 8 18: 9 8 13 19: 13 10 9 20: 6 9 10 21: 14 15 10 22: 11 10 15 23: 15 16 11 24: 12 11 16 25: 16 17 12 26: 13 12 17 27: 17 14 13 28: 10 13 14 29: 15 14 18 30: 16 15 18 31: 17 16 18 32: 14 17 18 sphere_imp_point_near_3d_test() sphere_imp_point_near_3d() finds the nearest point on an implicit sphere; Sphere radius 3.000000 Sphere center: 1: 1 2: 2 3: 3 P, PN 1.000000 2.000000 3.000000 2.732051 3.732051 4.732051 7.000000 2.000000 3.000000 4.000000 2.000000 3.000000 1.000000 5.000000 3.000000 1.000000 5.000000 3.000000 2.500000 3.500000 4.500000 2.732051 3.732051 4.732051 sphere_imp_point_project_3d_test(): sphere_imp_point_project_3d() projects a 3D point onto a sphere. P1 projection P2 2.000000 0.000000 0.000000 2.000000 2.000000 0.000000 0.000000 4.000000 0.000000 0.000000 4.000000 0.000000 2.000000 4.000000 10.000000 2.000000 4.000000 2.000000 3.000000 5.000000 0.000000 3.414214 5.414214 0.000000 sphere_imp_volume_nd_test(): sphere_imp_volume_nd() computes the volume of an implicit sphere in N dimensions; We use a radius of R = 1.000000 DIM_NUM Area Volume 2 3.141593 3 4.188790 4 4.934802 5 5.263789 6 5.167713 7 4.724766 8 4.058712 9 3.298509 10 2.550164 sphere_imp2exp_3d_test(): sphere_imp2exp_3d(): implicit sphere => explicit form. sphere_exp2imp_3d(): explicit sphere => implicit form; Initial form of explicit sphere: 4.000000 2.000000 3.000000 1.000000 5.000000 3.000000 1.000000 2.000000 6.000000 -2.000000 2.000000 3.000000 Computed form of implicit sphere: Imputed radius = 3.000000 Imputed center 1: 1 2: 2 3: 3 Computed form of explicit sphere: 1.000000 2.000000 6.000000 3.598076 2.000000 1.500000 -0.299038 4.250000 1.500000 -0.299038 -0.250000 1.500000 sphere_triangle_sides_to_angles_test(): sphere_triangle_sides_to_angles() takes the sides of a spherical triangle and determines the angles. A = 2.058867 (radians) A = 117.964369 (degrees) Correct = 117.966667 (radians) B = 1.627136 (radians) B = 93.228029 (degrees) Correct = 93.230000 (radians) C = 1.227740 (radians) C = 70.344308 (degrees) Correct = 70.343333 (radians) sphere01_area_nd_test(): sphere01_area_nd() evaluates the area of the unit sphere in N dimensions. DIM_NUM Exact Computed Area Area 1 2.000000 2.000000 2 6.283185 6.283185 3 12.566371 12.566371 4 19.739209 19.739209 5 26.318945 26.318945 6 31.006277 31.006277 7 33.073362 33.073362 8 32.469697 32.469697 9 29.686580 29.686580 10 25.501640 25.501640 11 20.725143 20.725143 12 16.023153 16.023153 13 11.838174 11.838174 14 8.389703 8.389703 15 5.721649 5.721649 16 3.765290 3.765290 17 2.396679 2.396679 18 1.478626 1.478626 19 0.885810 0.885810 20 0.516138 0.516138 sphere01_sample_2d_test sphere01_sample_2d() samples the unit sphere in 2D. A few sample values: 0.926537 0.376205 -0.849751 0.527184 0.916090 -0.400973 0.975246 0.221121 0.182906 -0.983130 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N_SAMPLE increases. Average: -0.007349 -0.009283 Now choose a random direction, sample the same number of points, and compute the dot product with the direction. Take the absolute value of each dot product and sum and average. We expect a value near 2 / PI = 0.6366... V: -0.910638 0.413205 Average |(XdotV)| 0.633817 V: 0.754584 0.656203 Average |(XdotV)| 0.637237 V: -0.189749 -0.981833 Average |(XdotV)| 0.621696 V: 0.432475 0.901646 Average |(XdotV)| 0.639812 V: 0.627330 -0.778754 Average |(XdotV)| 0.624498 sphere01_sample_3d_test(): sphere01_sample_3d() samples the unit sphere in 3D; A few sample values: 0.908567 0.118476 -0.400586 0.917551 -0.141867 0.371448 -0.615266 0.614441 -0.493873 -0.645523 0.562880 0.516204 0.241007 -0.929754 -0.278340 Now average the points, which should get a value close to zero, and closer as N_SAMPLE increases. Average: 0.038249 -0.020312 -0.028417 Now choose a random direction, sample the same number of points, and compute the dot product with the direction. Take the absolute value of each dot product and sum and average. V: -0.274608 -0.916025 0.292385 Average |(XdotV)| 0.484942 V: -0.604006 -0.402399 0.687934 Average |(XdotV)| 0.498249 V: 0.465436 -0.156948 0.871055 Average |(XdotV)| 0.511607 V: -0.876928 -0.113734 0.466972 Average |(XdotV)| 0.494055 V: -0.469556 0.867229 -0.165621 Average |(XdotV)| 0.498355 sphere01_sample_3d_2_test() sphere01_sample_3d_2() samples the 3D unit sphere; A few sample values: 0.199858 -0.880880 -0.429077 -0.045883 0.100341 0.993895 -0.220217 -0.164363 0.961504 -0.417344 -0.867092 0.271983 0.891038 0.013159 0.453738 Now average the points, which should get a value close to zero, and closer as N_SAMPLE increases. Average: 0.008599 -0.012404 0.046563 Now choose a random direction, sample the same number of points, and compute the dot product with the direction. Take the absolute value of each dot product and sum and average. V: -0.115488 0.868599 0.481870 Average |(XdotV)| 0.493209 V: 0.688432 -0.351557 -0.634404 Average |(XdotV)| 0.521146 V: -0.581459 -0.033895 0.812869 Average |(XdotV)| 0.588747 V: 0.082584 0.170680 -0.981860 Average |(XdotV)| 0.629904 V: 0.086291 -0.013759 -0.996175 Average |(XdotV)| 0.643139 sphere01_sample3_nd_test(): sphere01_sample3_nd() samples the unit sphere in ND. A few sample values: -0.823674 0.449521 -0.345676 -0.157015 0.957443 -0.242175 0.659146 0.495778 0.565448 -0.323099 0.909366 -0.262031 -0.910567 0.385606 0.148917 Spatial dimension = 3 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N increases. Average: -0.016304 -0.011349 0.005701 Now choose a random direction, sample the same number of points, and compute the dot product with the direction. Take the absolute value of each dot product and sum and average. V: 0.260676 -0.884361 0.387238 Average |(XdotV)| 0.497999 V: -0.275751 -0.868209 0.412523 Average |(XdotV)| 0.502051 V: -0.367460 -0.495035 -0.787346 Average |(XdotV)| 0.479801 V: -0.290019 0.447353 -0.846029 Average |(XdotV)| 0.496950 V: -0.342731 0.930016 -0.132687 Average |(XdotV)| 0.497572 sphere01_sample_nd_test(): sphere01_sample_nd() samples the unit sphere in N dimensions. A few sample values: 0.820656 -0.250149 -0.513759 0.011717 -0.637529 -0.770337 -0.808076 -0.228176 -0.543092 0.754474 -0.147306 0.639585 0.734726 -0.500832 0.457542 Spatial dimension = 3 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N increases. Average: 0.019792 0.019924 -0.019202 Now choose a random direction, sample the same number of points, and compute the dot product with the direction. Take the absolute value of each dot product and sum and average. V: -0.959552 -0.237174 -0.151682 Average |(XdotV)| 0.492590 V: 0.566821 0.440477 -0.696200 Average |(XdotV)| 0.518675 V: 0.086009 0.040288 -0.995479 Average |(XdotV)| 0.614681 V: -0.457787 -0.334012 0.823934 Average |(XdotV)| 0.567765 V: 0.195652 -0.291288 -0.936414 Average |(XdotV)| 0.592571 sphere01_sample2_nd_test(): sphere01_sample2_nd() samples the unit sphere in N dimensions. A few sample values: -0.346078 0.525816 0.777012 0.199794 0.243566 -0.949083 -0.291004 0.436123 -0.851536 0.721422 -0.654408 -0.226496 0.152001 0.550321 0.821001 Spatial dimension = 3 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N increases. Average: -0.005442 -0.012546 0.010964 Now choose a random direction, sample the same number of points, and compute the dot product with the direction. Take the absolute value of each dot product and sum and average. V: -0.670630 0.611277 -0.420233 Average |(XdotV)| 0.503017 V: 0.752857 -0.408218 0.516299 Average |(XdotV)| 0.508202 V: 0.419084 0.770508 -0.480298 Average |(XdotV)| 0.494331 V: -0.886017 -0.006231 -0.463611 Average |(XdotV)| 0.496314 V: -0.552421 -0.568757 0.609382 Average |(XdotV)| 0.504879 sphere01_volume_nd_test(): sphere01_volume_nd() evaluates the area of the unit sphere in N dimensions. DIM_NUM Exact Computed Volume Volume 1 2.000000 2.000000 2 3.141593 3.141593 3 4.188790 4.188790 4 4.934802 4.934802 5 5.263789 5.263789 6 5.167713 5.167713 7 4.724766 4.724766 8 4.058712 4.058712 9 3.298509 3.298509 10 2.550164 2.550164 11 1.884104 1.884104 12 1.335263 1.335263 13 0.910629 0.910629 14 0.599265 0.599265 15 0.381443 0.381443 16 0.235331 0.235331 17 0.140981 0.140981 18 0.082146 0.082146 19 0.046622 0.046622 20 0.025807 0.025807 string_2d_test(): string_2d() takes a set of line segments, and "strings" them together. I, (X1,Y1), (X2,Y2) 1 0.000000 0.000000 1.000000 1.000000 2 3.000000 4.000000 2.000000 4.000000 3 2.000000 2.000000 1.000000 3.000000 4 3.000000 2.000000 2.000000 3.000000 5 2.000000 1.000000 2.000000 2.000000 6 1.000000 1.000000 1.000000 2.000000 7 0.000000 5.000000 1.000000 6.000000 8 1.000000 2.000000 1.000000 3.000000 9 3.000000 2.000000 3.000000 3.000000 10 0.000000 0.000000 1.000000 0.000000 11 5.000000 5.000000 6.000000 6.000000 12 3.000000 3.000000 3.000000 4.000000 13 2.000000 4.000000 2.000000 3.000000 14 7.000000 4.000000 5.000000 5.000000 15 1.000000 0.000000 2.000000 1.000000 Found 4 groups of segments. STRING, ORDER, P1, P2 1 -3 2.000000 2.000000 2.000000 1.000000 1 -2 2.000000 1.000000 1.000000 0.000000 1 -1 1.000000 0.000000 0.000000 0.000000 1 0 0.000000 0.000000 1.000000 1.000000 1 1 1.000000 1.000000 1.000000 2.000000 1 2 1.000000 2.000000 1.000000 3.000000 1 3 1.000000 3.000000 2.000000 2.000000 2 -2 3.000000 2.000000 3.000000 3.000000 2 -1 3.000000 3.000000 3.000000 4.000000 2 0 3.000000 4.000000 2.000000 4.000000 2 1 2.000000 4.000000 2.000000 3.000000 2 2 2.000000 3.000000 3.000000 2.000000 3 0 0.000000 5.000000 1.000000 6.000000 4 -1 7.000000 4.000000 5.000000 5.000000 4 0 5.000000 5.000000 6.000000 6.000000 super_ellipse_points_2d_test(): super_ellipse_points_2d() returns points on a super ellipse; Superellipse center: 1: 5 2: -2 radii R1 = 3.000000, R2 = 1.000000 exponent EXPO = 1.500000 and angle PSI = 0.523599 Sample points: Row: 1 2 Col 1: 7.59808 -0.5 2: 7.40059 -0.461979 3: 6.91708 -0.484923 4: 6.24752 -0.593153 5: 5.51559 -0.771716 6: 4.86743 -0.980351 7: 4.5 -1.13397 8: 4.18324 -1.37537 9: 3.67848 -1.83238 10: 3.15787 -2.37696 11: 2.72936 -2.9027 12: 2.46774 -3.30996 13: 2.40192 -3.5 14: 2.59941 -3.53802 15: 3.08292 -3.51508 16: 3.75248 -3.40685 17: 4.48441 -3.22828 18: 5.13257 -3.01965 19: 5.5 -2.86603 20: 5.81676 -2.62463 21: 6.32152 -2.16762 22: 6.84213 -1.62304 23: 7.27064 -1.0973 24: 7.53226 -0.690042 tmat_test(): tmat geometric transformation matrix routines: tmat_init() initializes, tmat_rot_axis() for rotation about an axis, tmat_rot_vector() for rotation about a vector, tmat_scale() for scaling, tmat_shear() for shear, tmat_trans() for translation Initial transformation matrix: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 0 1 0 0 3 : 0 0 1 0 4 : 0 0 0 1 Transformation matrix for rotation about x by 30.000000 Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 0 0.866025 -0.5 0 3 : 0 0.5 0.866025 0 4 : 0 0 0 1 Transformation matrix for rotation about 1.000000 2.000000 3.000000 of 30.000000 Col: 1 2 3 4 Row 1 : 0.875595 -0.381753 0.29597 0 2 : 0.420031 0.904304 -0.0762129 0 3 : -0.238552 0.191048 0.952152 0 4 : 0 0 0 1 Transformation matrix for scaling by 2.000000 0.500000 10.000000 Col: 1 2 3 4 Row 1 : 2 0 0 0 2 : 0 0.5 0 0 3 : 0 0 10 0 4 : 0 0 0 1 Transformation matrix for xy shear coefficient of 0.500000 Col: 1 2 3 4 Row 1 : 1 0.5 0 0 2 : 0 1 0 0 3 : 0 0 1 0 4 : 0 0 0 1 Transformation matrix for translation by 1.000000 2.000000 3.000000 Col: 1 2 3 4 Row 1 : 1 0 0 1 2 : 0 1 0 2 3 : 0 0 1 3 4 : 0 0 0 1 tmat_mxp2_test(): tmat_mxp2() applies a geometric transformation matrix to a set of points. Points: Row: 1 2 3 Col 1: 1 0 0 2: 0 1 0 3: 0 0 1 4: 1 1 1 Initial transformation matrix: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 0 1 0 0 3 : 0 0 1 0 4 : 0 0 0 1 Rotation about x by 30.000000 Row: 1 2 3 Col 1: 1 0 0 2: 0 0.866025 0.5 3: 0 -0.5 0.866025 4: 1 0.366025 1.36603 Rotation about 1.000000 2.000000 3.000000 of 30.000000 Row: 1 2 3 Col 1: 0.875595 0.420031 -0.238552 2: -0.381753 0.904304 0.191048 3: 0.29597 -0.0762129 0.952152 4: 0.789812 1.24812 0.904648 Scaling by 2.000000 0.500000 10.000000 Row: 1 2 3 Col 1: 2 0 0 2: 0 0.5 0 3: 0 0 10 4: 2 0.5 10 xy shear coefficient of 0.500000 Row: 1 2 3 Col 1: 1 0 0 2: 0.5 1 0 3: 0 0 1 4: 1.5 1 1 Translation by 1.000000 2.000000 3.000000 Row: 1 2 3 Col 1: 2 2 3 2: 1 3 3 3: 1 2 4 4: 2 3 4 tp_to_xyz_test(): tp_to_xyz() converts (Theta,Phi) to normalized XYZ coordinates. xyz_to_tp() converts XYZ to (Theta,Phi) coordinates. T P X Y Z T P 2.5522 2.5605 -0.4563 0.3051 -0.8359 2.5522 2.5605 0.9306 1.8991 0.5655 0.7591 -0.3224 0.9306 1.8991 2.1364 1.9101 -0.5054 0.7961 -0.3328 2.1364 1.9101 2.9438 1.4810 -0.9765 0.1957 0.0897 2.9438 1.4810 1.0257 2.5570 0.2861 0.4719 -0.8339 1.0257 2.5570 2.3158 2.2898 -0.5101 0.5531 -0.6587 2.3158 2.2898 triangle_angles_2d_test() triangle_angles_2d() computes the angles of a triangle. Triangle vertices: Row: 1 2 Col 1: 0 1 2: 0 0 3: 1 0 Radians Degrees 0.785398 45.000000 1.570796 90.000000 0.785398 45.000000 triangle_angles_3d_test(): triangle_angles_3d() computes the angles of a triangle in 3D. Triangle vertices: Row: 1 2 3 Col 1: 1 2 3 2: 2.41421 3.41421 3 3: 1.70711 2.70711 4 Radians Degrees 0.785398 44.999999 0.785398 44.999995 1.570796 90.000006 triangle_area_test(): triangle_area() computes the area of a triangle. Triangle vertices (columns) Col: 1 2 3 Row 1 : 0 0 1 2 : 1 0 0 Triangle area is 0.500000 triangle_area_3d_test(): triangle_area_3d() computes the area; triangle_area_3d_2() computes the area; triangle_area_3d_3() computes the area; Triangle (vertices are columns) Col: 1 2 3 Row 1 : 1 2 3 2 : 2.41421 3.41421 3 3 : 1.70711 2.70711 4 Area #1 1.118034 Area #2 1.118034 Area #3 1.118034 triangle_area_heron_test(): triangle_area_heron() computes the area of a triangle. Triangle vertices: Row: 1 2 3 Col 1: 1 0 0 2: 0 1 0 3: 0 0 1 Side lengths: 1: 1.41421 2: 1.41421 3: 1.41421 The area is 0.866025 triangle_barycentric_test(): triangle_barycentric() converts XY coordinates to barycentric XSI coordinates in a triangle; Triangle vertices: Row: 1 2 Col 1: 0 1 2: 0 0 3: 1 0 X Y XSI 0.250000 0.250000 0.500000 0.250000 0.250000 0.750000 0.250000 0.000000 0.750000 0.250000 1.000000 1.000000 -1.000000 1.000000 1.000000 11.000000 0.500000 -10.500000 11.000000 0.500000 0.000000 1.000000 0.000000 0.000000 1.000000 0.500000 -10.000000 10.500000 0.500000 -10.000000 0.600000 0.600000 -0.200000 0.600000 0.600000 triangle_centroid_test(): triangle_centroid() computes the centroid of a triangle. Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0 1 Centroid: 1: 0.333333 2: 0.333333 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 0.866025 Centroid: 1: 0.5 2: 0.288675 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 10 Centroid: 1: 0.5 2: 3.33333 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 10 2 Centroid: 1: 3.66667 2: 0.666667 triangle_centroid_3d_test triangle_centroid_3d_test computes the centroid of a triangle in 3D. Triangle vertices: Row: 1 2 3 Col 1: 1 2 3 2: 2.41421 3.41421 3 3: 1.70711 2.70711 4 Centroid: 1: 1.70711 2: 2.70711 3: 3.33333 triangle_circumcenter_test():: triangle_circumcenter() computes the circumcenter of a triangle; triangle_circumcenter_2() computes the circumcenter of a triangle; Triangle vertices ( columns ) Col: 1 2 3 Row 1 : 10 11 10 2 : 5 5 6 triangle_circumenter: 1: 10.5 2: 5.5 triangle_circumcenter_2: 1: 10.5 2: 5.5 Triangle vertices ( columns ) Col: 1 2 3 Row 1 : 10 11 10.5 2 : 5 5 5.86603 triangle_circumenter: 1: 10.5 2: 5.28868 triangle_circumcenter_2: 1: 10.5 2: 5.28868 Triangle vertices ( columns ) Col: 1 2 3 Row 1 : 10 11 10.5 2 : 5 5 15 triangle_circumenter: 1: 10.5 2: 9.9875 triangle_circumcenter_2: 1: 10.5 2: 9.9875 Triangle vertices ( columns ) Col: 1 2 3 Row 1 : 10 11 20 2 : 5 5 7 triangle_circumenter: 1: 10.5 2: 28.5 triangle_circumcenter_2: 1: 10.5 2: 28.5 triangle_circumcenter_nd_test(): triangle_circumcenter_nd() computes the circumcenter of a triangle in ND. M2 = 2 circumcenter: 1: 2.58251 2: 11.0117 Distances from circumcenter to vertices: 0.467259 0.467259 0.467259 circumcenter: 1: 1.84727 2: 11.2205 Distances from circumcenter to vertices: 0.650266 0.650266 0.650266 circumcenter: 1: -9.44956 2: 14.4295 Distances from circumcenter to vertices: 12.266082 12.266082 12.266082 circumcenter: 1: -109.516 2: 42.8539 Distances from circumcenter to vertices: 116.285153 116.285153 116.285153 M2 = 3 circumcenter: 1: 3.52206 2: 10.2721 3: 9.21405 Distances from circumcenter to vertices: 0.513394 0.513394 0.513394 circumcenter: 1: 3.49453 2: 10.4954 3: 9.07927 Distances from circumcenter to vertices: 0.669027 0.669027 0.669027 circumcenter: 1: 2.72476 2: 16.7408 3: 5.31107 Distances from circumcenter to vertices: 7.830248 7.830248 7.830248 circumcenter: 1: -0.958097 2: 46.6208 3: -12.7175 Distances from circumcenter to vertices: 42.910405 42.910405 42.910405 M2 = 4 circumcenter: 1: 12.3924 2: 9.23745 3: 5.98239 4: 4.50852 Distances from circumcenter to vertices: 0.626812 0.626812 0.626812 circumcenter: 1: 12.11 2: 9.60839 3: 5.96158 4: 4.94586 Distances from circumcenter to vertices: 1.016268 1.016268 1.016268 circumcenter: 1: 6.38477 2: 17.1296 3: 5.53966 4: 13.8133 Distances from circumcenter to vertices: 13.800624 13.800624 13.800624 circumcenter: 1: -24.7612 2: 58.0455 3: 3.24436 4: 62.0529 Distances from circumcenter to vertices: 84.334096 84.334096 84.334096 M2 = 5 circumcenter: 1: 3.65867 2: 9.68403 3: 7.22817 4: 8.04439 5: 3.92722 Distances from circumcenter to vertices: 0.693719 0.693719 0.693719 circumcenter: 1: 3.38421 2: 9.74957 3: 7.27214 4: 8.01034 5: 3.75905 Distances from circumcenter to vertices: 0.782300 0.782300 0.782300 circumcenter: 1: 5.90809 2: 9.14687 3: 6.86782 4: 8.32344 5: 5.30551 Distances from circumcenter to vertices: 2.788406 2.788406 2.788406 circumcenter: 1: 86.1167 2: -10.0068 3: -5.98122 4: 18.2737 5: 54.4516 Distances from circumcenter to vertices: 100.067194 100.067194 100.067194 triangle_circumcircle_test(): triangle_circumcircle() computes the circumcenter. triangle_circumcircle_2() computes the circumcenter. Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0 1 Circumcenter 1: 0.5 2: 0.5 Circumradius: 0.707107 Circumcenter2 1: 0.5 2: 0.5 Circumradius2: 0.707107 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 0.866025 Circumcenter 1: 0.5 2: 0.288675 Circumradius: 0.577350 Circumcenter2 1: 0.5 2: 0.288675 Circumradius2: 0.577350 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 10 Circumcenter 1: 0.5 2: 4.9875 Circumradius: 5.012500 Circumcenter2 1: 0.5 2: 4.9875 Circumradius2: 5.012500 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 10 2 Circumcenter 1: 0.5 2: 23.5 Circumradius: 23.505319 Circumcenter2 1: 0.5 2: 23.5 Circumradius2: 23.505319 triangle_circumradius_test(): triangle_circumradius() computes the circumradius of a triangle. Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0 1 Circumradius: 0.707107 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 0.866025 Circumradius: 0.577350 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 10 Circumradius: 5.012500 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 10 2 Circumradius: 23.505319 triangle_contains_line_exp_3d_test(): triangle_contains_line_exp_3d() determines whether a triangle "contains" an explicit line in 3D. Triangle vertices: Row: 1 2 3 Col 1: 8 4 2 2: 9 0 5 3: 2 1 2 Line point P1: 1: 3 2: 0 3: -7 Line point P2: 1: 5 2: 1 3: -2 The triangle contains the line. Intersection point: 1: 7 2: 2 3: 3 Expected answer: The triangle contains the line, and the intersection point is at: 7, 2, 3. triangle_contains_line_par_3d_test(): triangle_contains_line_par_3d() determines whether a triangle "contains" a parametric line in 3D. Triangle vertices: Row: 1 2 3 Col 1: 8 4 2 2: 9 0 5 3: 2 1 2 Parametric base point P0: 1: 3 2: 0 3: -7 Parametric direction PD: 1: 0.365148 2: 0.182574 3: 0.912871 The triangle contains the line. Intersection point: 1: 7 2: 2 3: 3 Expected answer: The triangle contains the line, and the intersection point is at: ( 7, 2, 3 ). triangle_contains_point_test(): triangle_contains_point_2d_1() reports if a point is inside a triangle (and doesn't care about the ordering of the vertices) triangle_contains_point_2d_2() reports if a point is inside a triangle (and DOES care about the ordering of the vertices) triangle_contains_point_2d_3() reports if a point is inside a triangle (and doesn't care about the ordering of the vertices) Triangle vertices: Row: 1 2 Col 1: 0 1 2: 0 0 3: 1 0 X Y In1 In2 In3 0.250000 0.250000 1 1 1 0.750000 0.250000 1 1 1 1.000000 1.000000 0 0 0 11.000000 0.500000 0 0 0 0.000000 1.000000 1 1 1 0.500000 -10.000000 0 0 0 0.600000 0.600000 0 0 0 Repeat the test, but reverse the triangle vertex ordering. Triangle vertices (reversed): Row: 1 2 Col 1: 1 0 2: 0 0 3: 0 1 X Y In1 In2 In3 0.250000 0.250000 1 0 1 0.750000 0.250000 1 0 1 1.000000 1.000000 0 0 0 11.000000 0.500000 0 0 0 0.000000 1.000000 1 0 1 0.500000 -10.000000 0 0 0 0.600000 0.600000 0 0 0 triangle_diameter_test(): triangle_diameter() computes the diameter of the SMALLEST circle around the triangle. Triangle vertices: Row: 1 2 Col 1: 4 2 2: 1 5 3: -2 2 Diameter = 6.000000 Triangle vertices: Row: 1 2 Col 1: 4 2 2: 5 4 3: 6 6 Diameter = 6.000000 Triangle vertices: Row: 1 2 Col 1: 4 2 2: 1 5 3: 4 2 Diameter = 0.000000 triangle_gridpoints_test(): triangle_gridpoints() produces a set of gridpoints in or on the triangle. Triangle vertices: Row: 1 2 Col 1: 0 1 2: 0 0 3: 1 0 Number of grid points is 10 Grid points: Col: 1 2 3 4 5 Row 1 : 1 0.666667 0.333333 0 0.666667 2 : 0 0 0 0 0.333333 Col: 6 7 8 9 10 Row 1 : 0.333333 0 0.333333 0 0 2 : 0.333333 0.333333 0.666667 0.666667 1 triangle_incenter_test(): triangle_incenter() computes the incenter of a triangle. Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0 1 Incenter 1: 0.292893 2: 0.292893 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 0.866025 Incenter 1: 0.5 2: 0.288675 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 10 Incenter 1: 0.5 2: 0.475625 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 10 2 Incenter 1: 0.989247 2: 0.0979548 triangle_inradius_test(): triangle_inradius() computes the inradius of a triangle. Triangle vertices: Row: 1 2 Col 1: 0 1 2: 0 0 3: 1 0 Incircle radius is 0.292893 triangle_lattice_layer_point_next_test(): triangle_lattice_layer_point_next() returns the next point in a triangle lattice layer defined by: C(3) - 1 < X(1)/C(1) + X(2)/C(2) <= C(3). N = 2 C = 2 3 Layer 0 1 0 0 No more. Layer 1 1 1 0 2 2 0 3 0 1 4 1 1 5 0 2 6 0 3 No more. Layer 2 1 3 0 2 4 0 3 2 1 4 3 1 5 1 2 6 2 2 7 1 3 8 2 3 9 0 4 10 1 4 11 0 5 12 0 6 No more. Layer 3 1 5 0 2 6 0 3 4 1 4 5 1 5 3 2 6 4 2 7 3 3 8 4 3 9 2 4 10 3 4 11 1 5 12 2 5 13 1 6 14 2 6 15 0 7 16 1 7 17 0 8 18 0 9 No more. Layer 4 1 7 0 2 8 0 3 6 1 4 7 1 5 5 2 6 6 2 7 5 3 8 6 3 9 4 4 10 5 4 11 3 5 12 4 5 13 3 6 14 4 6 15 2 7 16 3 7 17 1 8 18 2 8 19 1 9 20 2 9 21 0 10 22 1 10 23 0 11 24 0 12 No more. triangle_lattice_point_next_test(): triangle_lattice_point_next() returns the next lattice point in a triangle defined by: 0 <= X(1)/C(1) + X(2)/C(2) <= C(3). N = 2 C = 3 2 1 1 0 0 2 1 0 3 2 0 4 3 0 5 0 1 6 1 1 7 0 2 No more. triangle_orientation_test(): triangle_orientation() determines orientation of a triangle. Triangle vertices: Row: 1 2 Col 1: 4 2 2: 1 5 3: -2 2 The points are counterclockwise. Triangle vertices: Row: 1 2 Col 1: 1 5 2: 4 2 3: 1 -1 The points are clockwise. Triangle vertices: Row: 1 2 Col 1: 1 5 2: 2 7 3: 3 9 The points are colinear. Triangle vertices: Row: 1 2 Col 1: 1 5 2: 4 2 3: 1 5 The points are not distinct. triangle_orthocenter_2d_test(): triangle_orthocenter_2d() computes the orthocenter. Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0 1 Orthocenter 1: 0 2: 0 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 0.866025 Orthocenter 1: 0.5 2: 0.288675 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 10 Orthocenter 1: 0.5 2: 0.025 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 10 2 Orthocenter 1: 10 2: -45 triangle_point_dist_test(): triangle_point_dist() computes the distance to a point from a triangle. Triangle vertices: Row: 1 2 Col 1: 0 1 2: 0 0 3: 1 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 triangle_point_dist_signed_2d_test(): triangle_point_dist_signed_2d_test() computes signed distance to a point; Triangle vertices: Row: 1 2 Col 1: 0 1 2: 0 0 3: 1 0 P DIST_SIGNED 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 triangle_point_dist_3d_test(): triangle_point_dist_3d() computes the distance to a point; Triangle vertices: Row: 1 2 3 Col 1: 1 2 3 2: 2.41421 3.41421 3 3: 1.70711 2.70711 4 P DIST 1.000000 2.000000 3.000000 0.000000 1.353553 2.353553 3.000000 0.000000 0.000000 0.000000 0.000000 3.741657 triangle_point_near_test(): triangle_point_near() computes the nearest point on a triangle to a given point. Triangle vertices: Row: 1 2 Col 1: 0 1 2: 0 0 3: 1 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 triangle_quality_2d_test triangle_quality_2d() computes the quality. Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0 1 Quality = 0.828427 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 0.866025 Quality = 1.000000 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 0.5 10 Quality = 0.189775 Triangle vertices: Row: 1 2 Col 1: 0 0 2: 1 0 3: 10 2 Quality = 0.008335 triangle_sample_test(): triangle_sample() samples a triangle. triangle_xy_to_xsi() converts XY to XSI coordinates. We are computing the XSI coordinates just to verify that the points are inside the triangle. Triangle vertices: Row: 1 2 Col 1: 4 2 2: 1 5 3: -2 2 Sample points (X,Y) and (XSI1,XSI2,XSI3) coordinates: 1.958835 3.828080 0.355126 0.609360 0.035514 2.076036 2.394825 0.613535 0.131608 0.254856 1.474303 3.341097 0.355534 0.447032 0.197433 -0.077651 3.810061 0.018715 0.603354 0.377932 1.588024 3.026290 0.426956 0.342097 0.230948 1.547233 4.031377 0.252643 0.677126 0.070232 -1.754431 2.107757 0.022969 0.035919 0.941112 0.853861 2.138429 0.452572 0.046143 0.501285 -1.021868 2.387925 0.098368 0.129308 0.772324 -1.368289 2.249674 0.063673 0.083225 0.853102 triangle_xsi_to_xy_test triangle_xsi_to_xy() converts XSI to XY coordinates. We verify that (X,Y) -> (XSI1,XSI2,XSI3) -> (X,Y) works properly. Triangle vertices: Row: 1 2 Col 1: 4 2 2: 1 5 3: -2 2 Sample points: 1.000000 3.000000 0.333333 0.333333 0.333333 1.000000 3.000000 3.000000 0.000000 1.166667 -0.666667 0.500000 3.000000 0.000000 1.473885 3.353656 0.353371 0.451219 0.195410 1.473885 3.353656 1.699318 3.962049 0.289545 0.654016 0.056439 1.699318 3.962049 2.711410 2.924733 0.631113 0.308244 0.060643 2.711410 2.924733 -1.041357 2.339091 0.103259 0.113030 0.783711 -1.041357 2.339091 2.546258 2.599089 0.657862 0.199696 0.142442 2.546258 2.599089 1.315091 4.486011 0.138180 0.828670 0.033150 1.315091 4.486011 2.668037 2.699388 0.661441 0.233129 0.105429 2.668037 2.699388 1.939170 2.786156 0.525502 0.262052 0.212446 1.939170 2.786156 triangle_xy_to_xsi_test(): triangle_xy_to_xsi() converts XY to XSI coordinates. We verify that (X,Y) -> (XSI1,XSI2,XSI3) -> (X,Y) works properly. Triangle vertices: Row: 1 2 Col 1: 4 2 2: 1 5 3: -2 2 Sample points: 1.000000 3.000000 0.333333 0.333333 0.333333 1.000000 3.000000 3.000000 0.000000 1.166667 -0.666667 0.500000 3.000000 0.000000 0.149172 2.812550 0.222770 0.270850 0.506380 0.149172 2.812550 1.005921 2.279798 0.454354 0.093266 0.452380 1.005921 2.279798 0.874728 2.426745 0.407997 0.142248 0.449754 0.874728 2.426745 3.604780 2.057462 0.924553 0.019154 0.056293 3.604780 2.057462 0.125166 3.380308 0.124143 0.460103 0.415754 0.125166 3.380308 3.334556 2.264457 0.845017 0.088152 0.066831 3.334556 2.264457 0.996317 3.281611 0.285784 0.427204 0.287012 0.996317 3.281611 -0.956864 2.401346 0.106965 0.133782 0.759253 -0.956864 2.401346 tube_2d_test(): tube_2d() computes corners of a tube of radius DIST surrounding a sequence of points. Test number 1 Number of points N = 4 Tube radius DIST = 0.500000 Points to surround: Row: 1 2 Col 1: 0 0 2: 4 3 3: 4 0 4: 0 0 P1: Row: 1 2 Col 1: -0.1 -0.7 2: 4.5 2.75 3: 4.5 -0.5 4: -0.5 -0.5 P2: Row: 1 2 Col 1: -0.7 0.1 2: 3.5 3.25 3: 3.5 0.5 4: -0.5 0.5 Test number 2 Number of points N = 5 Tube radius DIST = 0.500000 Points to surround: Row: 1 2 Col 1: 0 0 2: 2 0 3: 2 1 4: 0 1 5: 0 0 P1: Row: 1 2 Col 1: -0.5 -0.5 2: 2.5 -0.5 3: 2.5 1.5 4: -0.5 1.5 5: -0.5 -0.5 P2: Row: 1 2 Col 1: -0.5 0.5 2: 1.5 0.5 3: 1.5 0.5 4: 0.5 0.5 5: 0.5 -0.5 Test number 3 Number of points N = 5 Tube radius DIST = 1.000000 Points to surround: Row: 1 2 Col 1: 10 20 2: 20 20 3: 10 10 4: 20 10 5: 10 20 P1: Row: 1 2 Col 1: 9 19 2: 20.4142 19 3: 10.4142 9 4: 21 9 5: 8.58579 20 P2: Row: 1 2 Col 1: 9 21 2: 19.5858 21 3: 9.58579 11 4: 21 11 5: 10 21.4142 Test number 4 Number of points N = 5 Tube radius DIST = 1.000000 Points to surround: Row: 1 2 Col 1: 0 0 2: 10 0 3: 10 10 4: 10 0 5: 0 0 P1: Row: 1 2 Col 1: -1 -1 2: 11 -1 3: 11 11 4: 11 -1 5: -1 -1 P2: Row: 1 2 Col 1: -1 1 2: 9 1 3: 9 11 4: 9 1 5: -1 1 tuple_next2_test(): tuple_next2() returns the next "tuple", that is, a vector of N integers. N = 3 The minimum tuple: 2 3 8 The maximum tuple: 4 3 5 1 2 3 8 2 2 3 7 3 2 3 6 4 2 3 5 5 3 3 8 6 3 3 7 7 3 3 6 8 3 3 5 9 4 3 8 10 4 3 7 11 4 3 6 12 4 3 5 vector_directions_nd_test(): vector_directions_nd() computes the angles that a vector makes with the axes. X Y AX AY AX AY (__Radians___) (___Degrees___) 1.000000 0.000000 0.000000 1.570796 0.000000 90.000000 1.732051 1.000000 0.523599 1.047198 30.000000 60.000000 -1.732051 1.000000 2.617994 1.047198 150.000000 60.000000 -1.732051 -1.000000 2.617994 2.094395 150.000000 120.000000 1.732051 -1.000000 0.523599 2.094395 30.000000 120.000000 vector_rotate_2d_test(): vector_rotate_2d() rotates a vector through a given angle around the origin. X1 Y1 Angle X2 Y2 1.000000 0.000000 30.000000 0.866025 0.500000 0.000000 2.000000 -45.000000 1.414214 1.414214 1.000000 1.000000 270.000000 1.000000 -1.000000 vector_rotate_3d_test(): vector_rotate_3d() rotates a vector through a given angle around the origin. Rotations will be about the following axis: 1.000000 1.000000 1.000000 V1 Angle V2 ---------------------- ------ ---------------------- 1.000000 0.000000 0.000000 30.000000 0.910684 0.333333 -0.244017 0.000000 2.000000 0.000000 -45.000000 1.011759 1.609476 -0.621234 0.000000 0.000000 3.000000 90.000000 2.732051 -0.732051 1.000000 1.000000 1.000000 1.000000 270.000000 1.000000 1.000000 1.000000 1.000000 1.000000 -2.000000 30.000000 0.000000 1.732051 -1.732051 Rotations will be about the following axis: 0.000000 0.000000 2.000000 V1 Angle V2 ---------------------- ------ ---------------------- 1.000000 1.000000 1.000000 90.000000 -1.000000 1.000000 1.000000 vector_rotate_base_2d_test(): vector_rotate_base_2d() rotates a vector (X1,Y1) through an angle around a base point (XB,YB). P1 PB Angle P2 11.000000 5.000000 10.000000 5.000000 30.000000 10.866025 5.500000 10.000000 7.000000 10.000000 5.000000 -45.000000 11.414214 6.414214 11.000000 6.000000 10.000000 5.000000 270.000000 11.000000 4.000000 10.000000 5.000000 10.000000 5.000000 20.000000 10.000000 5.000000 vector_separation_nd_test(): vector_separation_nd() computes the separation angle between two vectors. -----Vector 1----- -----Vector 2----- Radians Degrees 1.000000 0.000000 0.000000 1.000000 2.000000 3.000000 1.300247 74.498640 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 1.570796 90.000000 1.000000 0.000000 0.000000 -3.000000 2.000000 -1.000000 2.501070 143.300775 1.000000 0.000000 0.000000 -2.000000 -4.000000 -6.000000 1.841346 105.501360 1.000000 2.000000 3.000000 0.000000 0.000000 1.000000 0.640522 36.699225 1.000000 2.000000 3.000000 -3.000000 2.000000 -1.000000 1.714144 98.213211 1.000000 2.000000 3.000000 -2.000000 -4.000000 -6.000000 3.141593 180.000000 0.000000 0.000000 1.000000 -3.000000 2.000000 -1.000000 1.841346 105.501360 0.000000 0.000000 1.000000 -2.000000 -4.000000 -6.000000 2.501070 143.300775 -3.000000 2.000000 -1.000000 -2.000000 -4.000000 -6.000000 1.427449 81.786789 vector_unit_nd_test(): vector_unit_nd() normalizes a vector in ND. Original vector: 1: 6.72481 2: -7.39038 3: 7.54246 4: 1.60966 5: -9.03148 Norm of original vector = 15.5206 Normalized vector: 1: 0.433284 2: -0.476167 3: 0.485965 4: 0.103712 5: -0.581904 Norm of normalized vector = 1 voxels_dist_l1_nd_test(): voxels_dist_l1_nd() prints the voxels on a line in 3D. P1: 1 1 5 P2: 9 4 4 L1 distance = 12 voxels_line_3d_test(): voxels_line_3d() computes the voxels on a line in 3D starting at the first voxel, and heading towards the second one. Starting voxel: 1 1 5 "Heading" voxel: 9 4 4 Number of voxels we will compute is 13 The voxels: Row: 1 2 3 Col 1: 1 1 5 2: 2 1 5 3: 2 2 5 4: 3 2 5 5: 4 2 5 6: 5 2 5 7: 5 3 5 8: 5 3 4 9: 6 3 4 10: 7 3 4 11: 8 3 4 12: 8 4 4 13: 9 4 4 voxels_region_3d_test(): voxels_region_3d() groups voxels into regions. Number of regions found = 3 The nonzero ISHOW array elements are: 2 4 1 1 2 5 1 1 2 7 1 1 3 3 1 1 3 4 1 1 3 5 1 1 3 6 1 1 3 7 1 1 4 4 1 1 4 5 1 1 4 7 1 1 5 7 1 1 6 2 1 2 6 3 1 2 6 6 1 1 6 7 1 1 7 3 1 2 8 8 1 3 The stack-based list of regions is: Region 3 include 1 voxels: 8 8 1 Region 2 include 3 voxels: 7 3 1 6 3 1 6 2 1 Region 1 include 14 voxels: 6 7 1 6 6 1 5 7 1 4 7 1 3 7 1 2 7 1 4 5 1 4 4 1 3 6 1 3 5 1 3 4 1 3 3 1 2 5 1 2 4 1 voxels_step_3d_test(): voxels_step_3d() steps along a line from one voxel to another. 0 1 1 5 1 2 1 5 2 2 2 5 3 3 2 5 4 4 2 5 5 5 3 4 6 6 3 4 7 7 3 4 8 7 4 4 9 8 4 4 10 9 4 4 Now, as a check, reverse direction and return. 0 9 4 4 1 8 4 4 2 8 3 4 3 7 3 4 4 6 3 4 5 5 2 5 6 4 2 5 7 3 2 5 8 3 1 5 9 2 1 5 10 1 1 5 wedge01_volume_test(): wedge01_volume() returns the volume of the unit wedge. Unit wedge volume = 1 xy_to_polar_test(): xy_to_polar() converts (X,Y) to (R,Theta). polar_to_xy() converts (R,Theta) to (X,Y); X Y ===> R T => X Y -0.739531 -0.966570 1.217031 -2.223897 -0.739531 -0.966570 -0.271536 0.717624 0.767278 1.932528 -0.271536 0.717624 -0.057371 0.310737 0.315988 1.753368 -0.057371 0.310737 -0.904352 -0.901977 1.277268 -2.357509 -0.904352 -0.901977 0.440856 -0.364334 0.571921 -0.690647 0.440856 -0.364334 -0.400915 0.286169 0.492570 2.521672 -0.400915 0.286169 -0.926079 -0.512888 1.058620 -2.635815 -0.926079 -0.512888 -0.885265 0.877018 1.246136 2.360874 -0.885265 0.877018 0.886342 -0.103403 0.892353 -0.116137 0.886342 -0.103403 0.768409 -0.892501 1.177714 -0.859973 0.768409 -0.892501 xyz_to_radec_test(): xyz_to_radec() converts RADEC to XYZ coordinates. radec_to_xyz() converts XYZ to RADEC coordinates. P1 RA DEC P2 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 6.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 90.000000 0.000000 0.000000 1.000000 1.000000 1.000000 1.000000 3.000000 35.264390 0.577350 0.577350 0.577350 5.000000 -2.000000 -1.000000 -1.453427 -10.519735 0.912871 -0.365148 -0.182574 -2.000000 -2.000000 -2.000000 -9.000000 -35.264390 -0.577350 -0.577350 -0.577350 xyz_to_rtp_test(): xyz_to_rtp() converts (R,Theta,Phi) to XYZ coordinates. rtp_to_xyz() converts XYZ to (R,Theta,Phi) coordinates. X1 Y1 Z1 R THETA PHI X2 Y2 Z2 0.8066 1.6953 0.5789 1.9646 1.1267 1.2717 0.8066 1.6953 0.5789 -0.4154 -1.4546 1.2296 1.9494 -1.8490 0.8883 -0.4154 -1.4546 1.2296 -0.3877 0.6552 0.3048 0.8201 2.1052 1.1900 -0.3877 0.6552 0.3048 -0.5733 -1.1683 -0.2257 1.3208 -2.0270 1.7425 -0.5733 -1.1683 -0.2257 -1.2448 1.4029 2.6049 3.2099 2.2966 0.6240 -1.2448 1.4029 2.6049 xyz_to_tp_test(): xyz_to_tp() converts XYZ to (Theta,Phi) coordinates. tp_to_xyz() converts (Theta,Phi) to normalized XYZ coordinates. P1 T P P2 1.000000 0.000000 0.000000 0.000000 1.570796 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 1.570796 1.570796 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 1.000000 1.000000 1.000000 0.785398 0.955317 0.577350 0.577350 0.577350 5.000000 -2.000000 -1.000000 -0.380506 1.754400 0.912871 -0.365148 -0.182574 -2.000000 -2.000000 -2.000000 -2.356194 2.186276 -0.577350 -0.577350 -0.577350 geometry_test(): Normal end of execution. 11-May-2022 11:56:06