我不知道如何找到我所说的第三点。
但是,我尝试编写代码:
float extraX; // x of the third point
float extraY; // y of the third point
float extraZ; // z of the third point
void CalculateExtraPoint(float x1, float y1, float z1, float x2, float y2, float z2){
float range = extraRange; //range from the first point to third point
float d_x = x1-x2;
float d_y = y1-y2;
float d_z = z1-z2;
distance1_2 = sqrt(pow(d_x,2)+pow(d_y,2)+pow(d_z,2));
float temp = (range/distance1_2)+1;
extraX = x2 + (temp*d_x);
extraY = y2 + (temp*d_y);
extraZ = z2 + (temp*d_z);
}
它来自 vector 方程,r=(x2,y2,z2) + (lambda)[x1-x2,y1-y2,z1-z2]。 r 是任意点。
正确吗?提前致谢。
最佳答案
是的,这是正确的。
稍微简单、更方便的变体。这里更清楚的是,我们从第一点开始考虑范围:
float temp = range/distance1_2;
extraX = x1 + (temp*d_x);
extraY = y1 + (temp*d_y);
extraZ = z1 + (temp*d_z);
关于c++ - 给定 2 个点和从第一个点到我必须找到的点的范围。如何找到我必须找到的点(在3D空间上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44503809/