Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -2,31 +2,30 @@ import std.stdio, std.conv, std.numeric;
struct V3 {
union {
immutable static struct { double x, y, z; }
immutable struct { double x, y, z; }
immutable double[3] v;
}
double dot(in V3 rhs) /*@safe*/ const pure nothrow {
double dot(in V3 rhs) const pure nothrow /*@safe*/ @nogc {
return dotProduct(v, rhs.v);
}
V3 cross(in V3 rhs) @safe const pure nothrow {
V3 cross(in V3 rhs) const pure nothrow @safe @nogc {
return V3(y * rhs.z - z * rhs.y,
z * rhs.x - x * rhs.z,
x * rhs.y - y * rhs.x);
}
string toString() /*@safe*/ const { return text(v); }
string toString() const { return v.text; }
}
double scalarTriple(in V3 a, in V3 b, in V3 c)
/*@safe*/ pure nothrow {
double scalarTriple(in V3 a, in V3 b, in V3 c) /*@safe*/ pure nothrow {
return a.dot(b.cross(c));
// function vector_products.V3.cross (const(V3) rhs) immutable
// is not callable using argument types (const(V3)) const
}
V3 vectorTriple(in V3 a, in V3 b, in V3 c) @safe pure nothrow {
V3 vectorTriple(in V3 a, in V3 b, in V3 c) @safe pure nothrow @nogc {
return a.cross(b.cross(c));
}
@ -34,6 +33,7 @@ void main() {
immutable V3 a = {3, 4, 5},
b = {4, 3, 5},
c = {-5, -12, -13};
writeln("a = ", a);
writeln("b = ", b);
writeln("c = ", c);