给定 2 点和从第一点到我必须找到的点的范围.如何找到我必须找到的点(在3D空间上)
Given 2 point and a range from first point to the point that I have to find. How to find the point I have to find (on 3D Space)
我不知道如何找到我所说的第三点。
但是,我尝试编写代码编写以下内容:
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);
}
它来自向量方程 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);
相关文章:
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 命名空间中具有.h和.cpp文件的类
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 为什么 std::variant 找不到运算符<() 当与比较类不在同一命名空间中时
- 为什么找不到使用命名空间中定义的类型实例化的 std::weak_ptr 的重载运算符==?
- dyld:惰性符号绑定失败:找不到符号.预期在:平面命名空间
- 在项目中移动了文件,现在我找不到命名空间
- 尽管包含头文件,但仍找不到嵌套命名空间
- Eclipse C :班级,名称空间,枚举找不到
- C++在全局命名空间中找不到非标准 C 函数
- 为什么我的项目在命名空间 std 中找不到"function"?
- 找出3D空间中两个对象的公式
- 找不到DirectX名称空间了
- 如何使用 vc++ 找出当前线程堆栈上还剩下多少空间
- 在命名空间/头文件中找不到类
- 找不到命名空间,尽管它就在那里
- 如果存在具有不同参数类型的重载,则在全局命名空间中找不到函数
- Xcode 找不到'std'命名空间
- boost.log std::异常格式化程序找不到运算符<< 自己的命名空间中的重载
- 链接器在命名空间中找不到函数定义