c++ - 找到与给定 3D 线正交的远离 d 距离的点

标签 c++ math vector 3d geometry

I want to find the coordinate of a point (say P) which is away from a known distance (say d). the case is: I want the point that lie on a line (3d) which is perpendicular to the another given line segment (3d) and passing through the one end of that given line segment (say A). So, I know 2 end points (also vector along the line) of the given line segment and distance d and vector of the perpendicular line. Also point C where the perpendicular line pass through is also known. I am having vector3 class and line3 class.

解决这个问题的方法很难弄清楚,所以请在这方面帮助我指点迷津。

是的,由于该线上有 2 个相反方向的点,我正在寻找更接近点 C(而不是 Q)的点 (P)。

提前谢谢

enter image description here

最佳答案

找到方向 vector ,然后将其乘以d,然后添加到起点:

Vector A, C;
float d = 100;

Vector dir = C - A;
dir.normalize();
dir *= d;
Vector P = A + dir;

关于c++ - 找到与给定 3D 线正交的远离 d 距离的点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13604514/

相关文章:

c++ - 使用 async 的并行函数调用

Javascript (+) 符号连接而不是给出变量的总和

确定可接受方差的算法

c++ - 是否有用于向文件路径添加尾部斜杠的习惯用法?

c++ - 有没有好的轻量级多平台C++定时器队列?

javascript - 如何提高生成下一个字典顺序的算法的效率?

c++ - 使用 vector 调整大小时如何调用非默认构造函数?

c++ - 2D 射弹 - 速度和位置 vector

java - Java 中的 push_back() 和 push_front()

c++ - 如果类具有引用成员,为什么合成的复制赋值运算符被定义为已删除?