var list = [], i, P, n, N, A, B, C, D, theta, prevN, totalN = Vector.Zero(3); for (i = 0; i < points.length; i++) { 
var np = points.length, list = [], i, P, n, N, A, B, C, D, theta, prevN, totalN = Vector.Zero(3); for (i = 0; i < np; i++) { 
Plane.fromPoints = function(points) {  var list = [], i, P, n, N, A, B, C, D, theta, prevN, totalN = Vector.Zero(3);  for (i = 0; i < points.length; i++) {    P = Vector.create(points[i]).to3D();    if (P === null) { return null; }    list.push(P);    n = list.length;    if (n > 2) {      // Compute plane normal for the latest three points      A = list[n-1].elements; B = list[n-2].elements; C = list[n-3].elements;      N = Vector.create([        (A[1] - B[1]) * (C[2] - B[2]) - (A[2] - B[2]) * (C[1] - B[1]),        (A[2] - B[2]) * (C[0] - B[0]) - (A[0] - B[0]) * (C[2] - B[2]),        (A[0] - B[0]) * (C[1] - B[1]) - (A[1] - B[1]) * (C[0] - B[0])      ]).toUnitVector();      if (n > 3) {        // If the latest normal is not (anti)parallel to the previous one, we've strayed off the plane.        // This might be a slightly long-winded way of doing things, but we need the sum of all the normals        // to find which way the plane normal should point so that the points form an anticlockwise list.        theta = N.angleFrom(prevN);        if (theta !== null) {          if (!(Math.abs(theta) <= Sylvester.precision || Math.abs(theta - Math.PI) <= Sylvester.precision)) { return null; }        }      }      totalN = totalN.add(N);      prevN = N;    }  }  // We need to add in the normals at the start and end points, which the above misses out  A = list[1].elements; B = list[0].elements; C = list[n-1].elements; D = list[n-2].elements;  totalN = totalN.add(Vector.create([    (A[1] - B[1]) * (C[2] - B[2]) - (A[2] - B[2]) * (C[1] - B[1]),    (A[2] - B[2]) * (C[0] - B[0]) - (A[0] - B[0]) * (C[2] - B[2]),    (A[0] - B[0]) * (C[1] - B[1]) - (A[1] - B[1]) * (C[0] - B[0])  ]).toUnitVector()).add(Vector.create([    (B[1] - C[1]) * (D[2] - C[2]) - (B[2] - C[2]) * (D[1] - C[1]),    (B[2] - C[2]) * (D[0] - C[0]) - (B[0] - C[0]) * (D[2] - C[2]),    (B[0] - C[0]) * (D[1] - C[1]) - (B[1] - C[1]) * (D[0] - C[0])  ]).toUnitVector());  return Plane.create(list[0], totalN);};
3123	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/3123/5bb35ddb3516d7e68f3747d86540ffaa68de3fe3/plane.js/buggy/src/plane.js