fixed akl: order lines counterclockwise
This commit is contained in:
parent
40f6a6cb04
commit
f65041c0ad
27
Display.cpp
27
Display.cpp
@ -127,15 +127,23 @@ void Display::setCurrentLine()
|
|||||||
positives++;
|
positives++;
|
||||||
break; // sufficient as candidate if at least one point is right
|
break; // sufficient as candidate if at least one point is right
|
||||||
}
|
}
|
||||||
/*positives += (sign(pt.getPosition().x, pt.getPosition().y,
|
/*if (sign(pt.getPosition().x, pt.getPosition().y,
|
||||||
cand.from().x(), cand.from().y(),
|
cand.from().x(), cand.from().y(),
|
||||||
cand.to().x(), cand.to().y()) > 0) ? 1 : 0;*/
|
cand.to().x(), cand.to().y()) > 0)
|
||||||
|
{
|
||||||
|
positives++;
|
||||||
|
break; // sufficient as candidate if at least one point is right
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (positives > 0)
|
if (positives > 0)
|
||||||
{
|
{
|
||||||
m_curLineIdx = lines - 1;
|
m_curLineIdx = lines - 1;
|
||||||
m_curLine = m_lines[lines - 1];
|
m_curLine = m_lines[lines - 1];
|
||||||
|
|
||||||
|
std::cout << "selecting last line of " << lines << ": " <<
|
||||||
|
m_curLine.from().x() << ", " << m_curLine.from().y() << " - " <<
|
||||||
|
m_curLine.to().x() << ", " << m_curLine.to().y() << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -209,6 +217,11 @@ void Display::update ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "right: " << right.x << ", " << right.y << std::endl;
|
||||||
|
std::cout << "top: " << top.x << ", " << top.y << std::endl;
|
||||||
|
std::cout << "left: " << left.x << ", " << left.y << std::endl;
|
||||||
|
std::cout << "bot: " << bot.x << ", " << bot.y << std::endl;
|
||||||
|
|
||||||
// adding edge points to hull
|
// adding edge points to hull
|
||||||
m_points[i_left].setFillColor(sf::Color::Blue);
|
m_points[i_left].setFillColor(sf::Color::Blue);
|
||||||
m_hullPoints.push_back(m_points[i_left]);
|
m_hullPoints.push_back(m_points[i_left]);
|
||||||
@ -223,9 +236,11 @@ void Display::update ()
|
|||||||
m_hullPoints.push_back(m_points[i_bot]);
|
m_hullPoints.push_back(m_points[i_bot]);
|
||||||
|
|
||||||
// building lines between edge points
|
// building lines between edge points
|
||||||
Point pt1(left.x, left.y);
|
// hull points shall be clockwise, but lines have to be counterclockwise
|
||||||
|
// because only checking elems right of lines
|
||||||
|
Point pt1(right.x, right.y);
|
||||||
Point pt2(top.x, top.y);
|
Point pt2(top.x, top.y);
|
||||||
Point pt3(right.x, right.y);
|
Point pt3(left.x, left.y);
|
||||||
Point pt4(bot.x, bot.y);
|
Point pt4(bot.x, bot.y);
|
||||||
m_lines.push_back(Line(pt1, pt2));
|
m_lines.push_back(Line(pt1, pt2));
|
||||||
m_lines.push_back(Line(pt2, pt3));
|
m_lines.push_back(Line(pt2, pt3));
|
||||||
@ -251,7 +266,7 @@ void Display::update ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentLine();
|
//setCurrentLine(); // set current line in next step
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user