1 Star 1 Fork 1

loading/SatelliteSimulator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
PointPol.cpp 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
Florent Forest 提交于 2017-04-08 12:13 . Code commit
#include <PointPol.h>
PointPol::PointPol(double r, double theta, double phi)
{
m_r = r;
m_theta = theta;
m_phi = phi;
}
PointPol::PointPol(const Point& p)
{
m_r = p.getR();
m_theta = p.getTheta();
m_phi = p.getPhi();
}
PointPol::~PointPol()
{
}
PointPol PointPol::operator=(const Point& p)
{
m_r = p.getR();
m_theta = p.getTheta();
m_phi = p.getPhi();
return *this;
}
PointPol& PointPol::operator+=(const Point& p)
{
// Create cartesian copy of point to use adding operator
PointCart tmp(*this);
tmp+=p;
// Reconvert to polar point
PointPol copy(tmp);
*this = copy;
return *this;
}
PointPol& PointPol::operator-=(const Point& p)
{
// Create cartesian copy of point to use substraction operator
PointCart tmp(*this);
tmp-=p;
// Reconvert to polar point
PointPol copy(tmp);
*this = copy;
return *this;
}
PointPol operator+(const PointPol& a, const Point& b)
{
PointPol copy(a);
copy+=b;
return copy;
}
PointPol operator-(const PointPol& a, const Point& b)
{
PointPol copy(a);
copy-=b;
return copy;
}
double PointPol::getX() const
{
return m_r * std::cos(m_theta) * std::cos(m_phi);
}
double PointPol::getY() const
{
return m_r * std::sin(m_theta) * std::cos(m_phi);
}
double PointPol::getZ() const
{
return m_r * std::sin(m_phi);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/llllawliet/SatelliteSimulator.git
[email protected]:llllawliet/SatelliteSimulator.git
llllawliet
SatelliteSimulator
SatelliteSimulator
master

搜索帮助