/** * Helper class since QVector3D does not provide rX() functions and only has float as data type * $Id$ * $HeadURL$ * $Author$ * Created by Christian Ehrlicher, SLSE, 2016-05-03 */ #include "qpoint3d.h" #include using namespace LtsUtils; double QPoint3D::distanceToLine(const QPoint3D &point, const QPoint3D &direction) const { if (direction.isNull()) return (*this - point).length(); QPoint3D p = point + dotProduct(*this - point, direction) * direction; return (*this - p).length(); } double QPoint3D::distanceToPlane(const QPoint3D &plane, const QPoint3D &normal) const { return dotProduct(*this - plane, normal); } double QPoint3D::distanceToPlane(const QPoint3D &plane1, const QPoint3D &plane2, const QPoint3D &plane3) const { QPoint3D n = normal(plane2 - plane1, plane3 - plane1); return dotProduct(*this - plane1, n); } double QPoint3D::distanceToPoint(const QPoint3D &point) const { return (*this - point).length(); } QDataStream &operator<<(QDataStream &s, const QPoint3D &p) { s << p.x() << p.y() << p.z(); return s; } QDataStream &operator>>(QDataStream &s, QPoint3D &p) { double x, y, z; s >> x; p.rx() = x; s >> y; p.ry() = y; s >> z; p.rz() = z; return s; }