作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个表示坐标的形式为 (x,y,x) 的向量。我希望能够执行类似 (x,y,z) + (x2,y2,z2) 的操作来生成一组新坐标。 Ada 说它不能对复合类型使用“+”,但我肯定有办法做到这一点?
最佳答案
如果你有
type Vector is record
X : Float;
Y : Float;
Z : Float;
end record;
你可以定义+
为
function "+" (L, R : Vector) return Vector is
(L.X + R.X, L.Y + R.Y, L.Z + R.Z);
在定义 -
时要小心,就像在整个过程中使用 -
一样!该错误非常难以发现。
关于vector - 如何在 Ada 中添加向量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63948479/
我是一名优秀的程序员,十分优秀!