-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.cs
More file actions
51 lines (48 loc) · 1.23 KB
/
Copy pathUtils.cs
File metadata and controls
51 lines (48 loc) · 1.23 KB
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
using System;
namespace utils
{
public struct vec3
{
public float x;
public float y;
public float z;
public vec3(float X, float Y, float Z)
{
x = X;
y = Y;
z = Z;
}
public bool IsNan()
{
return float.IsNaN(x) || float.IsNaN(y) || float.IsNaN(z);
}
}
class Utils
{
public static float length(vec3 a)
{
return (float)Math.Sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
}
public static float dot(vec3 a, vec3 b)
{
return a.x * b.x + a.y * b.y + a.z * b.z;
}
public static vec3 normilize(vec3 a)
{
float l = length(a);
return new vec3(a.x / l, a.y / l, a.z / l);
}
public static vec3 add(vec3 a, vec3 b)
{
return new vec3(a.x + b.x, a.y + b.y, a.z + b.z);
}
public static vec3 sub(vec3 a, vec3 b)
{
return new vec3(a.x - b.x, a.y - b.y, a.z - b.z);
}
public static vec3 multS(vec3 a, float k)
{
return new vec3(a.x * k, a.y * k, a.z * k);
}
}
}