Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Triangle.cpp
1 #include "Triangle.hh"
2 
4  const HomgPoint2D &b,
5  const HomgPoint2D &c)
6 : a_(a), b_(b), c_(c) {
7  // nothing to do here...
8 }
9 
10 
12  double &lambdaA,
13  double &lambdaB,
14  double &lambdaC) {
15  const double div = (a_[0] - c_[0]) * (b_[1] - c_[1])
16  - (b_[0] - c_[0]) * (a_[1] - c_[1]);
17 
18  lambdaA = ( (b_[1] - c_[1]) * (p[0] - c_[0])
19  + (c_[0] - b_[0]) * (p[1] - c_[1]))
20  / div;
21  lambdaB = ( (c_[1] - a_[1]) * (p[0] - c_[0])
22  + (a_[0] - c_[0]) * (p[1] - c_[1]))
23  / div;
24  lambdaC = 1.0 - lambdaA - lambdaB;
25 }
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
Triangle(const HomgPoint2D &a, const HomgPoint2D &b, const HomgPoint2D &c)
Constructor.
Definition: Triangle.cpp:3
void GetBarycentricCoords(const HomgPoint2D &p, double &lambdaA, double &lambdaB, double &lambdaC)
Returns the barycentric coordinates of the given point with respect to this triangle.
Definition: Triangle.cpp:11