1 Star 0 Fork 0

云金杞/learn_cpp_series

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
geometry.h 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
云金杞 提交于 2023-12-26 15:40 +08:00 . inital
#pragma once
#include "testing.h"
const double PI = 3.1415926535897932384626433832795028842;
// forward declarations, allows references
// to be used between the different classes
class Circle;
class PolarPoint;
class CartesianPoint;
class Circle {
public:
double radius;
double area();
double circumference();
};
class CartesianPoint {
public:
double x;
double y;
double distanceTo(const CartesianPoint& x) const;
double distanceTo(const PolarPoint& x) const;
};
class PolarPoint {
public:
double r;
double theta;
};
/**
* Computes the area of a circle
*/
double areaOfCircle(double r);
/**
* Computes the circumference of a circle
*/
double circumferenceOfCircle(double r);
/**
* Converts Cartesian coordinates to polar coordinates. Note this
* changes r and theta.
*/
PolarPoint cartesianToPolar(const CartesianPoint&);
/**
* Converts polar coordinates to cartesian. Note, this changes x and y.
*/
CartesianPoint polarToCartesian(const PolarPoint&);
/**
* Computes the perimeter of a triangle
*/
double perimeter(const CartesianPoint& p1,
const CartesianPoint& p2,
const CartesianPoint& p3);
/**
* Test suite
*/
void testGeometry();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/yunjinqi/learn_cpp_series.git
git@gitee.com:yunjinqi/learn_cpp_series.git
yunjinqi
learn_cpp_series
learn_cpp_series
master

搜索帮助