{
QPointF intrsctPoint;
// New point for intersection
const QLineF nEdge
(0,
0,
1000,
0);
// Initialize N edge boundry const QLineF sEdge
(0,
1000,
1000,
1000);
// Initialize S edge boundry const QLineF eEdge
(1000,
0,
1000,
1000);
// Initialize E edge boundry const QLineF wEdge
(0,
0,
0,
1000);
// Initialize W edge boundry
QLineF track
= QLineF::fromPolar(1, heading
);
// Track w/angle track.translate(crntPos); // Start line at current pos
if(track.
intersect(eEdge,
&intrsctPoint
) == QLineF::UnboundedIntersection) track.setP2(intrsctPoint);
if(track.
intersect(nEdge,
&intrsctPoint
) == QLineF::UnboundedIntersection) track.setP2(intrsctPoint);
if(track.
intersect(wEdge,
&intrsctPoint
) == QLineF::UnboundedIntersection) track.setP2(intrsctPoint);
if(track.
intersect(sEdge,
&intrsctPoint
) == QLineF::UnboundedIntersection) track.setP2(intrsctPoint);
return intrsctPoint;
}
QPointF Target::checkEdge(QPointF crntPos)
{
QPointF intrsctPoint; // New point for intersection
const QLineF nEdge(0, 0, 1000, 0); // Initialize N edge boundry
const QLineF sEdge(0, 1000, 1000, 1000); // Initialize S edge boundry
const QLineF eEdge(1000, 0, 1000, 1000); // Initialize E edge boundry
const QLineF wEdge(0, 0, 0, 1000); // Initialize W edge boundry
QLineF track = QLineF::fromPolar(1, heading); // Track w/angle
track.translate(crntPos); // Start line at current pos
if(track.intersect(eEdge, &intrsctPoint) == QLineF::UnboundedIntersection)
track.setP2(intrsctPoint);
if(track.intersect(nEdge, &intrsctPoint) == QLineF::UnboundedIntersection)
track.setP2(intrsctPoint);
if(track.intersect(wEdge, &intrsctPoint) == QLineF::UnboundedIntersection)
track.setP2(intrsctPoint);
if(track.intersect(sEdge, &intrsctPoint) == QLineF::UnboundedIntersection)
track.setP2(intrsctPoint);
return intrsctPoint;
}
To copy to clipboard, switch view to plain text mode
Bookmarks