Public
Edited
Apr 3, 2023
Importers
1 star
Insert cell
Insert cell
posInterpCircumferential = function(_centre) {
const centre = Victor.fromObject(_centre)
return function(_current_pos, _target_pos) {
const current = Victor.fromObject(_current_pos)
const target = Victor.fromObject(_target_pos)
const current_relative = current.subtract(centre)
const target_relative = target.subtract(centre)
// determine direction of rotation
const angle_delta = target_relative.angle() - current_relative.angle()
let rotation_angle = (angle_delta + Math.PI ) % (2*Math.PI) - Math.PI
rotation_angle += (rotation_angle < - Math.PI ? 2 * Math.PI : 0)
const radius_change = target_relative.length() - current_relative.length()
return function(t) {
const angle = current_relative.angle() + rotation_angle * t
const radius = current_relative.length() + radius_change * t
const pos = centre.add(Victor(radius,0).rotate(angle))
return pos.toObject()
}
}
}
Insert cell
posInterpLinear = function(_pos_old, pos_new) {
let pos_old = Victor(_pos_old.x, _pos_old.y)
return function(t) {
return pos_old.mix(pos_new, t)
}
}
Insert cell
Victor = require('https://bundle.run/victor@1.1.0')
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