@stdlib/math-base-special-sincosd
v0.1.1
Published
Simultaneously compute the sine and cosine of an angle measured in degrees.
Readme
sincosd
Simultaneously compute the sine and cosine of an angle measured in degrees.
Installation
npm install @stdlib/math-base-special-sincosdUsage
var sincosd = require( '@stdlib/math-base-special-sincosd' );sincosd( x )
Simultaneously computes the sine and cosine of an angle measured in degrees.
var v = sincosd( 0.0 );
// returns [ ~0.0, ~1.0 ]
v = sincosd( 90.0 );
// returns [ ~1.0, ~0.0 ]
v = sincosd( -30.0 );
// returns [ ~-0.5, ~0.866 ]sincosd.assign( x, out, stride, offset )
Simultaneously computes the sine and cosine of an angle measured in degrees and assigns the results to a provided output array.
var Float64Array = require( '@stdlib/array-float64' );
var out = new Float64Array( 2 );
var v = sincosd.assign( 0.0, out, 1, 0 );
// returns <Float64Array>[ ~0.0, ~1.0 ]
var bool = ( v === out );
// returns trueExamples
var linspace = require( '@stdlib/array-base-linspace' );
var sincosd = require( '@stdlib/math-base-special-sincosd' );
var x = linspace( 0.0, 180.0, 100 );
var y;
var i;
for ( i = 0; i < x.length; i++ ) {
y = sincosd( x[ i ] );
console.log( 'sincosd(%d) = [ %d, %d ]', x[ i ], y[ 0 ], y[ 1 ] );
}C APIs
Usage
#include "stdlib/math/base/special/sincosd.h"stdlib_base_sincosd( x, &sine, &cosine )
Simultaneously computes the sine and cosine of an angle measured in degrees.
double cosine;
double sine;
stdlib_base_sincosd( 4.0, &sine, &cosine );The function accepts the following arguments:
- x:
[in] doubleinput value. - sine:
[out] double*destination for the sine. - cosine:
[out] double*destination for the cosine.
void stdlib_base_sincosd( const double x, double *sine, double *cosine );Examples
#include "stdlib/math/base/special/sincosd.h"
#include <stdio.h>
int main( void ) {
const double x[] = { 0.0, 90.0, 180.0, 360.0 };
double cosine;
double sine;
int i;
for ( i = 0; i < 4; i++ ) {
stdlib_base_sincosd( x[ i ], &sine, &cosine );
printf( "x: %lf => sine: %lf, cosine: %lf\n", x[ i ], sine, cosine );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
