Mercurial > projects > ldc
annotate test/dotproduct.d @ 35:3cfcb944304e trunk
[svn r39] * Updated to DMD 1.022 with the exception of:
Bugzilla 278: dmd.conf search path doesn't work
This fix was causing crashes for me :/ So for it's the old behaviour
author | lindquist |
---|---|
date | Tue, 09 Oct 2007 06:21:30 +0200 |
parents | e116aa1488e6 |
children | 0c5f410d973c |
rev | line source |
---|---|
1 | 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 | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
10 void print(char[] n) |
1 | 11 { |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
12 printf("%.*s = vec3(%.4f, %.4f, %.4f)\n", n.length, n.ptr, x,y,z); |
1 | 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 |