ixfx
    Preparing search index...

    Function relation

    • Tracks the relation between two points.

      1. Call Points.relation with the initial reference point
      2. You get back a function
      3. Call the function with a new point to compute relational information.

      It computes angle, average, centroid, distance and speed.

      import { Points } from "https://unpkg.com/ixfx/dist/geometry.js";

      // Reference point: 50,50
      const t = Points.relation({x:50,y:50}); // t is a function

      // Invoke the returned function with a point
      const relation = t({ x:0, y:0 }); // Juicy relational data

      Or with destructuring:

      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 ...

      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

      Parameters

      • a: number | Geometry.Point

        Initial point, or x value

      • Optionalb: number

        y value, if first option is a number.

      Returns PointRelation