title: How to determine if 4 points are on same plane
body: <p>I'm choosing 4 points from an image outputted by Kinect therefor each point has its <code>(x, y, z)</code> coordinates.</p>
  
  <p>My objective is to determine whether the 4 points fall on the same plane.</p>
  
  <p>This is my function:</p>
  
  <pre><code>    public bool isValidPlane()
      {
          for (int i = 0; i &lt; edgesPoints.Length; i++)
          {
              double absPlaneEquation = Math.Abs(distance -
                  (normal.X * edgesPoints[i].X + normal.Y * edgesPoints[i].Y + normal.Z * edgesPoints[i].Z));
              if (absPlaneEquation &gt; 1500) /* 1500 is a tolerance error*/
              {
                  return false;
              }
          }
          return true;
      }
  </code></pre>
  
  <p>The <code>normal</code> is also the normal (a cross product of 2 vectors on the plane, which been previously calculated from 3 out of 4 of the chosen points) to the plane and it's normalized:</p>
  
  <pre><code>    private void calcPlaneNormalVector()
      {
          if (lastEdgeNumber &lt; 3)
          {
              return;
          }
          Vector3D vec1 = new Vector3D(edgesPoints[0], edgesPoints[1]);
          Vector3D vec2 = new Vector3D(edgesPoints[0], edgesPoints[2]);
          vec2 = vec1.crossProduct(vec2);
          double lengthNormal = Math.Sqrt(Math.Pow(vec2.X, 2) + Math.Pow(vec2.Y, 2) + Math.Pow(vec2.Z, 2));
  //normalizing:
          normal = new Vector3D((vec2.X / lengthNormal), (vec2.Y / lengthNormal), (vec2.Z / lengthNormal));
          distance = (-1) * (edgesPoints[0].X * normal.X + edgesPoints[0].Y * normal.Y + edgesPoints[0].Z + normal.Z);
      }
  </code></pre>
  
  <p><code>Vector3D</code> is a class to represent a vector:</p>
  
  <pre><code>public  class Vector3D
  {
      private double x, y, z;
  
      public Vector3D(Point3D p1, Point3D p2)
      {
          x = p2.X - p1.X;
          y = p2.Y - p1.Y;
          z = p2.Z - p1.Z;
      }
      public Vector3D(double a = 0, double b = 0, double c = 0)
      {
          x = a;
          y = b;
          z = c;
      }
  
      &lt;get properties for x, y, z &gt;
  
      public Vector3D crossProduct(Vector3D u)
      {
          double tmpX = 0, tmpY = 0, tmpZ = 0;
          tmpX = y * u.Z - z * u.Y;
          tmpY = z * u.X - x * u.Z;
          tmpZ = x * u.Y - y * u.X;
          return new Vector3D(tmpX, tmpY, tmpZ);
      }
      public double dotProduct(Vector3D u)
      {
          return x * u.X + y * u.Y + z * u.Z;
      }
  }
  </code></pre>
  
  <p>i always get <code>1300 &lt;= absPlaneEquation &lt;= 1400</code> even when the 4 points are chosen so that they won't be on the same plane.</p>
  
  <p>What is the best way to detect that the 4 points refer to the same plane?</p>