Published
Edited
Jan 20, 2021
1 fork
1 star
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
p = {
const p0 = anchor

const p1 = [
p0[0] + coxa * Math.cos(ro + teta),
p0[1] + coxa * Math.sin(ro + teta),
p0[2]
]

const p2 = [
p1[0] + femur * Math.cos(beta) * Math.cos(ro + teta),
p1[1] + femur * Math.cos(beta) * Math.sin(ro + teta),
p1[2] + femur * Math.sin(beta),
]

const omega = alpha - (Math.PI/2 - beta)
const Z = - tibia * Math.cos(omega)
const R = tibia * Math.sin(omega)

const p3 = [
p2[0] + tibia * Math.sin(alpha - (Math.PI/2 - beta)) * Math.cos(ro + teta),
p2[1] + tibia * Math.sin(alpha - (Math.PI/2 - beta)) * Math.sin(ro + teta),
p2[2] - tibia * Math.cos(alpha - (Math.PI/2 - beta))
]

return [p0, p1, p2, p3]
}
Insert cell
Insert cell
function setTipPos ([x, y, z]) {
const diffX = x - anchor[0]
const diffY = y - anchor[1]
const diffZ = z - anchor[2]

const rotatedX = diffX * Math.cos(ro) + diffY * Math.sin(ro)
const rotatedY = diffY * Math.cos(ro) - diffX * Math.sin(ro)

const r = Math.sqrt(Math.pow(rotatedY, 2) + Math.pow(rotatedX, 2))
const p = r - coxa
const u = Math.sqrt(Math.pow(p, 2) + Math.pow(diffZ, 2))
const gama = p > 0 ? Math.atan(-diffZ / p) : Math.PI + Math.atan(-diffZ / p)

return [
Math.atan(rotatedY / rotatedX),
Math.acos((Math.pow(u, 2) + Math.pow(femur, 2) - Math.pow(tibia, 2)) / (2 * femur * u)) - gama,
Math.acos((Math.pow(tibia, 2) + Math.pow(femur, 2) - Math.pow(u, 2)) / (2 * tibia * femur))
]
}
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