Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,16 @@
import std.stdio, std.algorithm, std.complex;
import std.math: PI;
auto radians(T)(in T d) pure nothrow @nogc { return d * PI / 180; }
auto degrees(T)(in T r) pure nothrow @nogc { return r * 180 / PI; }
real meanAngle(T)(in T[] D) pure nothrow @nogc {
immutable t = reduce!((a, d) => a + d.radians.expi)(0.complex, D);
return (t / D.length).arg.degrees;
}
void main() {
foreach (angles; [[350, 10], [90, 180, 270, 360], [10, 20, 30]])
writefln("The mean angle of %s is: %.2f degrees",
angles, angles.meanAngle);
}