diff --git a/lib/node_modules/@stdlib/math/base/special/sind/lib/sind.js b/lib/node_modules/@stdlib/math/base/special/sind/lib/sind.js new file mode 100644 index 000000000000..5ebf1210e0e7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sind/lib/sind.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnan = require('@stdlib/math/base/assert/is-nan'); +var isinfinite = require('@stdlib/math/base/assert/is-infinite'); +var abs = require('@stdlib/math/base/special/abs'); +var kernelSin = require('@stdlib/math/base/special/kernel-sin'); +var kernelCos = require('@stdlib/math/base/special/kernel-cos'); +var PI = require('@stdlib/constants/float64/pi'); +var deg2rad = require('@stdlib/math/base/special/deg2rad'); + +/** +* Compute the sine of a number. +* +* @module @stdlib/math/base/special/sind +* +* @example +* var sind = require( '@stdlib/math/base/special/sind' ); +* +* var v = sind( 0.0 ); +* // returns ~0.0 +* +* v = sind( 90 ); +* // returns ~1.0 +* +* v = sind( -30 ); +* // returns ~-0.5 +* +* v = sind( NaN ); +* // returns NaN +*/ + + +function sind(x) { + if (isinfinite(x)) { + return NaN; + } + if (isnan(x)) { + return NaN; + } + var rad; + x = ((x % 360) + 360) % 360 + if (x <= 45) { + rad = deg2rad(x); + return kernelSin(rad, 0); + } + if (x <= 135) { + rad = deg2rad(x - 90); + return kernelCos(rad, 0); + } + if (x <= 225) { + rad = deg2rad(180 - x); + return kernelSin(rad, 0); + } + if (x <= 315) { + rad = deg2rad(x - 270); + return -kernelCos(rad, 0); + } + rad = deg2rad(360 - x) + return -kernelSin(rad, 0); +} + +// EXPORTS // + +module.exports = sind; \ No newline at end of file