|
@@ -139,167 +139,38 @@ std::pair < QPoint *, QPoint * >StrengthLine::interpolateToEdge (int imgWidth, i
|
|
|
float
|
|
|
b = std::get < 1 > (eq);
|
|
|
|
|
|
- if(a>0)
|
|
|
+ QPoint *p1 = new QPoint(0, b);
|
|
|
+ QPoint *p2 = new QPoint(imgWidth, imgWidth * a + b);
|
|
|
+
|
|
|
+ // Si le point de gauche est trop bas
|
|
|
+ if(b < 0)
|
|
|
+ {
|
|
|
+ p1->setX(-b/a);
|
|
|
+ p1->setY(0);
|
|
|
+ }
|
|
|
+ // Si le point de gauche est trop haut
|
|
|
+ if(b > imgHeight)
|
|
|
{
|
|
|
- if(b<0)
|
|
|
- {
|
|
|
- if((a*imgWidth+b) > imgHeight)
|
|
|
- {
|
|
|
- // |------------------------------------------|
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // |------------------------------------------|
|
|
|
-
|
|
|
- return std::make_pair (new QPoint (-1*(b/a), 0),
|
|
|
- new QPoint ((imgHeight-b)/a, imgHeight));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // |------------------------------------------|
|
|
|
- // | *** |
|
|
|
- // | *** |
|
|
|
- // | *** |
|
|
|
- // | *** |
|
|
|
- // | ***|
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // |------------------------------------------|
|
|
|
-
|
|
|
- return std::make_pair (new QPoint (-1*(b/a), 0),
|
|
|
- new QPoint (imgWidth, a * imgWidth + b));
|
|
|
- }
|
|
|
- }
|
|
|
- else // a>0 and b>0
|
|
|
- {
|
|
|
-
|
|
|
- if((a*imgWidth+b) > imgHeight)
|
|
|
- {
|
|
|
- // |------------------------------------------|
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // |* |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // |------------------------------------------|
|
|
|
-
|
|
|
- return std::make_pair (new QPoint (0, b),
|
|
|
- new QPoint ((imgHeight -b )/a, imgHeight));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // |------------------------------------------|
|
|
|
- // | |
|
|
|
- // |******** |
|
|
|
- // | ******** |
|
|
|
- // | ******** |
|
|
|
- // | ******** |
|
|
|
- // | ******** |
|
|
|
- // | **|
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // |------------------------------------------|
|
|
|
-
|
|
|
- return std::make_pair (new QPoint (0, b),
|
|
|
- new QPoint (imgWidth, a*imgWidth+b));
|
|
|
- }
|
|
|
- }
|
|
|
+ p1->setX((imgHeight-b)/a);
|
|
|
+ p1->setY(imgHeight);
|
|
|
}
|
|
|
- else // a<0
|
|
|
+ // Si le point de droite est trop bas
|
|
|
+ if((imgWidth * a + b) < 0)
|
|
|
{
|
|
|
- if((a*imgWidth+b)>0)
|
|
|
- {
|
|
|
- if(b > imgHeight)
|
|
|
- {
|
|
|
- // |------------------------------------------|
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // |------------------------------------------|
|
|
|
-
|
|
|
- return std::make_pair (new QPoint ((imgHeight-b)/a, imgHeight),
|
|
|
- new QPoint (imgWidth, a*imgWidth+b));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // |------------------------------------------|
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // | **|
|
|
|
- // | ******** |
|
|
|
- // | ******** |
|
|
|
- // | ******** |
|
|
|
- // | ******** |
|
|
|
- // |******** |
|
|
|
- // | |
|
|
|
- // |------------------------------------------|
|
|
|
-
|
|
|
- return std::make_pair (new QPoint (0, b),
|
|
|
- new QPoint (imgWidth, a * imgWidth + b));
|
|
|
- }
|
|
|
- }
|
|
|
- else // a>0 and (a*imgWidth+b) < 0
|
|
|
- {
|
|
|
-
|
|
|
- if(b > imgHeight)
|
|
|
- {
|
|
|
- // |------------------------------------------|
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // |------------------------------------------|
|
|
|
-
|
|
|
- return std::make_pair (new QPoint (-1*(b/a), 0),
|
|
|
- new QPoint ((imgHeight-b)/a, imgHeight));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // |------------------------------------------|
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // | * |
|
|
|
- // |* |
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // | |
|
|
|
- // |------------------------------------------|
|
|
|
-
|
|
|
- return std::make_pair (new QPoint (0, b),
|
|
|
- new QPoint (-1*(b/a), 0));
|
|
|
- }
|
|
|
- }
|
|
|
+ p2->setX(-b/a);
|
|
|
+ p2->setY(0);
|
|
|
+ }
|
|
|
+ // Si le point de droite est trop haut
|
|
|
+ if((imgWidth * a + b) > imgHeight)
|
|
|
+ {
|
|
|
+ p2->setX((imgHeight-b)/a);
|
|
|
+ p2->setY(imgHeight);
|
|
|
}
|
|
|
|
|
|
- return std::make_pair (new QPoint (*p1),
|
|
|
- new QPoint (*p2));
|
|
|
+ return std::make_pair (p1, p2);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
float StrengthLine::ea_score(const StrengthLine *sl, double imgWidth, double imgHeight) const
|
|
|
{
|
|
|
std::srand(static_cast<unsigned int>(std::time(nullptr)+std::rand()));
|