【问题标题】:How can I subtract a vertex from another vertex?如何从另一个顶点中减去一个顶点?
【发布时间】:2021-05-04 14:47:01
【问题描述】:

对于我的 uni 分配,我需要从另一个顶点中减去一个顶点

任务:通过顶点 0 减去顶点 1 来构造向量 a。

教授给了我们方法的主体,我们需要填充它,以便为每个顶点工作

方法体:

Vector MinusToVector(const Vertex &other) const;

方法的使用:

向量 VectorA = 顶点 1. MinusToVector(vertex0);

我为这个任务奋斗了一个多小时,我做不到

【问题讨论】:

  • 我投票结束这个问题,因为问题来自家庭作业

标签: c++ gdi


【解决方案1】:

这通常有效:

Vector Vector::MinusToVector(const Vertex &other) const {
  return Vertex(this->X - other.x, this->y - other.y, this->z - other.z);
}

顺便说一句,你的教授给了你声明,而不是方法的主体。

确保在 Vector 类/结构体中包含声明。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-09
    • 1970-01-01
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多