10-Jan-2023 07:02:22 geometry_test(): MATLAB/Octave version 4.2.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.380919 -0.783932 -0.147449 -0.273009 -0.634827 0.283016 -0.043798 -0.832585 -0.135956 -0.800625 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.002261 -0.002065 Now average the distance of the points from the center, which should be 1/sqrt(2) = 0.707107 Average: 0.655085 Now average the angle THETA, which should be PI. Average: -0.090966 ball01_sample_3d_test(): ball01_sample_3d() samples the unit ball in 3d; A few sample values: -0.273432 -0.309453 -0.565597 0.113558 -0.161769 0.843776 0.500814 -0.291928 0.405249 -0.574974 0.334884 -0.319654 0.253067 0.362138 -0.025784 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.014633 0.018194 -0.005124 Now average the distance of the points from the center, which should be the 1/2**(1/dim_num) = 0.793701 Average: 0.745141 Now average the angle THETA, which should be PI. Average: -0.060365 Now average the angle PHI, which should be PI/2. Average: 1.554586 ball01_sample_nd_test(): ball_unit_sample_nd() samples the unit ball in N dimensions; A few sample values: 0.616761 -0.182088 -0.028452 -0.424488 -0.399577 -0.336309 -0.418397 0.235439 0.555842 -0.844594 -0.266996 -0.295124 -0.314936 -0.834127 0.376249 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N increases. Average: -0.018066 -0.006251 0.002301 Now average the distance of the points from the center, which should be the 1/2^(1/dim_num) = 0.793701 Average: 0.748181 Now average the angle THETA, which should be PI. Average: -0.089950 Now average the angle PHI, which should be PI/2. Average: 1.577293 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 3.3388 -8.2136 3.8663 -9.3807 -4.7304 5.5059 -1.7064 -3.4160 1.1816 -6.9062 -2.6721 2.4051 -7.8554 -4.3328 3.9711 -8.2965 -8.5261 6.8964 5.2349 5.5627 2.6385 2.9115 -5.0152 0.7990 -3.4087 8.8534 4.4869 5.3188 1.9110 0.6517 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 = 2.872612 Point #P1: -9.536986 8.144436 Point #P2: -5.343203 9.272899 Point #Q1: 6.403227 -0.452836 Point #Q2: 5.198493 1.835036 Center #1: -1.011887 7.463580 Center #2: 4.675355 8.993903 Center #1: -3.755969 12.674782 Center #2: 1.931272 14.205104 2.872612 2.872612 2.872612 2.872612 2.872612 2.872612 2.872612 2.872612 Radius R = 4.903837 Point #P1: -3.529070 -4.199280 Point #P2: 6.873379 -8.874030 Point #Q1: 0.337538 -2.018215 Point #Q2: 9.560921 -4.208091 Center #1: -67.292679 19.079159 Center #2: -19.735644 -2.292467 Center #1: -16.564439 7.034924 Center #2: 30.992596 -14.336701 4.903837 4.903837 4.903837 4.903837 4.903837 4.903837 4.903837 4.903837 Radius R = 3.470571 Point #P1: 7.853111 4.796396 Point #P2: -4.495842 8.940648 Point #Q1: -7.764064 -5.684460 Point #Q2: -6.115365 -1.815349 Center #1: -3.838617 12.380880 Center #2: 2.762454 10.165590 Center #1: -6.568147 5.975311 Center #2: 0.032925 3.760021 3.470571 3.470571 3.470571 3.470571 3.470571 3.470571 3.470571 3.470571 Radius R = 3.359749 Point #P1: 6.406915 -4.213499 Point #P2: -3.205717 -6.085419 Point #Q1: 4.308398 3.334175 Point #Q2: -2.576798 -5.462268 Center #1: 5.155639 -1.034307 Center #2: -4.912042 -2.994841 Center #1: -1.166292 -9.111130 Center #2: -11.233974 -11.071664 3.359749 3.359749 3.359749 3.359749 3.359749 3.359749 3.359749 3.359749 Radius R = 3.119895 Point #P1: -9.414818 -2.106152 Point #P2: 2.649873 -0.214172 Point #Q1: 5.330179 -1.439696 Point #Q2: -3.869064 -7.389941 Center #1: 9.827083 -2.246669 Center #2: -5.338877 -4.624989 Center #1: 22.716995 6.090772 Center #2: 7.551035 3.712451 3.119895 3.119895 3.119895 3.119895 3.119895 3.119895 3.119895 3.119895 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 = 11.179330 Point #1: 2.250561 -0.024214 -9.932025 Point #2: -6.640604 -1.212176 -4.212359 Point #3: -1.311899 6.439701 -3.319831 Center #1: -0.610354 8.094624 -2.799209 Center #2: -3.779689 -9.331014 -11.345175 9.768416 20.616223 9.169397 7.049862 21.335540 4.389987 9.397805 14.869789 17.748386 3.868354 9.967671 13.254725 -7.779425 -5.964938 1.938080 -0.687340 -5.017354 -2.624242 -7.779425 -5.964938 1.938080 -0.687340 -5.017354 -2.624242 Radius R = 20.487425 Point #1: 4.988168 7.069850 9.302062 Point #2: -0.354929 -1.011068 -2.837210 Point #3: 7.163611 3.244666 -0.836423 Center #1: 18.677040 5.927925 -5.898115 Center #2: -14.043800 0.130857 12.362967 20.248513 3.684011 22.753564 34.823848 12.823863 7.998704 36.783575 12.484154 9.579869 21.973279 3.217049 23.909309 0.038945 -0.114467 -0.278973 0.432710 0.481065 0.615645 0.038945 -0.114467 -0.278973 0.432710 0.481065 0.615645 Radius R = 7.361385 Point #1: 1.082009 1.151991 0.259134 Point #2: -3.688702 4.071302 3.130695 Point #3: -6.650382 -4.450585 -9.086984 Center #1: -5.546517 0.045276 -2.745496 Center #2: 2.939824 5.178017 6.135325 11.068557 1.531460 6.234421 13.086173 6.298515 9.049199 3.719398 7.561849 9.214079 6.727112 9.167063 10.478526 0.540100 0.516135 0.821891 2.173817 -0.483576 -0.161467 0.540100 0.516135 0.821891 2.173817 -0.483576 -0.161467 Radius R = 17.559882 Point #1: -6.257877 8.802400 -4.992456 Point #2: 3.575561 -0.654996 5.929558 Point #3: -8.174340 -4.960987 5.489499 Center #1: -13.337538 -4.769171 3.612212 Center #2: 10.655222 12.916576 -2.675110 24.696940 13.654803 14.085348 28.602811 14.178287 4.855975 23.115703 26.557852 12.244981 14.155371 17.895824 10.825528 10.114684 -6.603684 8.709944 -0.801386 3.894942 -3.414550 10.114684 -6.603684 8.709944 -0.801386 3.894942 -3.414550 Radius R = 5.137977 Point #1: 0.302886 5.222323 4.379356 Point #2: -3.167512 4.461939 6.426467 Point #3: 7.270673 -1.527400 5.858965 Center #1: 0.483731 0.930402 7.198136 Center #2: -3.348358 8.753860 3.607687 6.137006 5.541628 7.706740 8.029560 7.711770 10.748438 12.103954 10.150222 3.758222 12.513219 12.882409 7.387733 -5.757626 2.347609 0.958742 -11.475434 1.094806 4.331550 -5.757626 2.347609 0.958742 -11.475434 1.094806 4.331550 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 = 12.613737 Point #1: -0.953097 6.925648 Point #2: -9.210450 6.192278 Center #1: -6.135691 18.425520 Center #2: -4.027855 -5.307594 14.051970 22.533927 12.705628 30.222493 11.376879 12.985140 11.459076 12.144108 Radius R = 15.083455 Point #1: -8.271157 5.955217 Point #2: 2.531920 1.757610 Center #1: -7.913240 -9.123992 Center #2: 2.174003 16.836819 13.873075 15.103306 14.234701 15.945831 11.108508 27.364570 0.549079 20.784914 Radius R = 6.918725 Point #1: -7.514597 7.117550 Point #2: -8.951674 5.279595 Center #1: -13.605539 10.399195 Center #2: -2.860732 1.997950 21.599675 18.211895 19.450109 20.016653 11.010203 10.802725 10.166833 11.430812 Radius R = 11.111767 Point #1: -9.729752 -5.320142 Point #2: -3.855213 3.311380 Center #1: 1.316674 -6.523402 Center #2: -14.901639 4.514640 12.886848 3.424692 5.543218 10.190298 10.888227 17.309698 21.301117 8.455902 Radius R = 13.625331 Point #1: -6.611911 3.568143 Point #2: 5.036506 1.138088 Center #1: -3.290978 -9.646283 Center #2: 1.715573 14.352513 7.620770 13.558336 9.432052 18.217765 8.531061 23.575618 3.370769 16.168149 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.626573 1.96336 -0.145709 2: -0.46136 -1.90536 -0.338015 3: -0.752918 -0.0867909 -0.404042 4: -0.345611 0.191312 0.00605488 5: 0.00204748 1.73656 0.489556 6: -0.488629 1.60239 -0.111093 7: -0.867726 0.325765 -0.298976 8: -0.0272963 1.60306 -0.289103 9: 0.935503 1.30735 0.20083 10: -0.857342 -1.83377 0.430619 11: -0.612943 0.179034 -0.0300802 12: -0.630117 1.85084 -0.107734 13: 0.526196 -1.35521 -0.408457 14: 0.155744 0.364612 0.640932 15: 0.0774863 -1.34477 0.224322 16: -0.834189 -1.15644 0.0193945 17: -0.130134 0.359186 0.244751 18: 0.836664 0.0315466 0.143524 19: -0.308061 -1.71935 -0.40488 20: -0.729756 -0.936861 -0.0111083 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.990202 0.139625 0.002220 0.949164 0.236370 -0.207886 0.997480 -0.056828 -0.042477 0.993740 -0.091559 0.064010 0.998686 0.039945 -0.032119 0.935752 -0.080938 0.343244 0.996276 -0.027917 0.081578 0.993950 -0.103569 -0.036568 0.999517 -0.009302 0.029667 0.991314 -0.001509 0.131505 0.989914 0.137831 -0.032748 0.927949 0.268466 0.258529 0.962413 -0.122857 -0.242215 0.992840 -0.018929 0.117941 0.994753 -0.016018 -0.101047 0.949097 -0.183800 -0.255799 0.998778 -0.012664 -0.047771 0.999691 -0.015407 0.019493 0.990224 -0.139104 0.010353 0.995164 -0.088816 -0.041968 Using Sigma = 0.500000 0.365502 -0.863533 -0.347446 0.777478 0.232731 -0.584264 0.053368 -0.980136 0.191012 0.491692 0.720652 -0.488774 0.650463 0.732562 -0.200628 0.988612 -0.047996 0.142625 0.749554 0.017205 -0.661719 0.418719 0.858626 0.295697 0.610126 0.135138 -0.780694 0.715828 0.670825 -0.193865 0.876245 0.464217 0.129215 -0.965388 -0.170345 0.197506 -0.273933 -0.113063 0.955080 0.372936 0.611369 0.697959 0.581850 0.810530 -0.067023 0.408515 -0.864642 -0.292419 -0.342826 0.221556 -0.912898 0.396076 -0.764107 0.509180 -0.077912 -0.619299 0.781280 0.618462 0.749477 0.236197 Using Sigma = 0.100000 -0.057314 -0.825455 -0.561551 -0.161415 0.571501 0.804569 -0.388093 -0.913279 0.123713 -0.570131 0.238943 0.786039 -0.595903 0.542016 0.592553 -0.018172 -0.812632 0.582494 -0.186892 -0.455948 0.870163 0.315084 0.626009 -0.713327 0.284828 -0.809978 0.512648 -0.062721 -0.906083 0.418426 -0.583053 0.055461 0.810539 -0.102992 -0.748159 0.655478 -0.445758 0.894888 -0.021791 -0.885318 -0.265350 -0.381839 0.502075 0.145391 0.852515 -0.777979 -0.547145 -0.308837 -0.007564 0.730085 -0.683314 0.022998 -0.422940 0.905866 -0.087638 -0.884157 -0.458896 0.168174 0.983910 -0.060330 direction_uniform_3d_test(): direction_uniform_3d() picks a random direction vector. -0.450824 0.854706 0.257362 -0.642877 0.754140 -0.134098 -0.816178 -0.046713 0.575909 -0.005231 0.058814 -0.998255 0.069631 0.874118 0.480697 -0.015923 -0.309618 0.950728 0.827994 -0.548461 -0.116691 0.698202 -0.691164 0.186565 0.655024 -0.537941 0.530624 0.278791 -0.954202 0.108510 direction_uniform_nd_test(): direction_uniform_nd() picks a random direction vector in ND. -0.307915 0.012663 -0.223625 0.924673 0.415352 -0.004168 0.532093 -0.737796 0.964293 -0.094815 0.235162 -0.076472 0.061969 -0.204295 0.972824 0.089646 -0.380603 0.232230 -0.657538 0.607334 0.393725 -0.675322 0.017510 -0.623389 0.589150 0.334480 0.677996 0.285213 -0.843526 0.264810 -0.421446 0.201799 0.537618 -0.680180 -0.286611 -0.407647 0.615539 -0.710726 0.320036 -0.116434 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: 4 2: 10 3: 4 4: 1 5: 8 6: 3 7: 5 8: 6 9: 1 10: 5 Descending heap form: 1: 10 2: 8 3: 5 4: 6 5: 5 6: 3 7: 4 8: 1 9: 1 10: 4 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.293081 2: 0.585981 3: 0.246416 Normal vector N: 1: 0.767265 2: 0.633578 3: 0.0994138 Vector PQ: 1: -0.0766565 2: -0.0633 3: 0.995046 Vector PR: 1: -0.636733 2: 0.771085 3: 0 Dot product matrix: Col: 1 2 3 Row 1 : 1 -1.38778e-17 0 2 :-1.38778e-17 1 -6.93889e-18 3 : 0 -6.93889e-18 1 Dot product matrix: Col: 1 2 3 Row 1 : 1 -6.93889e-18 0 2 :-6.93889e-18 1 0 3 : 0 0 1 Dot product matrix: Col: 1 2 3 Row 1 : 1 0 -5.55112e-17 2 : 0 1 2.77556e-17 3 :-5.55112e-17 2.77556e-17 1 Dot product matrix: Col: 1 2 3 Row 1 : 1 -5.55112e-17 0 2 :-5.55112e-17 1 2.77556e-17 3 : 0 2.77556e-17 1 Dot product matrix: Col: 1 2 3 Row 1 : 1 1.38778e-17 0 2 : 1.38778e-17 1 0 3 : 0 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.228417 -0.174519 0.287457 -2.489168 -0.228417 -0.174519 0.412387 -0.737264 0.844761 -1.060805 0.412387 -0.737264 0.203366 0.777215 0.803380 1.314875 0.203366 0.777215 0.553479 0.742252 0.925893 0.930069 0.553479 0.742252 -0.197315 0.869237 0.891351 1.794012 -0.197315 0.869237 -0.221189 -0.830015 0.858982 -1.831232 -0.221189 -0.830015 -0.896338 0.132244 0.906041 2.995112 -0.896338 0.132244 0.287107 0.418094 0.507181 0.969050 0.287107 0.418094 -0.759958 0.401879 0.859676 2.655158 -0.759958 0.401879 -0.272175 -0.989023 1.025791 -1.839345 -0.272175 -0.989023 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.578528 0.387379 0.012105 1 1 2 0.737323 0.687399 0.417790 0 0 3 0.423000 0.645925 0.626292 0 0 4 0.457398 0.417172 0.087670 1 1 5 0.894673 0.580095 0.605751 0 0 6 0.167859 0.268285 0.180828 1 1 7 0.463662 0.654002 0.895471 0 0 8 0.651779 0.852598 0.663201 0 0 9 0.686022 0.540897 0.168697 0 0 10 0.944304 0.504340 0.192997 0 0 11 0.042178 0.423543 0.668052 0 0 12 0.529120 0.780863 0.997890 0 0 13 0.915823 0.444790 0.998199 0 0 14 0.095293 0.601368 0.522507 0 0 15 0.077309 0.195830 0.195169 1 1 16 0.735002 0.532915 0.898733 0 0 17 0.982620 0.190303 0.000625 0 0 18 0.744299 0.596340 0.982631 0 0 19 0.805129 0.890130 0.248033 0 0 20 0.502911 0.463492 0.720451 0 0 21 0.813910 0.251065 0.504411 0 0 22 0.554099 0.197704 0.906450 0 0 23 0.847824 0.676231 0.715149 0 0 24 0.262418 0.798582 0.109895 0 0 25 0.596532 0.138542 0.417208 0 0 26 0.381260 0.683514 0.574910 0 0 27 0.186414 0.736854 0.497102 0 0 28 0.874916 0.471799 0.806735 0 0 29 0.226188 0.305699 0.827817 0 0 30 0.913022 0.208184 0.980744 0 0 31 0.573480 0.278103 0.128266 1 1 32 0.818960 0.774009 0.242257 0 0 33 0.488183 0.296184 0.958752 0 0 34 0.862904 0.832421 0.520758 0 0 35 0.578719 0.384669 0.238640 0 0 36 0.567828 0.800258 0.388575 0 0 37 0.871621 0.153090 0.943907 0 0 38 0.503592 0.889136 0.567180 0 0 39 0.957756 0.621128 0.470757 0 0 40 0.794832 0.997880 0.706226 0 0 41 0.833492 0.791352 0.388481 0 0 42 0.805197 0.621925 0.734977 0 0 43 0.618088 0.132745 0.366858 0 0 44 0.609203 0.571516 0.394068 0 0 45 0.234986 0.486930 0.474932 0 0 46 0.113517 0.102356 0.718571 1 1 47 0.374446 0.161256 0.441294 1 1 48 0.464658 0.967748 0.769330 0 0 49 0.126252 0.159158 0.347205 1 1 50 0.283547 0.034814 0.895091 0 0 51 0.426972 0.409347 0.874101 0 0 52 0.084373 0.286079 0.492108 1 1 53 0.790352 0.170403 0.818841 0 0 54 0.960564 0.813054 0.563003 0 0 55 0.360296 0.757390 0.191841 0 0 56 0.142652 0.060854 0.588670 1 1 57 0.864328 0.002853 0.444230 0 0 58 0.527679 0.039133 0.356092 1 1 59 0.438597 0.415667 0.086064 1 1 60 0.232890 0.618294 0.996400 0 0 61 0.601914 0.945116 0.768967 0 0 62 0.938024 0.208544 0.284525 0 0 63 0.898340 0.168056 0.836847 0 0 64 0.200187 0.997600 0.213952 0 0 65 0.232438 0.093230 0.902463 0 0 66 0.502813 0.492649 0.655749 0 0 67 0.910387 0.167587 0.288548 0 0 68 0.831638 0.198681 0.977184 0 0 69 0.290345 0.875619 0.949203 0 0 70 0.912551 0.139885 0.905818 0 0 71 0.367373 0.273327 0.341065 1 1 72 0.344026 0.066826 0.692490 0 0 73 0.979973 0.654057 0.430947 0 0 74 0.045440 0.785991 0.221295 0 0 75 0.821812 0.313915 0.144808 0 0 76 0.407056 0.924782 0.093047 0 0 77 0.626635 0.473341 0.788877 0 0 78 0.578635 0.906178 0.093918 0 0 79 0.336435 0.217002 0.157578 1 1 80 0.158658 0.215266 0.382838 1 1 81 0.957686 0.321654 0.868590 0 0 82 0.098184 0.212387 0.329810 1 1 83 0.730720 0.189703 0.165210 0 0 84 0.295356 0.065671 0.588212 1 1 85 0.738928 0.900951 0.901386 0 0 86 0.712310 0.550787 0.156197 0 0 87 0.559868 0.628178 0.829450 0 0 88 0.093223 0.216909 0.121537 1 1 89 0.471532 0.813231 0.175893 0 0 90 0.810992 0.741723 0.342475 0 0 91 0.397220 0.768058 0.757153 0 0 92 0.570944 0.210148 0.557481 0 0 93 0.626105 0.127098 0.798572 0 0 94 0.593275 0.714638 0.110546 0 0 95 0.892990 0.240240 0.164768 0 0 96 0.367372 0.990013 0.859595 0 0 97 0.885652 0.628150 0.354967 0 0 98 0.898748 0.428615 0.960473 0 0 99 0.613095 0.464881 0.934202 0 0 100 0.882266 0.352745 0.302623 0 0 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 1.2754 3.7304 8.0906 3.9263 3.7110 76.2777 8.0811 2.3252 202.4559 6.8793 4.0156 253.3806 1.9279 6.4179 31.8056 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: 4.43856 7.94034 2: 6.1817 5.9951 3: 9.32919 6.01157 4: 4.01466 3.17689 5: 6.77481 0.285196 6: 4.18413 0.330951 7: 0.555185 1.53539 8: 1.81053 1.4083 9: 1.35771 2.44884 10: 5.75596 7.74091 11: 8.74378 0.0167507 12: 0.985264 6.47241 Rearranged array Left index = 6 Key index = 7 Right index = 8 Left half: 1: 0.985264 6.47241 2: 1.35771 2.44884 3: 4.01466 3.17689 4: 1.81053 1.4083 5: 4.18413 0.330951 6: 0.555185 1.53539 Key: 1: 4.43856 7.94034 Right half: 1: 6.77481 0.285196 2: 5.75596 7.74091 3: 8.74378 0.0167507 4: 9.32919 6.01157 5: 6.1817 5.9951 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: -3.36633 7.10732 2: -7.54475 -8.25779 3: 7.28955 4.97418 4: 7.66431 6.98288 r82vec_sort_quick_a_test(): r82vec_sort_quick_a() sorts an R82VEC using quick sort. Before rearrangement: 1: 7.3744 6.73068 2: 5.27545 1.1613 3: 4.46483 4.92329 4: 6.15907 0.437326 5: 4.46483 9.17623 6: 7.34414 6.73068 7: 6.12852 7.46987 8: 5.16786 1.28259 9: 7.40506 1.1613 10: 7.29973 7.38403 11: 6.12852 7.46987 12: 6.15907 0.0522553 Sorted array: 1: 4.46483 4.92329 2: 4.46483 9.17623 3: 5.16786 1.28259 4: 5.27545 1.1613 5: 6.12852 7.46987 6: 6.12852 7.46987 7: 6.15907 0.0522553 8: 6.15907 0.437326 9: 7.29973 7.38403 10: 7.34414 6.73068 11: 7.3744 6.73068 12: 7.40506 1.1613 r82vec_sort_heap_index_a_test(): r82vec_sort_heap_index_a() index sorts an R82VEC using heapsort. Before rearrangement: 1: 1.27741 3.26831 2: 3.26305 2.13346 3: 5.13419 5.27564 4: 2.03075 8.58112 5: 5.13419 5.40409 6: 1.45296 3.26831 7: 4.61339 2.54715 8: 5.46453 3.10172 9: 3.24917 2.13346 10: 8.97232 8.76396 11: 4.61339 2.54715 12: 2.03075 3.88582 I Index A(Index) 1 1 1.27741 3.26831 2 6 1.45296 3.26831 3 12 2.03075 3.88582 4 4 2.03075 8.58112 5 9 3.24917 2.13346 6 2 3.26305 2.13346 7 7 4.61339 2.54715 8 11 4.61339 2.54715 9 3 5.13419 5.27564 10 5 5.13419 5.40409 11 8 5.46453 3.10172 12 10 8.97232 8.76396 After rearrangement by R82VEC_PERMUTE: 1: 1.27741 3.26831 2: 1.45296 3.26831 3: 2.03075 3.88582 4: 2.03075 8.58112 5: 3.24917 2.13346 6: 3.26305 2.13346 7: 4.61339 2.54715 8: 4.61339 2.54715 9: 5.13419 5.27564 10: 5.13419 5.40409 11: 5.46453 3.10172 12: 8.97232 8.76396 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 : 5.55112e-16 1 0 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.32275 1 0 2 1.48405 1 5.55112e-17 3 1.73483 1 0 4 2.02059 1 1.11022e-16 5 2.03109 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 179.999999 -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 -1.5529 2.2407 1.6972 3.2113 2.1769 1.0140 -1.5529 2.2407 1.6972 2.7502 1.6239 -0.0829 3.1949 0.5334 1.5967 2.7502 1.6239 -0.0829 2.2631 -1.1460 2.4624 3.5353 -0.4687 0.8003 2.2631 -1.1460 2.4624 0.6759 0.8931 1.6967 2.0331 0.9230 0.5835 0.6759 0.8931 1.6967 0.1910 1.6217 2.4170 2.9169 1.4535 0.5942 0.1910 1.6217 2.4170 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.235713 0.102232 P2 = 0.039341 0.406983 P = 0.986178 0.913425 DIST = 1.070229 TEST = 2 P1 = 0.601364 0.628633 P2 = 0.583208 0.864303 P = 0.222039 0.097530 DIST = 0.652654 TEST = 3 P1 = 0.683278 0.332775 P2 = 0.822004 0.622336 P = 0.014254 0.109891 DIST = 0.705174 segment_point_near_test(): segment_point_near() computes the nearest point from a line segment to a point. TEST = 1 P1 = 0.828050 0.838349 P2 = 0.248584 0.037786 P = 0.162073 0.039874 PN = 0.248584 0.037786 DIST = 0.086537 T = 1.000000 TEST = 2 P1 = 0.511173 0.326379 P2 = 0.261141 0.149978 P = 0.976474 0.723454 PN = 0.511173 0.326379 DIST = 0.611697 T = 0.000000 TEST = 3 P1 = 0.823481 0.553080 P2 = 0.222151 0.209308 P = 0.272540 0.293135 PN = 0.296247 0.251668 DIST = 0.047766 T = 0.876781 segment_point_dist_3d_test(): segment_point_dist_3d() computes the distance between a line segment and point in 3D. TEST = 1 P1 = 0.915509 0.628959 0.536341 P2 = 0.380924 0.828219 0.196971 P = 0.005240 0.882011 0.218217 DIST = 0.380110 TEST = 2 P1 = 0.837870 0.987762 0.840797 P2 = 0.997891 0.933539 0.923618 P = 0.004018 0.440986 0.576819 DIST = 1.031483 TEST = 3 P1 = 0.841180 0.068874 0.811383 P2 = 0.343281 0.165088 0.167213 P = 0.482091 0.047588 0.654187 DIST = 0.197788 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.480722 0.792875 0.034621 P2 = 0.586774 0.671381 0.559299 P = 0.093978 0.009566 0.555682 PN = 0.586774 0.671381 0.559299 DIST = 0.825142 T = 1.000000 TEST = 2 P1 = 0.417070 0.318741 0.643778 P2 = 0.032021 0.519874 0.737205 P = 0.227796 0.310047 0.707555 PN = 0.266734 0.397270 0.680255 DIST = 0.099344 T = 0.390433 TEST = 3 P1 = 0.419098 0.845873 0.798428 P2 = 0.682591 0.302134 0.869573 P = 0.148715 0.998582 0.329824 PN = 0.419098 0.845873 0.798428 DIST = 0.562153 T = 0.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: 12 2: 7 3: 13 4: 17 5: 5 6: 16 7: 15 8: 11 9: 3 10: 3 11: 16 12: 17 13: 14 14: 5 15: 5 16: 9 17: 18 18: 19 19: 14 20: 9 Sorted array: 1: 3 2: 3 3: 5 4: 5 5: 5 6: 7 7: 9 8: 9 9: 11 10: 12 11: 13 12: 14 13: 14 14: 15 15: 16 16: 16 17: 17 18: 17 19: 18 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.216189 -0.976352 0.865117 0.501569 0.034608 -0.999401 -0.999186 0.040344 -0.953043 0.302834 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.001487 0.011620 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.266747 0.963767 Average |(XdotV)| 0.641685 V: 0.687046 -0.726614 Average |(XdotV)| 0.652000 V: -0.997133 0.075667 Average |(XdotV)| 0.628728 V: 0.621568 0.783360 Average |(XdotV)| 0.639794 V: -0.912387 0.409329 Average |(XdotV)| 0.630563 sphere01_sample_3d_test(): sphere01_sample_3d() samples the unit sphere in 3D; A few sample values: -0.428928 -0.708965 -0.559812 0.120544 0.989572 -0.078843 -0.132067 0.986618 -0.095620 -0.576881 0.757846 -0.304758 -0.329134 -0.693795 -0.640562 Now average the points, which should get a value close to zero, and closer as N_SAMPLE increases. Average: 0.022352 -0.012975 -0.006047 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.695092 -0.423079 -0.581250 Average |(XdotV)| 0.513070 V: -0.072603 0.545211 0.835149 Average |(XdotV)| 0.511946 V: -0.223137 0.559106 0.798505 Average |(XdotV)| 0.498546 V: 0.176636 0.095648 -0.979618 Average |(XdotV)| 0.497975 V: -0.828514 -0.440010 -0.346346 Average |(XdotV)| 0.503754 sphere01_sample_3d_2_test() sphere01_sample_3d_2() samples the 3D unit sphere; A few sample values: 0.579844 0.803731 0.133405 -0.769304 -0.606822 0.199843 0.138609 0.033515 -0.989780 -0.911860 -0.121160 0.392213 0.832063 -0.362099 -0.420185 Now average the points, which should get a value close to zero, and closer as N_SAMPLE increases. Average: 0.005703 0.011096 -0.009766 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.055789 -0.996501 -0.062240 Average |(XdotV)| 0.400908 V: 0.394652 0.623554 0.674856 Average |(XdotV)| 0.530219 V: 0.196728 -0.247931 -0.948593 Average |(XdotV)| 0.636740 V: 0.825401 0.537428 -0.172871 Average |(XdotV)| 0.425091 V: -0.998083 0.043685 -0.043831 Average |(XdotV)| 0.412238 sphere01_sample3_nd_test(): sphere01_sample3_nd() samples the unit sphere in ND. A few sample values: 0.364830 -0.370019 0.854391 0.239663 -0.041038 0.969989 -0.491471 -0.785837 0.375389 -0.626293 0.772343 0.106032 -0.752805 0.595640 -0.280174 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.027599 -0.008441 0.009008 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.435443 -0.763535 0.476869 Average |(XdotV)| 0.510208 V: 0.713189 -0.491703 0.499590 Average |(XdotV)| 0.501472 V: 0.336430 0.265702 -0.903447 Average |(XdotV)| 0.483977 V: 0.917948 0.199941 -0.342629 Average |(XdotV)| 0.506464 V: -0.933853 0.022496 0.356950 Average |(XdotV)| 0.502095 sphere01_sample_nd_test(): sphere01_sample_nd() samples the unit sphere in N dimensions. A few sample values: -0.947107 0.265489 0.180288 0.268230 0.594548 0.758001 -0.129436 0.136287 0.982177 -0.154284 -0.578075 -0.801265 -0.584023 0.148678 -0.798005 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.009985 0.000898 0.016200 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.776717 0.407214 0.480508 Average |(XdotV)| 0.489839 V: 0.813169 0.005884 -0.581998 Average |(XdotV)| 0.534056 V: -0.556308 -0.005890 -0.830955 Average |(XdotV)| 0.556189 V: -0.035597 -0.019187 0.999182 Average |(XdotV)| 0.622204 V: -0.931783 0.019926 0.362469 Average |(XdotV)| 0.511231 sphere01_sample2_nd_test(): sphere01_sample2_nd() samples the unit sphere in N dimensions. A few sample values: 0.660173 0.438749 0.609649 -0.921245 -0.333103 0.200871 -0.184618 0.313730 0.931391 0.843691 0.369449 -0.389478 -0.972179 0.176427 -0.154080 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.008199 0.030481 0.036735 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.830751 0.331636 0.447069 Average |(XdotV)| 0.498792 V: 0.001843 -0.046559 -0.998914 Average |(XdotV)| 0.497372 V: -0.218163 -0.470875 -0.854799 Average |(XdotV)| 0.511990 V: -0.766269 -0.642370 0.013851 Average |(XdotV)| 0.500733 V: 0.783441 0.531978 0.321278 Average |(XdotV)| 0.509032 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 1.2707 2.3152 0.2174 0.7026 -0.6775 1.2707 2.3152 1.2036 2.1938 0.2916 0.7580 -0.5834 1.2036 2.1938 0.0854 2.1203 0.8497 0.0727 -0.5222 0.0854 2.1203 2.8017 2.4738 -0.5838 0.2064 -0.7852 2.8017 2.4738 0.3255 2.0458 0.8426 0.2844 -0.4573 0.3255 2.0458 1.9306 0.5315 -0.1785 0.4744 0.8620 1.9306 0.5315 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.41421 1.70711 2 : 2 3.41421 2.70711 3 : 3 3 4 Area #1 1.000000 Area #2 1.000000 Area #3 1.000000 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.8118 2: 10.931 Distances from circumcenter to vertices: 0.764076 0.764076 0.764076 circumcenter: 1: 3.55116 2: 10.8953 Distances from circumcenter to vertices: 1.464459 1.464459 1.464459 circumcenter: 1: 21.4233 2: 10.0337 Distances from circumcenter to vertices: 19.320314 19.320314 19.320314 circumcenter: 1: 68.6953 2: 7.7545 Distances from circumcenter to vertices: 66.645119 66.645119 66.645119 M2 = 3 circumcenter: 1: 6.57022 2: 10.4747 3: 12.1599 Distances from circumcenter to vertices: 0.874471 0.874471 0.874471 circumcenter: 1: 5.77485 2: 11.2078 3: 12.2096 Distances from circumcenter to vertices: 1.850363 1.850363 1.850363 circumcenter: 1: -11.4765 2: 27.1088 3: 13.2875 Distances from circumcenter to vertices: 25.261479 25.261479 25.261479 circumcenter: 1: -70.5737 2: 81.5803 3: 16.9798 Distances from circumcenter to vertices: 105.713672 105.713672 105.713672 M2 = 4 circumcenter: 1: 4.37482 2: 9.36223 3: 5.56493 4: 11.8126 Distances from circumcenter to vertices: 0.634359 0.634359 0.634359 circumcenter: 1: 4.37103 2: 9.30323 3: 5.525 4: 11.9164 Distances from circumcenter to vertices: 0.663047 0.663047 0.663047 circumcenter: 1: 4.19468 2: 6.55758 3: 3.66677 4: 16.7479 Distances from circumcenter to vertices: 6.105434 6.105434 6.105434 circumcenter: 1: 2.55111 2: -19.0319 3: -13.6519 4: 61.7774 Distances from circumcenter to vertices: 60.712406 60.712406 60.712406 M2 = 5 circumcenter: 1: 7.58712 2: 8.03763 3: 7.46233 4: 10.4459 5: 6.39633 Distances from circumcenter to vertices: 0.735343 0.735343 0.735343 circumcenter: 1: 7.60367 2: 8.0384 3: 7.46201 4: 10.4285 5: 6.43042 Distances from circumcenter to vertices: 0.746316 0.746316 0.746316 circumcenter: 1: 10.0051 2: 8.14926 3: 7.41452 4: 7.9113 5: 11.3771 Distances from circumcenter to vertices: 6.305178 6.305178 6.305178 circumcenter: 1: 31.8227 2: 9.15653 3: 6.98309 4: -14.9586 5: 56.3192 Distances from circumcenter to vertices: 61.223589 61.223589 61.223589 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.463925 4.520367 0.157260 0.840122 0.002618 0.007896 3.390600 0.102883 0.463533 0.433584 -0.225528 2.170464 0.267335 0.056821 0.675844 1.963636 2.733408 0.538371 0.244469 0.217159 1.183675 3.213316 0.328393 0.404439 0.267168 0.258087 3.008519 0.208261 0.336173 0.455566 0.287641 2.655664 0.271996 0.218555 0.509449 1.067024 3.363327 0.283950 0.454442 0.261608 0.835180 2.317568 0.419602 0.105856 0.474542 3.490546 2.061661 0.904814 0.020554 0.074632 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.172791 2.249971 0.487137 0.083324 0.429540 1.172791 2.249971 -1.357659 2.090385 0.091993 0.030128 0.877879 -1.357659 2.090385 1.292648 3.615841 0.279468 0.538614 0.181918 1.292648 3.615841 0.568660 3.158175 0.235081 0.386058 0.378861 0.568660 3.158175 -1.575500 2.126199 0.049717 0.042066 0.908217 -1.575500 2.126199 1.374904 3.181815 0.365515 0.393938 0.240547 1.374904 3.181815 0.749314 3.647730 0.183597 0.549243 0.267159 0.749314 3.647730 1.380619 3.742852 0.272961 0.580951 0.146088 1.380619 3.742852 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 1.552913 3.265103 0.381302 0.421701 0.196997 1.552913 3.265103 1.357386 3.878422 0.246494 0.626141 0.127365 1.357386 3.878422 1.522545 2.936839 0.430951 0.312280 0.256769 1.522545 2.936839 1.358150 3.152210 0.367657 0.384070 0.248273 1.358150 3.152210 0.464212 3.721775 0.123739 0.573925 0.302336 0.464212 3.721775 1.926776 3.236876 0.448317 0.412292 0.139391 1.926776 3.236876 2.433134 2.794055 0.606513 0.264685 0.128802 2.433134 2.794055 0.916881 3.689100 0.204630 0.563033 0.232336 0.916881 3.689100 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: 19.5858 9 5: 8.58579 20 P2: Row: 1 2 Col 1: 9 21 2: 19.5858 21 3: 9.58579 11 4: 20.4142 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: 0.0943662 2: 9.24716 3: 1.31124 4: 4.30214 5: -4.47075 Norm of original vector = 11.2131 Normalized vector: 1: 0.00841569 2: 0.824673 3: 0.116938 4: 0.38367 5: -0.398707 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 LABEL 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.432002 0.168359 0.463649 2.769982 -0.432002 0.168359 0.374451 -0.214982 0.431777 -0.521178 0.374451 -0.214982 -0.705479 0.260693 0.752105 2.787629 -0.705479 0.260693 0.384727 -0.811301 0.897900 -1.127993 0.384727 -0.811301 -0.012313 -0.628990 0.629111 -1.590369 -0.012313 -0.628990 0.416742 -0.420217 0.591824 -0.789550 0.416742 -0.420217 -0.019718 -0.838092 0.838324 -1.594319 -0.019718 -0.838092 -0.943819 0.589270 1.112669 2.583464 -0.943819 0.589270 0.373830 0.311946 0.486887 0.695402 0.373830 0.311946 -0.645871 -0.951153 1.149713 -2.167316 -0.645871 -0.951153 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.8897 2.3534 1.8790 3.1402 1.2094 0.9293 0.8897 2.3534 1.8790 2.8768 -1.1433 -1.9581 3.6629 -0.3783 2.1348 2.8768 -1.1433 -1.9581 2.8648 1.7536 2.0835 3.9527 0.5493 1.0156 2.8648 1.7536 2.0835 -1.1327 1.7312 2.6393 3.3535 2.1502 0.6648 -1.1327 1.7312 2.6393 -1.1621 -0.0781 0.2924 1.2009 -3.0745 1.3249 -1.1621 -0.0781 0.2924 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. 10-Jan-2023 07:02:26