UNPKG

salat-first

Version:

Islamic prayer times calculation with special support for Moroccan methods and Maliki madhab

52 lines (51 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.degreesToRadians = degreesToRadians; exports.radiansToDegrees = radiansToDegrees; exports.normalizeToScale = normalizeToScale; exports.unwindAngle = unwindAngle; exports.quadrantShiftAngle = quadrantShiftAngle; /** * Converts degrees to radians * @param degrees Angle in degrees * @returns Angle in radians */ function degreesToRadians(degrees) { return (degrees * Math.PI) / 180.0; } /** * Converts radians to degrees * @param radians Angle in radians * @returns Angle in degrees */ function radiansToDegrees(radians) { return (radians * 180.0) / Math.PI; } /** * Normalizes a value to be within a given scale * @param value The value to normalize * @param max The maximum value of the scale * @returns The normalized value */ function normalizeToScale(value, max) { return value - max * Math.floor(value / max); } /** * Unwinds an angle to be between 0 and 360 degrees * @param angle The angle in degrees * @returns The unwound angle between 0 and 360 degrees */ function unwindAngle(angle) { return normalizeToScale(angle, 360.0); } /** * Shifts an angle to be between -180 and 180 degrees * @param angle The angle in degrees * @returns The shifted angle between -180 and 180 degrees */ function quadrantShiftAngle(angle) { if (angle >= -180 && angle <= 180) { return angle; } return angle - 360 * Math.round(angle / 360); }