25-Sep-2024 08:50:17 cg_lab_triangles_test(): MATLAB/Octave version 6.4.0 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.295557,0.647493) P1 = (-1.2217,-0.278257) P2 = (0.0751399,-0.873299) Direction vector L.DV = (1.296840 -0.595042) Normal vector L.NV = [0.417035 0.908890] Distance from P to line (P1,P2) = 1.22764 P = (1.11968,-0.65302) P1 = (0.114984,0.672999) P2 = (-3.0026,-0.613038) Direction vector L.DV = (-3.117580 -1.286037) Normal vector L.NV = [0.381340 -0.924435] Distance from P to line (P1,P2) = 1.60895 P = (0.299135,-0.845795) P1 = (1.19992,-1.76437) P2 = (0.655067,-0.385905) Direction vector L.DV = (-0.544850 1.378462) Normal vector L.NV = [-0.929989 -0.367587] Distance from P to line (P1,P2) = 0.500063 P = (-0.553756,1.35205) P1 = (2.39877,0.0427591) P2 = (-0.0713032,0.247155) Direction vector L.DV = (-2.470076 0.204396) Normal vector L.NV = [-0.082467 -0.996594] Distance from P to line (P1,P2) = -1.06134 P = (-0.540775,-0.274815) P1 = (-1.34572,-0.033021) P2 = (-0.890987,-0.72935) Direction vector L.DV = (0.454735 -0.696329) Normal vector L.NV = [0.837276 0.546780] Distance from P to line (P1,P2) = 0.541755 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 = (1.53231,-0.690665) P2 = (0.729511,-0.516566) P3 = (-3.13493,0.337593) Orientation test value = -0.015735 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 4.779172 Edge2 = p3-p2, length = 3.957713 Edge3 = p1-p3, length = 0.821464 The point (-1.07634,0.365849) is OUTSIDE the triangle The point (0.073645,-0.355981) is OUTSIDE the triangle The point (-1.35275,-1.44285) is OUTSIDE the triangle The point (0.955727,-0.505937) is OUTSIDE the triangle The point (-1.83028,1.66548) is OUTSIDE the triangle P1 = (-0.47427,0.103254) P2 = (1.4252,1.26786) P3 = (1.2631,-0.748435) Orientation test value = -1.634197 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 1.934893 Edge2 = p3-p2, length = 2.022800 Edge3 = p1-p3, length = 2.228068 The point (-0.810639,0.947731) is OUTSIDE the triangle The point (0.889013,0.987418) is OUTSIDE the triangle The point (-1.2702,-1.69138) is OUTSIDE the triangle The point (1.36733,-0.525263) is OUTSIDE the triangle The point (-0.353995,-0.615177) is OUTSIDE the triangle P1 = (-0.851142,0.300135) P2 = (-0.994385,0.313417) P3 = (-1.0856,0.278073) Orientation test value = 0.043614 The triangle is counter-clockwise oriented. Edge1 = p2-p1, length = 0.143857 Edge2 = p3-p2, length = 0.097824 Edge3 = p1-p3, length = 0.235495 The point (-0.823281,0.822345) is OUTSIDE the triangle The point (0.651281,0.320434) is OUTSIDE the triangle The point (0.717152,0.115793) is OUTSIDE the triangle The point (-1.49348,-0.0996684) is OUTSIDE the triangle The point (1.40719,-1.24295) is OUTSIDE the triangle P1 = (-1.39828,-0.324627) P2 = (-1.20052,-0.891953) P3 = (-0.272345,-0.187144) Orientation test value = 1.108448 The triangle is counter-clockwise oriented. Edge1 = p2-p1, length = 0.600807 Edge2 = p3-p2, length = 1.165448 Edge3 = p1-p3, length = 1.134300 The point (1.55331,0.10398) is OUTSIDE the triangle The point (-0.378985,1.0499) is OUTSIDE the triangle The point (-0.233757,-0.248319) is OUTSIDE the triangle The point (0.3745,0.498987) is OUTSIDE the triangle The point (-1.00979,0.232095) is OUTSIDE the triangle P1 = (-1.97823,1.90776) P2 = (1.94292,-0.986615) P3 = (-0.27476,-1.98488) Orientation test value = -2.120192 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 4.249058 Edge2 = p3-p2, length = 2.432004 Edge3 = p1-p3, length = 4.873691 The point (-0.925243,0.0722893) is OUTSIDE the triangle The point (-0.69918,0.247877) is OUTSIDE the triangle The point (1.51711,-0.781047) is OUTSIDE the triangle The point (0.933915,-0.338915) is OUTSIDE the triangle The point (0.302702,0.926513) 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 = 339 % = 33.9000 N2 = 341 % = 34.1000 N3 = 320 % = 32.0000 N = 1000 % = 100.0000 Use good sampling scheme. N1 = 335 % = 33.5000 N2 = 333 % = 33.3000 N3 = 332 % = 33.2000 N = 1000 % = 100.0000 PROGRAM_05 - The Eyeball Test on Sampling Define a triangle T: N1 = 306 % = 30.6000 N2 = 330 % = 33.0000 N3 = 364 % = 36.4000 N = 1000 % = 100.0000 Graphics saved as "program_05_bad.png" N1 = 312 % = 31.2000 N2 = 334 % = 33.4000 N3 = 354 % = 35.4000 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.160727 Exact integral = 0.166667 Absolute error = 0.005940 Relative error = 0.035640 PROGRAM_07 - Monte Carlo estimate of Integral x^p y^q over an arbitrary triangle. Define a triangle T: Estimated integral = 586.469445 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:50:17