sin【サイン (正弦):sine】メソッド
cos【コサイン (余弦):cosine】メソッド
tan【タンジェント (正接):tangent】メソッド
メモ
- 三角関数:サイン 【正弦】・コサイン 【余弦】・タンジェント 【正接】
Math.sin【サイン (正弦):sine】メソッド
構文
- sin(x)
- x:角度 (ラジアン単位)
サイン (-1 ~ 1)
| x | 戻り値 |
|---|---|
| NaN | NaN |
| +0 | +0 |
| -0 | -0 |
| +∞ | NaN |
| -∞ | NaN |
例
グラフ表示
console.log(Math.sin(Math.PI / 2)); // 出力:1
console.log(Math.sin(Math.PI * 1.5)); // 出力:-1
console.log(Math.sin(NaN)); // 出力:NaN
console.log(Math.sin(+0)); // 出力:0
console.log(Math.sin(-0)); // 出力:-0
console.log(Math.sin(+Infinity)); // 出力:NaN
console.log(Math.sin(-Infinity)); // 出力:NaN
Math.cos【コサイン (余弦):cosine】メソッド
構文
- cos(x)
- x:角度 (ラジアン単位)
コサイン (-1 ~ 1)
| x | 戻り値 |
|---|---|
| NaN | NaN |
| +0 | 1 |
| -0 | 1 |
| +∞ | NaN |
| -∞ | NaN |
例
グラフ表示
console.log(Math.cos(Math.PI)); // 出力:-1
console.log(Math.cos(Math.PI * 2)); // 出力:1
console.log(Math.cos(NaN)); // 出力:NaN
console.log(Math.cos(+0)); // 出力:1
console.log(Math.cos(-0)); // 出力:1
console.log(Math.cos(+Infinity)); // 出力:NaN
console.log(Math.cos(-Infinity)); // 出力:NaN
Math.tan【タンジェント (正接):tangent】メソッド
構文
- tan(x)
- x:角度 (ラジアン単位)
タンジェント (-1 ~ 1)
| x | 戻り値 |
|---|---|
| NaN | NaN |
| +0 | +0 |
| -0 | -0 |
| +∞ | NaN |
| -∞ | NaN |
例
グラフ表示
console.log(Math.tan(Math.PI / 4)); // 出力:≒1
console.log(Math.tan(Math.PI)); // 出力:≒0
console.log(Math.tan(NaN)); // 出力:NaN
console.log(Math.tan(+0)); // 出力:0
console.log(Math.tan(-0)); // 出力:-0
console.log(Math.tan(+Infinity)); // 出力:NaN
console.log(Math.tan(-Infinity)); // 出力:NaN
関連
- PI【円周率 (π)】
- asin【アークサイン (逆正弦)】 ・acos【アークコサイン (逆余弦)】 ・atan【アークタンジェント (逆正接)】 ・atan2【y/x のアークタンジェント (逆正接)】
- ECMAScript 5.1 (英語)
- ECMAScript 2015 (6) (英語)
- ECMAScript 2016 (7) (英語)