SYNCERのロゴ
アイキャッチ画像

Math.cos() - 余弦(コサイン)

Math.cos()は、余弦(コサイン)を求めるメソッドです。引数にラジアン単位の角度を指定すると、コサイン(-1〜1の比率)を計算して返します。

概要

名前
cos
所属
Math
仕様書
https://tc39.github.io/ecma262/#sec-math.cos

説明

Math.cos ( x )

xの余弦の実装依存の近似値を返します。 引数はラジアン単位で表されます。

  • xがNaNの場合、NaNを返します。
  • xが+0の場合、1を返します。
  • xが-0の場合、1を返します。
  • xが+Infinityの場合、+NaNを返します。
  • xが-Infinityの場合、-NaNを返します。

デモ

Math.cos()のデモです。

<!-- このコードは編集できます。 -->

<!DOCTYPE html>
<html>
<head>
	<style>
body {
	white-space: pre-wrap ;
}
	</style>
</head>
<body>
<script>
/** try it! **/
var a = Math.cos( 0 ) ;
var b = Math.cos( -1 ) ;
var c = Math.cos( 1 ) ;
var d = Math.cos( NaN ) ;
var e = Math.cos( Infinity ) ;
/** try it! **/

var results = { a:a, b:b, c:c, d:d, e:e, } ;

for( var name in results ) {
	console.log( name, results[name] ) ;
	document.body.appendChild( new Text( name + " = " + results[name] + "\n" ) ) ;
}
</script>
</body>
</html>

サポート状況

ChromeFirefoxSafariEdgeIEOperaiOS SafariAndroid
  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2017年9月25日 (月)
コンテンツを公開しました。