c++ - 如何从另一个顶点中减去一个顶点?
问题描述
对于我的 uni 分配,我需要从另一个顶点中减去一个顶点
任务:通过从顶点 0 中减去顶点 1 来构造向量 a。
教授给了我们方法的主体,我们需要填充它,以便为每个顶点工作
方法的主体:
Vector MinusToVector(const Vertex &other) const;
使用方法:
向量 VectorA = 顶点 1. MinusToVector(vertex0);
我为这个任务奋斗了一个多小时,我做不到
解决方案
This usually works:
Vector Vector::MinusToVector(const Vertex &other) const {
return Vertex(this->X - other.x, this->y - other.y, this->z - other.z);
}
By the way your professor gave you the declaration, not the body of the method.
Make sure to include the declaration inside the Vector class/struct body.
推荐阅读
- c++ - 使用 enable_if 仅匹配具有特定静态数据成员且仅具有特定值的类
- php - 在 JSON 中获得两次输出
- php - 如何在 PHP 中创建设置选项
- javascript - 生产与开发中的 Django/React 应用程序 API?
- java - 禁止 HashSet 允许 JAVA 中的重复对象
- php - 无法使用日期函数获得结果
- python - 将值分配给 numpy 矩阵
- javascript - 在 php 中共享到 facebook 时如何在标题 facebook 帖子中显示名称
- c++ - 使用智能指针实现 AVL 树第 2 部分
- java - 嵌入式 Jetty 服务器中的 TLSv1 支持