Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 21, 2005, 6:07:23 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: implemented a point in triangle function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r4925 r4929  
    389389
    390390
     391sTriangleExt* QuadtreeNode::getTriangle(const Vector& position)
     392{
     393
     394}
     395
     396bool QuadtreeNode::pointInTriangle(const Vector&p, const Vector& a, const Vector& b, const Vector& c)
     397{
     398  if( this->sameSide(p, a, b, c) && this->sameSide(p, b, a, c) && sameSide(p, c, a, b))
     399    return true;
     400  return false;
     401  /*
     402  function PointInTriangle(p, a,b,c)
     403  if SameSide(p,a, b,c) and SameSide(p,b, a,c)
     404  and SameSide(p,c, a,b) then return true
     405  else return false
     406  */
     407}
     408
     409
     410bool QuadtreeNode::sameSide(const Vector& p1, const Vector&p2, const Vector& a, const Vector& b)
     411{
     412  Vector cp1 = (b - a).cross(p1 - a);
     413  Vector cp2 = (b - a).cross(p2 - a);
     414
     415  if( unlikely(cp1.dot(cp2) >= 0)) return true;
     416  return false;
     417}
     418
     419
    391420/**
    392421 *  draws all the debug quadtree squares
Note: See TracChangeset for help on using the changeset viewer.