-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cs
69 lines (58 loc) · 1.67 KB
/
test.cs
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
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Text;
namespace T4Templates
{
public static partial class Test
{
public static bool IsBetween(this double x, double min, double max)
{
return x < min ? false : (x > max ? false : true);
}
public static double Clamp(this double x, double min, double max)
{
return x < min ? min : (x > max ? max : x);
}
public static double Lerp(this double t, double a, double b)
{
return t.Clamp(0, 1)*(b - a) + a;
}
public static double Saturate(this double t)
{
return t.Clamp(0, 1);
}
public static bool IsBetween(this float x, float min, float max)
{
return x < min ? false : (x > max ? false : true);
}
public static float Clamp(this float x, float min, float max)
{
return x < min ? min : (x > max ? max : x);
}
public static float Lerp(this float t, float a, float b)
{
return t.Clamp(0, 1)*(b - a) + a;
}
public static float Saturate(this float t)
{
return t.Clamp(0, 1);
}
public static bool IsBetween(this decimal x, decimal min, decimal max)
{
return x < min ? false : (x > max ? false : true);
}
public static decimal Clamp(this decimal x, decimal min, decimal max)
{
return x < min ? min : (x > max ? max : x);
}
public static decimal Lerp(this decimal t, decimal a, decimal b)
{
return t.Clamp(0, 1)*(b - a) + a;
}
public static decimal Saturate(this decimal t)
{
return t.Clamp(0, 1);
}
}
}