comparison test/dotproduct.d @ 1:c53b6e3fe49a trunk

[svn r5] Initial commit. Most things are very rough.
author lindquist
date Sat, 01 Sep 2007 21:43:27 +0200
parents
children e116aa1488e6
comparison
equal deleted inserted replaced
0:a9e71648e74d 1:c53b6e3fe49a
1 struct vec3
2 {
3 float x,y,z;
4
5 float dot(ref vec3 v)
6 {
7 return x*v.x + y*v.y + z*v.z;
8 }
9
10 void print(char* n)
11 {
12 printf("%s = vec3(%.4f, %.4f, %.4f)\n", n, x,y,z);
13 }
14 }
15
16 int main()
17 {
18 printf("Dot Product test\n");
19
20 const float f = 0.7071067811865474617f;
21 vec3 v = vec3(f,f,0);
22 vec3 w = vec3(f,0,f);
23
24 v.print("v");
25 v.print("w");
26
27 auto dp = v.dot(w);
28 printf("v ยท w = %f\n", dp);
29 assert(dp > 0.4999 && dp < 0.5001);
30
31 printf(" SUCCESS\n");
32 return 0;
33 }
34