auto begin = points[1];
auto end = points[2];
auto pt = points[0];
osg::Vec3 ret;
auto dx = begin.x() - end.x();
auto dy = begin.y() - end.y();
auto dz = begin.z() - end.z();
auto u = (pt.x() - begin.x()) * (begin.x() - end.x()) + (pt.y() - begin.y()) * (begin.y() - end.y()) +
(pt.z() - begin.z()) * (begin.z() - end.z());
u = u / (qPow(dx, 2) + qPow(dy, 2) + qPow(dz, 2));
ret.x() = begin.x() + u * dx;
ret.y() = begin.y() + u * dy;
ret.z() = begin.z() + u * dz;
07-21
617
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-01
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交