1 module rip.concepts.mathematics; 2 3 private 4 { 5 import std.math; 6 7 import rip.concepts.templates; 8 9 static real RADIAN_IN_DEGREES = 180.0 / PI; 10 static real DEGREE_IN_RADIANS = PI / 180.0; 11 } 12 13 // Касинус 14 /++ +/ 15 T cas(T)(T x) 16 if (allArithmetic!T) 17 { 18 auto argument = cast(real) x; 19 return cast(T) SQRT2 * cos(x + PI_4); 20 } 21 22 23 // Ненормированный кардинальный синус 24 /++ +/ 25 T sinc(T)(T x) 26 if (allArithmetic!T) 27 { 28 auto argument = cast(real) x; 29 30 if (approxEqual(x, 0)) 31 { 32 return 1; 33 } 34 else 35 { 36 return sin(x) / x; 37 } 38 } 39 40 // Нгормированный кардинальный синус 41 /++ +/ 42 T normalizedSinc(T)(T x) 43 if (allArithmetic!T) 44 { 45 auto argument = cast(real) x; 46 47 if (approxEqual(x, 0)) 48 { 49 return 1; 50 } 51 else 52 { 53 return sin(PI * x) / (PI * x); 54 } 55 } 56 57 /++ +/ 58 T degreesInRadians(T)(T x) 59 if (allArithmetic!T) 60 { 61 auto argument = cast(real) x; 62 return x * DEGREE_IN_RADIANS; 63 } 64 65 /++ +/ 66 T radiansInDegrees(T)(T x) 67 if (allArithmetic!T) 68 { 69 auto argument = cast(real) x; 70 return x * RADIAN_IN_DEGREES; 71 }