Published
Edited
Jun 24, 2020
Importers
3 stars
Insert cell
Insert cell
// Returns the length of the longest side (hypotenuse) of a right-angled triangle,
// based on the length of the other two sides
function triangleHypotenuse(sideA, sideB) {
return Math.sqrt(Math.pow(sideA, 2) + Math.pow(sideB, 2));
}
Insert cell
//returns the height of an equilateral triangle based on the width of the base
function equilateralHeight(width) {
return Math.sqrt(width * width - ((width / 2) * width) / 2);
}
Insert cell
function angleTan(opposite, adjacent) {
return Math.atan(opposite / adjacent);
}
Insert cell
//returns the length of the opposite side to the angle, using the hypotenuse's length
function oppositeSin(angle, hypotenuse) {
return Math.sin(angle) * hypotenuse;
}
Insert cell
//returns the length of the adjacent side to the angle, using the hypotenuse's length
function adjacentCos(angle, hypotenuse) {
return Math.cos(angle) * hypotenuse;
}
Insert cell
//returns the length of the opposite side to the angle, using the adjacent side's length
function oppositeTan(angle, adjacent) {
return Math.tan(angle) * adjacent;
}
Insert cell
//returns the length of the adjacent side to the angle, using the opposite's length
function adjacentTan(angle, opposite) {
return opposite / Math.tan(angle);
}
Insert cell
//returns the length of the unknown side of a right angle triangle, using the other two sides' lengths
function triangleSide(sideA, sideB) {
var hypothenuse, shorterSide;
if (sideA > sideB) {
hypothenuse = sideA;
shorterSide = sideB;
} else {
hypothenuse = sideB;
shorterSide = sideA;
}
return Math.sqrt(Math.pow(hypothenuse, 2) - Math.pow(shorterSide, 2));
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more