How to use the @mathigon/fermat.Point.sum function in @mathigon/fermat

To help you get started, we’ve selected a few @mathigon/fermat 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 mathigon / boost.js / src / svg.ts View on Github external
function drawAngle(angle: Angle, options: SVGDrawingOptions = {}) {
  let a = angle.a;
  const b = angle.b;
  let c = angle.c;

  const size = options.size || angleSize(angle, options);

  const ba = Point.difference(a, b).unitVector;
  const bc = Point.difference(c, b).unitVector;

  a = Point.sum(b, ba.scale(size));
  c = Point.sum(b, bc.scale(size));

  let p = options.fill ? `M${b.x},${b.y}L` : 'M';

  if (angle.isRight && !options.round) {
    const d = Point.sum(a, bc.scale(size));
    p += `${a.x},${a.y}L${d.x},${d.y}L${c.x},${c.y}`;
  } else {
    p += drawArc(a, b, c);
  }

  if (options.fill) p += 'Z';
  return p;
}
github mathigon / boost.js / src / svg.ts View on Github external
let a = angle.a;
  const b = angle.b;
  let c = angle.c;

  const size = options.size || angleSize(angle, options);

  const ba = Point.difference(a, b).unitVector;
  const bc = Point.difference(c, b).unitVector;

  a = Point.sum(b, ba.scale(size));
  c = Point.sum(b, bc.scale(size));

  let p = options.fill ? `M${b.x},${b.y}L` : 'M';

  if (angle.isRight && !options.round) {
    const d = Point.sum(a, bc.scale(size));
    p += `${a.x},${a.y}L${d.x},${d.y}L${c.x},${c.y}`;
  } else {
    p += drawArc(a, b, c);
  }

  if (options.fill) p += 'Z';
  return p;
}
github mathigon / boost.js / src / svg.ts View on Github external
function drawAngle(angle: Angle, options: SVGDrawingOptions = {}) {
  let a = angle.a;
  const b = angle.b;
  let c = angle.c;

  const size = options.size || angleSize(angle, options);

  const ba = Point.difference(a, b).unitVector;
  const bc = Point.difference(c, b).unitVector;

  a = Point.sum(b, ba.scale(size));
  c = Point.sum(b, bc.scale(size));

  let p = options.fill ? `M${b.x},${b.y}L` : 'M';

  if (angle.isRight && !options.round) {
    const d = Point.sum(a, bc.scale(size));
    p += `${a.x},${a.y}L${d.x},${d.y}L${c.x},${c.y}`;
  } else {
    p += drawArc(a, b, c);
  }

  if (options.fill) p += 'Z';
  return p;
}