title: Most efficient way to check if a point is in or on a convex quad polygon
body: <p>I'm trying to figure out the most efficient/fast way to add a large number of convex quads (four given x,y points) into an array/list and then to check against those quads if a point is within or on the border of those quads. </p>
  
  <p>I originally tried using ray casting but thought that it was a little overkill since I know that all my polygons will be quads and that they are also all convex.</p>
  
  <p>currently, I am splitting each quad into two triangles that share an edge and then checking if the point is on or in each of those two triangles using their areas.</p>
  
  <p>for example
  Triangle ABC and test point P.
  if (areaPAB + areaPAC + areaPBC == areaABC) { return true; }</p>
  
  <p>This seems like it may run a little slow since I need to calculate the area of 4 different triangles to run the check and if the first triangle of the quad returns false, I have to get 4 more areas. (I include a bit of an epsilon in the check to make up for floating point errors)</p>
  
  <p>I'm hoping that there is an even faster way that might involve a single check of a point against a quad rather than splitting it into two triangles.</p>
  
  <p>I've attempted to reduce the number of checks by putting the polygon's into an array[,]. When adding a polygon, it checks the minimum and maximum x and y values and then using those, places the same poly into the proper array positions. When checking a point against the available polygons, it retrieves the proper list from the array of lists.</p>
  
  <p>I've been searching through similar questions and I think what I'm using now may be the fastest way to figure out if a point is in a triangle, but I'm hoping that there's a better method to test against a quad that is always convex. Every polygon test I've looked up seems to be testing against a polygon that has many sides or is an irregular shape. </p>
  
  <p>Thanks for taking the time to read my long winded question to what's prolly a simple problem.</p>