How to use the @antv/matrix-util.vec2.distance function in @antv/matrix-util

To help you get started, we’ve selected a few @antv/matrix-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / G2 / src / geometry / shape / util / path.ts View on Github external
prevPoint = points[i ? i - 1 : len - 1];
      nextPoint = points[(i + 1) % len];
    } else {
      if (i === 0 || i === len - 1) {
        cps.push(point);
        continue;
      } else {
        prevPoint = points[i - 1];
        nextPoint = points[i + 1];
      }
    }
    let v = [];
    v = vec2.sub(v, nextPoint, prevPoint);
    v = vec2.scale(v, v, smooth);

    let d0 = vec2.distance(point, prevPoint);
    let d1 = vec2.distance(point, nextPoint);

    const sum = d0 + d1;
    if (sum !== 0) {
      d0 /= sum;
      d1 /= sum;
    }

    const v1 = vec2.scale([], v, -d0);
    const v2 = vec2.scale([], v, d1);

    let cp0 = vec2.add([], point, v1);
    let cp1 = vec2.add([], point, v2);

    if (hasConstraint) {
      cp0 = vec2.max([], cp0, min);
github antvis / G2 / src / geometry / shape / util / path.ts View on Github external
nextPoint = points[(i + 1) % len];
    } else {
      if (i === 0 || i === len - 1) {
        cps.push(point);
        continue;
      } else {
        prevPoint = points[i - 1];
        nextPoint = points[i + 1];
      }
    }
    let v = [];
    v = vec2.sub(v, nextPoint, prevPoint);
    v = vec2.scale(v, v, smooth);

    let d0 = vec2.distance(point, prevPoint);
    let d1 = vec2.distance(point, nextPoint);

    const sum = d0 + d1;
    if (sum !== 0) {
      d0 /= sum;
      d1 /= sum;
    }

    const v1 = vec2.scale([], v, -d0);
    const v2 = vec2.scale([], v, d1);

    let cp0 = vec2.add([], point, v1);
    let cp1 = vec2.add([], point, v2);

    if (hasConstraint) {
      cp0 = vec2.max([], cp0, min);
      cp0 = vec2.min([], cp0, max);
github antvis / G2 / packages / g2 / src / element / util / path.ts View on Github external
prevPoint = points[i ? i - 1 : len - 1];
      nextPoint = points[(i + 1) % len];
    } else {
      if (i === 0 || i === len - 1) {
        cps.push(point);
        continue;
      } else {
        prevPoint = points[i - 1];
        nextPoint = points[i + 1];
      }
    }
    let v = [];
    v = vector2.sub(v, nextPoint, prevPoint);
    v = vector2.scale(v, v, smooth);

    let d0 = vector2.distance(point, prevPoint);
    let d1 = vector2.distance(point, nextPoint);

    const sum = d0 + d1;
    if (sum !== 0) {
      d0 /= sum;
      d1 /= sum;
    }

    const v1 = vector2.scale([], v, -d0);
    const v2 = vector2.scale([], v, d1);

    let cp0 = vector2.add([], point, v1);
    let cp1 = vector2.add([], point, v2);

    if (hasConstraint) {
      cp0 = vector2.max([], cp0, min);
github antvis / G2 / src / chart / controller / tooltip.ts View on Github external
items.forEach((item) => {
          const distance = vec2.distance([point.x, point.y], [item.x, item.y]);
          if (distance < nearestDistance) {
            nearestDistance = distance;
            nearestItem = item;
          }
        });
        items = items.filter((item) => item.title === nearestItem.title);
github antvis / G2 / packages / g2 / src / element / util / path.ts View on Github external
nextPoint = points[(i + 1) % len];
    } else {
      if (i === 0 || i === len - 1) {
        cps.push(point);
        continue;
      } else {
        prevPoint = points[i - 1];
        nextPoint = points[i + 1];
      }
    }
    let v = [];
    v = vector2.sub(v, nextPoint, prevPoint);
    v = vector2.scale(v, v, smooth);

    let d0 = vector2.distance(point, prevPoint);
    let d1 = vector2.distance(point, nextPoint);

    const sum = d0 + d1;
    if (sum !== 0) {
      d0 /= sum;
      d1 /= sum;
    }

    const v1 = vector2.scale([], v, -d0);
    const v2 = vector2.scale([], v, d1);

    let cp0 = vector2.add([], point, v1);
    let cp1 = vector2.add([], point, v2);

    if (hasConstraint) {
      cp0 = vector2.max([], cp0, min);
      cp0 = vector2.min([], cp0, max);