comparison test/v2d.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 d9d5d59873d8
comparison
equal deleted inserted replaced
0:a9e71648e74d 1:c53b6e3fe49a
1 struct V2D(T)
2 {
3 T x,y;
4
5 T dot(ref V2D v)
6 {
7 return x*v.x + y*v.y;
8 }
9
10 V2D opAdd(ref V2D v)
11 {
12 return V2D(x+v.x, y+v.y);
13 }
14 }
15
16 alias V2D!(float) V2Df;
17
18 void main()
19 {
20 printf("V2D test\n");
21 auto up = V2Df(0.0f, 1.0f);
22 auto right = V2Df(1.0f, 0.0f);
23 assert(up.dot(right) == 0.0f);
24 auto upright = up + right;
25 assert(upright.x == 1.0f && upright.y == 1.0f);
26 auto copy = upright;
27 copy.x++;
28 assert(copy.x > upright.x);
29 printf(" SUCCESS\n");
30 }