How to use the distance function from mathjs

Find comprehensive JavaScript mathjs.distance code examples handpicked from public code repositorys.

34
35
36
37
38
39
40
41
42
43
  .map((el) => this.rayLineIntersection(ray, el))
  .map((el2) => (el2 == null ? [999999, 999999] : el2));
let min = Infinity;
let cur = null;
for (let i = 0; i < points.length; i++) {
  let dist = distance(points[i], ray.position);
  if (dist < min) {
    cur = points[i];
    min = dist;
  }
fork icon1
star icon0
watch icon0

+ 3 other calls in file

70
71
72
73
74
75
76
77
78
79
yodash.getBestAngle = (targets, position) => {
  let closest = Infinity
  let target
  targets.forEach(candidate => {
    const pos = candidate.position
    const distance = math.distance([pos.down, pos.right], [position.down, position.right])
    if (distance < closest) {
      closest = distance
      target = candidate
    }
fork icon0
star icon6
watch icon0

+ 19 other calls in file