Point2和Point3类定义
支持以下图中的运算

类声明:
class Point2 {
public:
Point2();
~Point2();
Point2(ldouble a);
Point2(ldouble a, ldouble b);
Point2(const Point2& p);
Point2 operator+(const Point2& p) const;
Point2& operator+=(const Point2& p);
Point2 operator-(const Point2& p) const;
Point2& operator-=(const Point2& p);
Point2 operator*(ldouble a) const;
Point2& operator*=(ldouble a);
Point2 operator/(ldouble f) const;
Point2& operator/=(ldouble f);
Point2 operator-() const;
Point2& operator=(const Point2& p);
bool operator==(const Point2& p) const;
bool operator!=(const Point2& p) const;
friend ldouble distance(const Point2& p1, const Point2& p2);
friend ldouble distance_squared(const Point2& p1, const Point2& p2);
friend Point2 operator*(ldouble a, const Point2& p);
friend std::ostream& operator<<(std::ostream& os, const Point2& p);
friend std::istream& operator>>(std::istream& is, Point2& p);
ldouble x, y;
};
class Point3 {
public:
Point3();
~Point3();
Point3(ldouble a);
Point3(ldouble a, ldouble b, ldouble c);
Point3(const Point2& p);
Point3(const Point3& p);
Point3 operator+(const Vector3& v) const;
Point3& operator+=(const Vector3& v);
Vector3 operator-(const Point3& p) const;
Point3 operator-(const Vector3& v) const;
Point3& operator-=(const Vector3& v);
Point3 operator*(ldouble a) const;
Point3& operator*=(ldouble a);
Point3 operator/(ldouble f) const;
Point3& operator/=(ldouble f);
Point3 operator-() const;
Point3& operator=(const Point3& p);
bool operator==(const Point3& p) const;
bool operator!=(const Point3& p) const;
friend ldouble distance(const Point3& p1, const Point3& p2);
friend ldouble distance_squared(const Point3& p1, const Point3& p2);
friend Point3 operator*(ldouble a, const Point3& p);
friend std::ostream& operator<<(std::ostream& os, const Point3& p);
friend std::istream& operator>>(std::istream& is, Point3& p);
ldouble x, y, z;
};
实现还是作为练习,图中已经写明了运算了。
Point2和Point3类定义的更多相关文章
- Sampler类定义
此是所有采样的基类,这样定义的好处是,我们可以分别测试每一个采样算法. 类定义: #pragma once #ifndef __SAMPLER_HEADER__ #define __SAMPLER_H ...
- Sphere类定义
这个类是球体,也就是一会要显示的球体了.这个类继承于Geometrics类,并实现了自己的碰撞检测,碰撞原理,书上也说的很清楚了啊,大家多看.然后对照代码就明白了. 类定义: #pragma once ...
- Python笔记——类定义
Python笔记——类定义 一.类定义: class <类名>: <语句> 类实例化后,可以使用其属性,实际上,创建一个类之后,可以通过类名访问其属性 如果直接使用类名修改其属 ...
- 几种常用的JS类定义方法
几种常用的JS类定义方法 // 方法1 对象直接量var obj1 = { v1 : "", get_v1 : function() { return ...
- Js 类定义的几种方式
提起面向对象我们就能想到类,对象,封装,继承,多态.在<javaScript高级程序设计>(人民邮电出版社,曹力.张欣译.英文名字是:Professional JavaScript for ...
- 为什么C++类定义中,数据成员不能被指定为自身类型,但可以是指向自身类型的指针或引用?为什么在类体内可以定义将静态成员声明为其所属类的类型呢 ?
static的成员变量,不是存储在Bar实例之中的,因而不会有递归定义的问题. 类声明: class Screen: //Screen类的声明 1 类定义: class Screen{ //Scree ...
- C++学了这么多年,你也许不知道为什么类定义要放在.h文件,类实现放在cpp文件。它们如何关联?
原文 http://blog.csdn.net/ithzhang/article/details/8119286 主题 C++ C++学了这么多年你知道为什么定义类时,类的定义放在.h文件中,而类 ...
- YTU 2602: 熟悉题型——类设计( 矩形类定义【C++】)
2602: 熟悉题型--类设计( 矩形类定义[C++]) 时间限制: 1 Sec 内存限制: 128 MB 提交: 183 解决: 119 题目描述 定义一个矩形类,数据成员包括左下角和右上角坐标 ...
- Objective-c 类接口 (@interface) (类定义)
在Objective-c中如何定义一个类呢?我们可以使用下面的格式进行表示: @interface 类名:父类名{ 变量定义; } 方法定义: @end; 下面给出一个实例: @interface P ...
随机推荐
- 浅析kubernetes中client-go structure01
Prepare Introduction 从2016年8月起,Kubernetes官方提取了与Kubernetes相关的核心源代码,形成了一个独立的项目,即client-go,作为官方提供的go客户端 ...
- 使用 Vite 插件开发构建 Tampermonkey 用户脚本
起因 一直以来,我都是直接在浏览器 Tampermonkey 扩展页面直接新建用户脚本来开发的: 对于一些简单的脚本,这没有什么问题,即改即看.但当代码多了以后问题就来了,自带编辑器开发体验确实不太舒 ...
- Unity-UGUI-无限循环列表
前言:项目准备新增一个竞技场排行榜,策划规定只显示0-400名的玩家.我一想,生成四百个游戏物体,怕不是得把手机给卡死?回想原来在GitHub上看到过一个实现思路就是无限循环列表,所以就想自己试试.公 ...
- CF1681F Unique Occurrences
题意:一棵树,问每条路径上只出现一次的值的个数的和. 思路: 显然想到考虑边贡献.每条边权下放到下面的哪个点.\(up_i\)为上面第一个点权等于它的点.我们需要一个子树内点权等于它的点(如果满足祖孙 ...
- Codeforces Round #773 (Div. 2)
这一场打的非常一般,不过把D想出来了(当然只剩10min没有写出来). A.Hard Way 题意:(很怪的题,我读题读半天)给你一个三角形(端点都在整数点上),问从x轴往上划线(不一定垂直)画不到的 ...
- 一个全新的Vue拖拽特性实现:“调整尺寸”部分
关于拖拽 CabloyJS提供了完备的拖拽特性,可以实现移动和调整尺寸两大类功能,这里对调整尺寸的开发进行阐述 关于移动的开发,请参见:拖拽:移动 演示 开发步骤 下面以模块test-party为例, ...
- conda和pip加速参考
conda install和创建虚拟环境下载慢,可以修改/root/.condarc文件: vim /root/.condarc 各系统都可以通过修改用户目录下的 .condarc 文件.Window ...
- 【物联网天线选择攻略】2.4GHz 频段增益天线模块设备选择
天线模块设备(antenna)是一种能量变换器,它把传输线上传播的导行波,变换成在无界媒介中传播的电磁波,或者进行相反的变换.对于设计一个应用于射频系统中的小功率.短距离的2.4GHz无线收发设备, ...
- Eclipse for Python开发环境部署
Eclipse for Python开发环境部署 工欲善其事,必先利其器. 对开发人员来说,顺手的开发工具必定事半功倍.自学编程的小白不知道该选择那个开发工具,Eclipse作为一个功能强大且开源免费 ...
- Java使用FreeMarker模版技术动态生成word实践
一.序言 在日常开发中,常常有动态word文件生成的需求,通过编制模版,然后动态修改word内容以组合成新的文件.报告单.请假单.发票页等都可以使用动态生成word来解决. 笔者总结归纳出通用技术要点 ...