forked from Gericom/EveryFileExplorer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MathUtil.cs
42 lines (36 loc) · 858 Bytes
/
MathUtil.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LibEveryFileExplorer.Math
{
public class MathUtil
{
public static int Clamp(int value, int min, int max)
{
if (value < min) value = min;
if (value > max) value = max;
return (short)value;
}
public static float RadToDeg(float Radians)
{
return Radians * (180f / (float)System.Math.PI);
}
public static double RadToDeg(double Radians)
{
return Radians * (180.0 / System.Math.PI);
}
public static float DegToRad(float Degrees)
{
return Degrees * ((float)System.Math.PI / 180f);
}
public static double DegToRad(double Degrees)
{
return Degrees * (System.Math.PI / 180.0);
}
public static int GetNearest2Power(float Value)
{
return (int)System.Math.Ceiling(System.Math.Log(Value, 2));
}
}
}