Home License -- for personal use only. Not for government, academic, research, commercial, or other organizational use. 25-Sep-2024 08:24:17 cg_lab_triangles_test(): MATLAB/Octave version 9.11.0.2358333 (R2021b) Update 7 Test cg_lab_triangles() point_line_distance_signed_test(): Compute signed distance between a point P and a line L defined by points P1 and P2. P = (0.537667,1.83389) P1 = (-2.25885,0.862173) P2 = (0.318765,-1.30769) Direction vector L.DV = (2.577612 -2.169862) Normal vector L.NV = [0.644004 0.765022] Distance from P to line (P1,P2) = 2.544347e+00 P = (-0.433592,0.342624) P1 = (3.5784,2.76944) P2 = (-1.34989,3.03492) Direction vector L.DV = (-4.928284 0.265486) Normal vector L.NV = [-0.053792 -0.998552] Distance from P to line (P1,P2) = 2.639112e+00 P = (0.725404,-0.0630549) P1 = (0.714743,-0.204966) P2 = (-0.124144,1.4897) Direction vector L.DV = (-0.838887 1.694664) Normal vector L.NV = [-0.896206 -0.443637] Distance from P to line (P1,P2) = -7.251185e-02 P = (1.40903,1.41719) P1 = (0.671497,-1.20749) P2 = (0.717239,1.63024) Direction vector L.DV = (0.045742 2.837722) Normal vector L.NV = [-0.999870 0.016117] Distance from P to line (P1,P2) = -6.951396e-01 P = (0.488894,1.03469) P1 = (0.726885,-0.303441) P2 = (0.293871,-0.787283) Direction vector L.DV = (-0.433014 -0.483842) Normal vector L.NV = [0.745163 -0.666883] Distance from P to line (P1,P2) = -1.069720e+00 point_triangle_orientation_test(): Define a point P, Define a triangle T with vertices P1, P2, P3. Determine the orientation of the point with respect to T. P1 = (0.888396,-1.14707) P2 = (-1.06887,-0.809499) P3 = (-2.94428,1.43838) Orientation test value = -1.896426 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 4.623201 Edge2 = p3-p2, length = 2.927480 Edge3 = p1-p3, length = 1.986163 The point (0.325191,-0.754928) is OUTSIDE the triangle The point (1.3703,-1.71152) is OUTSIDE the triangle The point (-0.102242,-0.241447) is OUTSIDE the triangle The point (0.319207,0.312859) is OUTSIDE the triangle The point (-0.86488,-0.0300513) is OUTSIDE the triangle P1 = (-0.164879,0.627707) P2 = (1.09327,1.10927) P3 = (-0.863653,0.0773591) Orientation test value = -0.264195 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 0.889476 Edge2 = p3-p2, length = 2.212324 Edge3 = p1-p3, length = 1.347158 The point (-1.21412,-1.1135) is OUTSIDE the triangle The point (-0.00684933,1.53263) is OUTSIDE the triangle The point (-0.769666,0.371379) is OUTSIDE the triangle The point (-0.225584,1.11736) is OUTSIDE the triangle The point (-1.08906,0.0325575) is OUTSIDE the triangle P1 = (0.552527,1.10061) P2 = (1.54421,0.0859311) P3 = (-1.49159,-0.742302) Orientation test value = -2.749995 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 2.752225 Edge2 = p3-p2, length = 3.146755 Edge3 = p1-p3, length = 1.418807 The point (-1.06158,2.35046) is OUTSIDE the triangle The point (-0.615602,0.748077) is OUTSIDE the triangle The point (-0.192419,0.88861) is OUTSIDE the triangle The point (-0.764849,-1.40227) is OUTSIDE the triangle The point (-1.42238,0.488194) is OUTSIDE the triangle P1 = (-0.177375,-0.196053) P2 = (1.41931,0.291584) P3 = (0.197811,1.5877) Orientation test value = 1.596378 The triangle is counter-clockwise oriented. Edge1 = p2-p1, length = 1.669489 Edge2 = p3-p2, length = 1.781003 Edge3 = p1-p3, length = 1.822783 The point (-0.804466,0.696624) is OUTSIDE the triangle The point (0.835088,-0.243715) is OUTSIDE the triangle The point (0.21567,-1.16584) is OUTSIDE the triangle The point (-1.14795,0.104875) is OUTSIDE the triangle The point (0.722254,2.58549) is OUTSIDE the triangle P1 = (-0.666891,0.187331) P2 = (-0.0824944,-1.93302) P3 = (-0.438966,-1.79468) Orientation test value = -0.306899 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 1.995072 Edge2 = p3-p2, length = 0.382376 Edge3 = p1-p3, length = 2.199414 The point (0.840376,-0.888032) is OUTSIDE the triangle The point (0.100093,-0.544529) is OUTSIDE the triangle The point (0.303521,-0.600327) is OUTSIDE the triangle The point (0.489965,0.739363) is OUTSIDE the triangle The point (1.71189,-0.194124) is OUTSIDE the triangle barycentric_test Define a triangle T: Triangle area = 7.500000 Now we compute barycentric coordinates for points. PBC = 4.0000 XI1 = 0.5333 APC = -3.0000 XI2 = -0.4000 APB = 6.5000 XI3 = 0.8667 Sum = 7.5000 Sum = 1.0000 program_04(): Uniform Sampling Define a triangle T: Use bad sampling scheme. N1 = 321 % = 32.1000 N2 = 338 % = 33.8000 N3 = 341 % = 34.1000 N = 1000 % = 100.0000 Use good sampling scheme. N1 = 336 % = 33.6000 N2 = 346 % = 34.6000 N3 = 318 % = 31.8000 N = 1000 % = 100.0000 PROGRAM_05 - The Eyeball Test on Sampling Define a triangle T: N1 = 310 % = 31.0000 N2 = 354 % = 35.4000 N3 = 336 % = 33.6000 N = 1000 % = 100.0000 Graphics saved as "program_05_bad.png" N1 = 311 % = 31.1000 N2 = 340 % = 34.0000 N3 = 349 % = 34.9000 N = 1000 % = 100.0000 Graphics saved as "program_05_good.png" PROGRAM_06(): Monte Carlo estimate of Integral x^p y^q over the unit triangle. Estimated integral = 0.165894 Exact integral = 0.166667 Absolute error = 0.000773 Relative error = 0.004638 PROGRAM_07 - Monte Carlo estimate of Integral x^p y^q over an arbitrary triangle. Define a triangle T: Estimated integral = 608.160828 PROGRAM_08 - Quadrature rule estimates of Integral x^p y^q over the unit triangle. Rule #1 Estimated integral = 0.006173 Exact integral = 0.005556 Absolute error = 0.000617 Relative error = 0.111107 Rule #2 Estimated integral = 0.004444 Exact integral = 0.005556 Absolute error = 0.001111 Relative error = 0.199998 Rule #3 Estimated integral = 0.005556 Exact integral = 0.005556 Absolute error = 0.000000 Relative error = 0.000001 PROGRAM_09 - Quadrature rule estimates of Integral x^p y^q over an arbitrary triangle. Define a triangle T: Rule #1 Estimated integral = 370.523061 Rule #2 Estimated integral = 593.111515 Rule #3 Estimated integral = 601.213992 cg_lab_triangles_test(): Normal end of execution. 25-Sep-2024 08:24:24