c++ - 向量双重计算以在 C++ 中找到角度
问题描述
我有以下代码
constexpr double pi = 3.14159265358979323846;
cout << "RAV dot product is " << normalization1.first.DotProduct(normalization2.first) << endl;
cout << "acos of 1 is " << std::acos(1) * (180/pi) << endl;
double dotproductvalue = normalization1.first.DotProduct(normalization2.first);
cout << "dot product value: " << std::fixed << dotproductvalue << endl;
cout << "RAV angel is " << std::acos(dotproductvalue) * (180 / pi) << endl;
return std::acos(normalization1.first.DotProduct(normalization2.first)) * (180 / pi); // return in
度数
当我在产品上方运行时,我观察到以下输出
问题 3:
Intersection of lines 1.182000x_1+ 5.562000x_2 = 6.744000
and 1.773000x_1+ 8.343000x_2 = 9.525000
are
RAV dot product is 1.000000
acos of 1 is 0.000000
dot product value: 1.000000
RAV angel is -nan(ind)
我无法在上面的代码中找到什么是错误 为什么 angel 显示为 -nan(ind) 而不是零?
请帮助调试。
谢谢
解决方案
推荐阅读
- javascript - 无法删除/更新 ajax laravel 中的新项目
- reactjs - jsx中的条件和数组的映射
- html - 使用 Bootstrap 的响应式 img
- r - 如何创建包含标准正态分布的递归函数?
- c# - C#模拟多个客户端随机调用10个web服务
- xcode - 删除 Github Repo 让我丢失了 Xcode 文件
- python - Python OpenCV 背景减法和边界框
- python - 为模型预测构建生成器
- python - 尝试在第 71 行运行 reindent.py 时出错
- powershell - 使用单个字符串在 PowerShell 中逐行读取文件