I have the following problem that is breaking my head and I can not solve it. I receive geographical positions by means of a GPS ... I convert them to coordinates of the plane. Once I have these coordinates, I draw the area between each pair of points received. I mean, I get the point P1 (x1, Y1) (I do not draw anything to be the first ... then I get the point P2 (x2, y2), here, if the x1 is equal to the x2, it means that it moved up or down ... if Y1 = Y2, it means that it moved sideways. Now ... if x1! = X2 and / or y1! = Y2, then it was run up or down ... BUT I NEED (and it is what I do not get) determine the polygon that I have to draw ... Based on something ... Imagine a curve, which came straight up and then down again straight in a lane next to ... that curve or sweep I can not find mathematically how to calculate the points to draw it. Can somebody help me???. I leave the QT code from when I receive the points and there I determine (in these cases they are always rectangles lying down or stopped) but in the curves I do not find what to graph.
void WorkedPathGraph::addPointToDraw(QPointF point)
{
if (points.count() == 0)
{
/*QRectF newRect = QRectF(QPointF(point.x() - (_anchoLabor / 2.0), point.y()), QPointF(point.x() + (_anchoLabor / 2.0), point.y()));
areas.append(newRect);*/
points.append(point);
}
else
{
QPointF lastIns = points.last();
if (lastIns.y() == point.y())
{
QPolygonF newPol = QPolygonF(QVector<QPointF>() << QPointF(point.x(), point.y() - (_anchoLabor / 2.0))
<< QPointF(point.x(), point.y() + (_anchoLabor / 2.0))
<< QPointF(lastIns.x(), lastIns.y() + (_anchoLabor / 2.0))
<< QPointF(lastIns.x(), lastIns.y() - (_anchoLabor / 2.0)));
points.append(point);
areas.append(newPol);
}
else
{
QPolygonF newPol = QPolygonF(QVector<QPointF>() << QPointF(point.x() - (_anchoLabor / 2.0), point.y()) << QPointF(point.x() + (_anchoLabor / 2.0), point.y()) << QPointF(lastIns.x() + (_anchoLabor / 2.0), lastIns.y()) << QPointF(lastIns.x() - (_anchoLabor / 2.0), lastIns.y()));
points.append(point);
areas.append(newPol);
}
}
this->parentItem()->update();
}