title: Python code to check if a point is inside or outside a Cuboid
body: <p>for a particular purpose, I have to find whether a given point is inside a cuboid or not. With help from this link ( <a href="https://math.stackexchange.com/questions/1472049/check-if-a-point-is-inside-a-rectangular-shaped-area-3d">https://math.stackexchange.com/questions/1472049/check-if-a-point-is-inside-a-rectangular-shaped-area-3d</a> ). I have written a prototype code which can check if the points are inside a cuboid or not. </p>
  
  <p>( for the mathematics of this, please refer this link.)</p>
  
  <p>for this, we should define the 3 mutually perpendicular axes of the cuboid. </p>
  
  <p>Here is my code</p>
  
  <pre><code>import numpy
  
  def dot(v1, v2):
      return numpy.sqrt(numpy.square(numpy.dot(v1, v2)))
  
  def InCuboid ( plist,pnt):
      c1 = plist[0]
      c2 = plist[1]
      c3 = plist[2]
      c4 = plist[3]
      u1 = numpy.subtract(c1, c2)
      u2 = numpy.subtract(c1, c3)
      u3 = numpy.subtract(c1, c4)
      t = pnt
      if dot(u1, c1) &lt;= dot(u1, t) &lt;= dot(u1, c2) and dot(u2, c1) &lt;= dot(u2, t) &lt;= dot(u2, c3) and dot(u3, c1) &lt;= dot(u3,t) &lt;= dot(u3, c4):
          return "In"
      else :
          return "Out"
  
  c1 = [-100,1,-10]
  c2 = [-50,1,-10]
  c3 = [-100,3.0,-10]
  c4 = [-100,1,10]
  
  plst = [c1,c2,c3,c4]
  mlst = [[0,0,0],[100,1000,1000],[-80,2,0],[-80,2,1]]
  
  for p in mlst :
      print InCuboid(plst,p)
  
  
  </code></pre>
  
  <p>If the common vertex is at the origin, this is working fine. But if it's any general point, the code is not working.
  can anyone help me to find the problem? </p>