直角坐标向量加法
直、极坐标变换
极坐标转为方位角表达
程序代码:#include <iostream>
#include <format>
#include <utility>
#include <cmath>
#include <numbers>
using namespace std;
int main( void )
{
const pair<double,double> vs[] = { {100,0}, {300,+120}, {200,-120} };
double x=0, y=0;
for( auto [mag,angle] : vs )
{
x += mag * cos(angle/180.*std::numbers::pi);
y += mag * sin(angle/180.*std::numbers::pi);
}
double mag = hypot(y,x);
double angle = std::atan2(y,x) /std::numbers::pi*180;
cout << format("magnitude={}, angle={}", mag, angle) << endl;
}