Esempio n. 1
0
 static double CalcSignedDistance(QLineF line, QPointF p)
 {
     // scalar projection on line. in case of co-linear
     // vectors this is equal to the signed distance.
     return((p.x() - line.p1().x()) * (line.p2().x() - line.p1().x()) + (p.y() - line.p1().y()) * (line.p2().y() - line.p1().y()));
 }
Esempio n. 2
0
        static LineSide GetSideOfLine(QLineF line, QPointF pt)
        {
            double d = (pt.x() - line.p1().x()) * (line.p2().y() - line.p1().y()) - (pt.y() - line.p1().y()) * (line.p2().x() - line.p1().x());

            return((Math.Sign(d) >= 0) ? LineSide.Right : ((Math.Sign(d) < 0) ? LineSide.Left : LineSide.On));
        }