Published
Edited
Feb 23, 2018
8 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rotateVector = (vector, theta) => {
const { x, y } = vector
// first column of the matrix
const xa = x * Math.cos(theta)
const xb = x * Math.sin(theta)
// second column of the matrix
const yc = y * -Math.sin(theta)
const yd = y * Math.cos(theta)
// sum the components
return {
x: xa + yc,
y: xb + yd
}
}
Insert cell
resultA = rotateVector({ x: 1, y: 0 }, theta)
Insert cell
resultB = rotateVector({ x: 0, y: 1 }, theta)
Insert cell
resultC = rotateVector({ x: 1, y: 1 }, theta)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more