Languages
[Edit]
PL

JavaScript - Math.sin w stopniach

1 points
Created by:
Sylwia
1337

W JavaScript metoda Math.sin() domy┼Ťlnie u┼╝ywa radian├│w. Aby prze┼é─ůczy─ç go na stopnie, konieczna jest prosta operacja ((Math.PI / 180) * stopnie). W tym artykule mo┼╝emy zobaczy─ç niestandardow─ů funkcj─Ö Math.sin(), kt├│ra dzia┼éa na stopniach.

// ONLINE-RUNNER:browser;

function calculateSine(deg) {
	var radians = (Math.PI / 180) * deg;
  
  	return Math.sin(radians);
}

// Example:

console.log( calculateSine(0)   ); //  0
console.log( calculateSine(30)  ); // ~0.5
console.log( calculateSine(45)  ); //  0.7071067811865475
console.log( calculateSine(60)  ); //  0.8660254037844386
console.log( calculateSine(90)  ); //  1

console.log( calculateSine(180) ); // ~0
console.log( calculateSine(270) ); // -1
console.log( calculateSine(360) ); // ~0

Zobacz r├│wnie┼╝

  1. JavaScript - Math.sin() - przyk┼éad metody z dokumentacj─ů
Hey ­čĹő
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.