// RUNNABLE_PHOBOS_TEST // original post to the D newsgroup: // http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=D&artnum=10554&header // Test to manipulate 3D vectors, in D! // by Sean L Palmer (seanpalmer@directvinternet.com) // This code is released without any warranty. Use at your own risk. import core.stdc.stdio; import std.math : sqrt; template VecTemplate(tfloat, int dim:3) { struct Vector { tfloat d[dim]; version(none) { // sets the vector to the value of the given array void set(tfloat[dim] r) { d[] = r[]; } // comparison (a == b, a != b) bool opEquals(Vector b) { for (int i=0; i