Graphics Tutorial Solution 02
Graphics Tutorial Solution 02
We could take (P2-P1) = [5,-10,5], or simply [1,-2,1] and (P3-P1) = [15,0,5] or just [3,0,1], and take the cross product: i 1 3 j -2 0 k 1 = [-2,2,6] 1
So a simple normal vector is [-1,1,3]. 2. P-P1 = [x-10,y-20,z-5] n.(P-P1) = -(x-10) + (y-20) + 3(z-5) = -x +y +3z -25 = 0 verify using P2 P-P2 = [x-15,y-10,z-10] n.(P-P2) = -(x-15) + (y-10) + 3(z-10) = -x + y + 3z -25 = 0. 3. TYPE Vector = Array [0..2] of REAL; PROCEDURE PlaneEquation(P1,P2,P3: Vector;VAR a,b,c,d: REAL); VAR d1,d2: Vector; (* Find two vectors parallel to the plane *) FOR j:0 .. 2 d1[j] = P2[j]-P1[j]; d2[j] = P3[j]-P1[j]; END FOR (* Find the normal vector to the plane n=[a,b,c]=d1Xd2 *) a := d1[1]*d2[2] - d1[2]*d2[1] b := d1[2]*d2[0] - d1[0]*d2[2] c := d1[0]*d2[1] - d1[1]*d2[0] (* take the dot product with P-P1 *) d := -(a*P1[0]+b*P1[1]+c*P1[2]) END PlaneEquation; 4. Take the vector from say P1 to P4, ie P4-P1 = [20,0,5], and take the dot product of this with the normal [-1,1,3], which gives -5. Since the result is negative the angle between these two vectors is bigger than 90, and so the normal vector must be the outward surface normal. The inner surface normal is therefore [1,-1,-3] P = P1 + d1 + d2 P = P1 + (P2 - P1) + (P3 - P1) the parametric plane equation P.n = P1.n + (P2-P1).n + (P3 - P1).n since n is the normal vector, and (P2-P1) is parallel to the plane by definition (P2-P1).n =0. Similarly (P3-P1).n=0 and so: P.n = P1.n or n.(P-P1) = 0 5.
DOC Interactive Computer Graphics Tutorial 2 page 2