aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/Colourful/Implementation/Utils/MathUtils.cs
blob: dfe39680850dba125344f66f8e9d23b25e16a3b3 (plain)
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
using System;

namespace Colourful.Implementation
{
    /// <summary>
    /// Math helper functions
    /// </summary>
    internal static class MathUtils
    {
        /// <summary>
        /// Compute x^2
        /// </summary>
        /// <param name="x">Base</param>
        /// <returns>Result of the exponentiation</returns>
        public static double Pow2(double x) => x * x;

        /// <summary>
        /// Compute x^3
        /// </summary>
        /// <param name="x">Base</param>
        /// <returns>Result of the exponentiation</returns>
        public static double Pow3(double x) => x * x * x;

        /// <summary>
        /// Compute x^4
        /// </summary>
        /// <param name="x">Base</param>
        /// <returns>Result of the exponentiation</returns>
        public static double Pow4(double x) => x * x * (x * x);

        /// <summary>
        /// Compute x^7
        /// </summary>
        /// <param name="x">Base</param>
        /// <returns>Result of the exponentiation</returns>
        public static double Pow7(double x) => x * x * x * (x * x * x) * x;

        /// <summary>
        /// Compute sine of angle in degrees
        /// </summary>
        /// <param name="x">Given angle</param>
        /// <returns></returns>
        public static double SinDeg(double x)
        {
            var x_rad = Angle.DegreeToRadian(x);
            var y = Math.Sin(x_rad);
            return y;
        }

        /// <summary>
        /// Compute cosine of angle in degrees
        /// </summary>
        /// <param name="x">Given angle</param>
        /// <returns></returns>
        public static double CosDeg(double x)
        {
            var x_rad = Angle.DegreeToRadian(x);
            var y = Math.Cos(x_rad);
            return y;
        }
    }
}