14-May-2025 10:19:13 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.291475,-1.85137) P1 = (-1.43708,0.110404) P2 = (1.39427,-0.417235) Direction vector L.DV = (2.831347 -0.527639) Normal vector L.NV = [0.183202 0.983075] Distance from P to line (P1,P2) = -1.71869 P = (1.74873,-1.6665) P1 = (0.510787,-0.717099) P2 = (0.128138,-0.044405) Direction vector L.DV = (-0.382649 0.672694) Normal vector L.NV = [-0.869214 -0.494435] Distance from P to line (P1,P2) = -0.606623 P = (-0.763431,0.0484374) P1 = (0.326762,0.124827) P2 = (0.394122,1.23557) Direction vector L.DV = (0.067360 1.110739) Normal vector L.NV = [-0.998166 0.060533] Distance from P to line (P1,P2) = 1.08357 P = (1.11936,0.15717) P1 = (0.400741,1.66955) P2 = (1.37904,0.121411) Direction vector L.DV = (0.978297 -1.548139) Normal vector L.NV = [0.845359 0.534198] Distance from P to line (P1,P2) = -0.20042 P = (-0.492229,1.26183) P1 = (-1.66476,0.237538) P2 = (0.814512,-2.67668) Direction vector L.DV = (2.479268 -2.914218) Normal vector L.NV = [0.761658 0.647980] Distance from P to line (P1,P2) = 1.55679 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.883142,0.357448) P2 = (-1.22985,-0.326944) P3 = (-1.51704,0.265194) Orientation test value = -0.523784 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 0.640572 Edge2 = p3-p2, length = 0.658107 Edge3 = p1-p3, length = 0.767200 The point (-2.51299,1.0203) is OUTSIDE the triangle The point (0.494068,0.951089) is OUTSIDE the triangle The point (-0.705598,0.81476) is OUTSIDE the triangle The point (0.789505,0.920948) is OUTSIDE the triangle The point (-2.09483,0.319324) is OUTSIDE the triangle P1 = (-0.530719,1.12238) P2 = (0.103005,-0.90803) P3 = (-0.664744,1.30567) Orientation test value = -0.073329 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 0.227065 Edge2 = p3-p2, length = 2.343052 Edge3 = p1-p3, length = 2.127006 The point (0.763583,0.478767) is OUTSIDE the triangle The point (0.0262261,-1.93909) is OUTSIDE the triangle The point (-2.45305,0.543117) is OUTSIDE the triangle The point (-1.38967,-0.583801) is OUTSIDE the triangle The point (-0.570401,-1.57601) is OUTSIDE the triangle P1 = (0.723427,-0.795357) P2 = (-2.48426,-1.64927) P3 = (0.890708,1.32893) Orientation test value = -2.009759 The triangle is clockwise oriented. Correct the orientation! Edge1 = p2-p1, length = 2.130860 Edge2 = p3-p2, length = 4.501115 Edge3 = p1-p3, length = 3.319399 The point (-0.494606,0.237651) is OUTSIDE the triangle The point (2.62717,-1.44452) is OUTSIDE the triangle The point (0.709697,-1.24283) is OUTSIDE the triangle The point (0.903936,-0.51104) is OUTSIDE the triangle The point (1.74096,0.36306) is OUTSIDE the triangle P1 = (-0.201952,-0.159998) P2 = (-1.23988,-0.134627) P3 = (0.318255,-0.496515) Orientation test value = 0.323704 The triangle is counter-clockwise oriented. Edge1 = p2-p1, length = 1.038242 Edge2 = p3-p2, length = 1.599612 Edge3 = p1-p3, length = 0.619563 The point (0.135292,-0.330711) is OUTSIDE the triangle The point (0.0418361,0.122404) is OUTSIDE the triangle The point (-1.3756,-1.33598) is OUTSIDE the triangle The point (0.219169,0.947533) is OUTSIDE the triangle The point (-1.16078,-1.68632) is OUTSIDE the triangle P1 = (-1.17884,2.16203) P2 = (0.39873,-2.84836) P3 = (-0.215447,1.05692) Orientation test value = 0.587026 The triangle is counter-clockwise oriented. Edge1 = p2-p1, length = 5.252873 Edge2 = p3-p2, length = 3.953273 Edge3 = p1-p3, length = 1.466082 The point (-1.48801,-0.586403) is OUTSIDE the triangle The point (-2.47052,-1.18023) is OUTSIDE the triangle The point (-0.00696907,2.43541) is OUTSIDE the triangle The point (0.368059,1.1779) is OUTSIDE the triangle The point (0.610655,0.027299) 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 = 349 % = 34.9000 N2 = 327 % = 32.7000 N3 = 324 % = 32.4000 N = 1000 % = 100.0000 Use good sampling scheme. N1 = 337 % = 33.7000 N2 = 327 % = 32.7000 N3 = 336 % = 33.6000 N = 1000 % = 100.0000 PROGRAM_05 - The Eyeball Test on Sampling Define a triangle T: N1 = 334 % = 33.4000 N2 = 330 % = 33.0000 N3 = 336 % = 33.6000 N = 1000 % = 100.0000 Graphics saved as "program_05_bad.png" N1 = 311 % = 31.1000 N2 = 339 % = 33.9000 N3 = 350 % = 35.0000 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.172811 Exact integral = 0.166667 Absolute error = 0.006145 Relative error = 0.036868 PROGRAM_07 - Monte Carlo estimate of Integral x^p y^q over an arbitrary triangle. Define a triangle T: Estimated integral = 621.358345 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. 14-May-2025 10:19:14