-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathOptions.cs
More file actions
51 lines (44 loc) · 1.76 KB
/
MathOptions.cs
File metadata and controls
51 lines (44 loc) · 1.76 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 Number = double;
namespace PhysicalAnalysis
{
/// <summary>
/// Static class with configurable display and unit options.
/// </summary>
public static class MathOptions
{
public enum AngleUnit { Radian, Degree }
public enum VectorSystem { Cartesian, Polar }
public static AngleUnit angleUnit = AngleUnit.Radian;
public static VectorSystem vectorSystem = VectorSystem.Cartesian;
/// <summary>
/// Whether to display grams as kilograms. This only affects .ToString(), the underlying base unit for calculations is still grams.
/// </summary>
public static bool baseKilograms = true;
/// <summary>
/// Whether to show common composite units such as Newtons or Joules as a single unit.
/// </summary>
public static bool consolidateUnits = true;
/// <summary>
/// The priority order for which units are consolidated first, if multiple are available.
/// </summary>
public static List<DerivedUnit> consolidatePriority = [];
/// <summary>
/// Converts an angle to radians if useRadians is true.
/// </summary>
/// <param name="angle"></param>
/// <returns></returns>
public static Number ConvertAngle(Number angle)
{
return angleUnit == AngleUnit.Radian ? angle : angle * Math.PI / 180;
}
/// <summary>
/// Converts an angle to degrees if useRadians is false.
/// </summary>
/// <param name="angle"></param>
/// <returns></returns>
public static Number ReverseConvertAngle(Number angle)
{
return angleUnit == AngleUnit.Radian ? angle : angle * 180 / Math.PI;
}
}
}