My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Text;
using OpenTK.Math;

namespace Dogfight2008.Common
{
public static class Calc
{
public const float Epsilon = 0.001f; // Unit meters; millimeter precision OK

public static bool AlmostEqual(float a, float b)
{
return Math.Abs(a - b) < Epsilon;
}

public static bool AlmostEqual(Vector3 v1, Vector3 v2)
{
return AlmostEqual(v1.X, v2.X) && AlmostEqual(v1.Y, v2.Y) && AlmostEqual(v1.Z, v2.Z);
}

public static bool AlmostZero(float a)
{
return AlmostEqual(a, 0);
}

public static bool Equal(Vector3 v1, Vector3 v2)
{
return v1.X == v2.X && v1.Y == v2.Y && v1.Z == v2.Z;
}

public static float DegreesToRadians(float degrees)
{
return 0.0174532925f * degrees;
}

public static float RadiansToDegrees(float radians)
{
return radians / 0.0174532925f;
}

public static Vector2 v(double x, double y)
{
return new Vector2((float)x, (float)y);
}

public static Vector3 v(double x, double y, double z)
{
return new Vector3((float)x, (float)y, (float)z);
}

public static Vector2 Polar(double angle, double distance)
{
return v(Math.Cos(angle) * distance, Math.Sin(angle) * distance);
}
}
}

Change log

r2 by olof.bjarnason on Jun 11, 2008   Diff
[No log message]
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1373 bytes, 57 lines
Powered by Google Project Hosting