Tracks the relation between two points.
Points.relation
It computes angle, average, centroid, distance and speed.
import { Points } from "https://unpkg.com/ixfx/dist/geometry.js";// Reference point: 50,50const t = Points.relation({x:50,y:50}); // t is a function// Invoke the returned function with a pointconst relation = t({ x:0, y:0 }); // Juicy relational data Copy
import { Points } from "https://unpkg.com/ixfx/dist/geometry.js";// Reference point: 50,50const t = Points.relation({x:50,y:50}); // t is a function// Invoke the returned function with a pointconst relation = t({ x:0, y:0 }); // Juicy relational data
Or with destructuring:
const { angle, distanceFromStart, distanceFromLast, average, centroid, speed } = t({ x:0,y:0 }); Copy
const { angle, distanceFromStart, distanceFromLast, average, centroid, speed } = t({ x:0,y:0 });
x & y coordinates can also be used as parameters:
const t = Points.relation(50, 50);const result = t(0, 0);// result.speed, result.angle ... Copy
const t = Points.relation(50, 50);const result = t(0, 0);// result.speed, result.angle ...
Note that intermediate values are not stored. It keeps the initial and most-recent point. If you want to compute something over a set of prior points, you may want to use Trackers.points
Initial point, or x value
Optional
y value, if first option is a number.
Tracks the relation between two points.
Points.relation
with the initial reference pointIt computes angle, average, centroid, distance and speed.
Or with destructuring:
x & y coordinates can also be used as parameters:
Note that intermediate values are not stored. It keeps the initial and most-recent point. If you want to compute something over a set of prior points, you may want to use Trackers.points