Anonymous user
Vector products: Difference between revisions
Updated D code
(→{{header|Pascal}}: add example) |
(Updated D code) |
||
Line 388:
=={{header|D}}==
<lang d>import std.stdio
immutable struct V3 {
union {
static struct { double x, y, z; }
double[3] v;
}
return dotProduct(v, rhs.v);
}
return V3(y*rhs.z - z*rhs.y,
z*rhs.x - x*rhs.z,
x*rhs.y - y*rhs.x);
}
string toString() const { return text(v); }
}
return a.dot(b.cross(c));
}
return a.cross(b.cross(c));
}
void main() {
b = {4, 3, 5},
c = {-5, -12, -13};
writeln("a = ", a);
writeln("b = ", b);
|