Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mathigon/euclid

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mathigon/euclid - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

4

dist/angle.d.ts

@@ -19,2 +19,4 @@ import { Arc } from './arc';

static fromRadians(val: number): Angle;
/** Checks if `a` and `b` are roughly equivalent (by default, within one degree of eachother) */
static equals(a: Angle, b: Angle, precision?: number): boolean;
/** The size, in radians, of this angle. */

@@ -46,4 +48,4 @@ get rad(): number;

translate(p: SimplePoint): Angle;
equals(_a: Angle): boolean;
equals(a: Angle, precision?: number): boolean;
toString(): string;
}

@@ -0,1 +1,2 @@

import { Rectangle } from './rectangle';
import { GeoElement } from './utilities';

@@ -9,2 +10,3 @@ export interface CanvasDrawingOptions {

lineJoin?: CanvasLineJoin;
box?: Rectangle;
}

@@ -11,0 +13,0 @@ declare type CanvasLineCap = 'butt' | 'round' | 'square';

@@ -0,1 +1,2 @@

"use strict";
var __defProp = Object.defineProperty;

@@ -291,3 +292,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

get perpendicularVector() {
return new Point(this.p2.y - this.p1.y, this.p1.x - this.p2.x).unitVector;
return new Point(
this.p2.y - this.p1.y,
this.p1.x - this.p2.x
).unitVector;
}

@@ -329,3 +333,6 @@ parallel(p) {

transform(m) {
return new this.constructor(this.p1.transform(m), this.p2.transform(m));
return new this.constructor(
this.p1.transform(m),
this.p2.transform(m)
);
}

@@ -543,3 +550,7 @@ rotate(a, c = ORIGIN) {

transform(m) {
return new this.constructor(this.c.transform(m), this.start.transform(m), this.angle);
return new this.constructor(
this.c.transform(m),
this.start.transform(m),
this.angle
);
}

@@ -549,12 +560,28 @@ rotate(a, c = ORIGIN) {

return this;
return new this.constructor(this.c.rotate(a, c), this.start.rotate(a, c), this.angle);
return new this.constructor(
this.c.rotate(a, c),
this.start.rotate(a, c),
this.angle
);
}
reflect(l) {
return new this.constructor(this.c.reflect(l), this.start.reflect(l), this.angle);
return new this.constructor(
this.c.reflect(l),
this.start.reflect(l),
this.angle
);
}
scale(sx, sy = sx) {
return new this.constructor(this.c.scale(sx, sy), this.start.scale(sx, sy), this.angle);
return new this.constructor(
this.c.scale(sx, sy),
this.start.scale(sx, sy),
this.angle
);
}
shift(x, y = x) {
return new this.constructor(this.c.shift(x, y), this.start.shift(x, y), this.angle);
return new this.constructor(
this.c.shift(x, y),
this.start.shift(x, y),
this.angle
);
}

@@ -813,3 +840,3 @@ translate(p) {

if (ev.isStart) {
let checkBothIntersections = function() {
let checkBothIntersections2 = function() {
if (above) {

@@ -824,6 +851,7 @@ const eve2 = checkIntersection(eventRoot, ev, above);

};
var checkBothIntersections = checkBothIntersections2;
const surrounding = statusRoot.findTransition((here) => statusCompare(ev, here.ev) > 0);
const above = (_a = surrounding.before) == null ? void 0 : _a.ev;
const below = (_b = surrounding.after) == null ? void 0 : _b.ev;
const eve = checkBothIntersections();
const eve = checkBothIntersections2();
if (eve) {

@@ -1286,3 +1314,5 @@ if (selfIntersection) {

static interpolate(p1, p2, t = 0.5) {
const points = p1.points.map((p, i) => Point.interpolate(p, p2.points[i], t));
const points = p1.points.map(
(p, i) => Point.interpolate(p, p2.points[i], t)
);
return new Polygon(...points);

@@ -1482,2 +1512,5 @@ }

}
static equals(a, b, precision = Math.PI / 360) {
return (0, import_fermat9.nearlyEquals)(a.rad, b.rad, precision);
}
get rad() {

@@ -1570,4 +1603,4 @@ const phiA = Math.atan2(this.a.y - this.b.y, this.a.x - this.b.x);

}
equals(_a) {
return false;
equals(a, precision) {
return Angle.equals(a, this, precision);
}

@@ -1743,2 +1776,12 @@ toString() {

ctx.lineTo(obj.p2.x, obj.p2.y);
} else if (isLineLike(obj)) {
if (!options.box)
return;
let [start, end] = intersections(obj, options.box);
if (isRay(obj))
end = obj.p1;
if (!start || !end)
return;
ctx.moveTo(start.x, start.y);
ctx.lineTo(end.x, end.y);
} else if (isCircle(obj)) {

@@ -1786,5 +1829,13 @@ ctx.arc(obj.c.x, obj.c.y, obj.r, 0, TWO_PI);

case "arrow":
return drawPath(m.add(n.inverse).add(p), m.add(n), m.add(n.inverse).add(p.inverse));
return drawPath(
m.add(n.inverse).add(p),
m.add(n),
m.add(n.inverse).add(p.inverse)
);
case "arrow2":
return drawPath(m.add(n.scale(-2)).add(p), m, m.add(n.scale(-2)).add(p.inverse)) + drawPath(m.add(p), m.add(n.scale(2)), m.add(p.inverse));
return drawPath(
m.add(n.scale(-2)).add(p),
m,
m.add(n.scale(-2)).add(p.inverse)
) + drawPath(m.add(p), m.add(n.scale(2)), m.add(p.inverse));
default:

@@ -1791,0 +1842,0 @@ return "";

@@ -227,3 +227,6 @@ // src/angle.ts

get perpendicularVector() {
return new Point(this.p2.y - this.p1.y, this.p1.x - this.p2.x).unitVector;
return new Point(
this.p2.y - this.p1.y,
this.p1.x - this.p2.x
).unitVector;
}

@@ -265,3 +268,6 @@ parallel(p) {

transform(m) {
return new this.constructor(this.p1.transform(m), this.p2.transform(m));
return new this.constructor(
this.p1.transform(m),
this.p2.transform(m)
);
}

@@ -479,3 +485,7 @@ rotate(a, c = ORIGIN) {

transform(m) {
return new this.constructor(this.c.transform(m), this.start.transform(m), this.angle);
return new this.constructor(
this.c.transform(m),
this.start.transform(m),
this.angle
);
}

@@ -485,12 +495,28 @@ rotate(a, c = ORIGIN) {

return this;
return new this.constructor(this.c.rotate(a, c), this.start.rotate(a, c), this.angle);
return new this.constructor(
this.c.rotate(a, c),
this.start.rotate(a, c),
this.angle
);
}
reflect(l) {
return new this.constructor(this.c.reflect(l), this.start.reflect(l), this.angle);
return new this.constructor(
this.c.reflect(l),
this.start.reflect(l),
this.angle
);
}
scale(sx, sy = sx) {
return new this.constructor(this.c.scale(sx, sy), this.start.scale(sx, sy), this.angle);
return new this.constructor(
this.c.scale(sx, sy),
this.start.scale(sx, sy),
this.angle
);
}
shift(x, y = x) {
return new this.constructor(this.c.shift(x, y), this.start.shift(x, y), this.angle);
return new this.constructor(
this.c.shift(x, y),
this.start.shift(x, y),
this.angle
);
}

@@ -749,3 +775,3 @@ translate(p) {

if (ev.isStart) {
let checkBothIntersections = function() {
let checkBothIntersections2 = function() {
if (above) {

@@ -760,6 +786,7 @@ const eve2 = checkIntersection(eventRoot, ev, above);

};
var checkBothIntersections = checkBothIntersections2;
const surrounding = statusRoot.findTransition((here) => statusCompare(ev, here.ev) > 0);
const above = (_a = surrounding.before) == null ? void 0 : _a.ev;
const below = (_b = surrounding.after) == null ? void 0 : _b.ev;
const eve = checkBothIntersections();
const eve = checkBothIntersections2();
if (eve) {

@@ -1222,3 +1249,5 @@ if (selfIntersection) {

static interpolate(p1, p2, t = 0.5) {
const points = p1.points.map((p, i) => Point.interpolate(p, p2.points[i], t));
const points = p1.points.map(
(p, i) => Point.interpolate(p, p2.points[i], t)
);
return new Polygon(...points);

@@ -1418,2 +1447,5 @@ }

}
static equals(a, b, precision = Math.PI / 360) {
return nearlyEquals8(a.rad, b.rad, precision);
}
get rad() {

@@ -1506,4 +1538,4 @@ const phiA = Math.atan2(this.a.y - this.b.y, this.a.x - this.b.x);

}
equals(_a) {
return false;
equals(a, precision) {
return Angle.equals(a, this, precision);
}

@@ -1679,2 +1711,12 @@ toString() {

ctx.lineTo(obj.p2.x, obj.p2.y);
} else if (isLineLike(obj)) {
if (!options.box)
return;
let [start, end] = intersections(obj, options.box);
if (isRay(obj))
end = obj.p1;
if (!start || !end)
return;
ctx.moveTo(start.x, start.y);
ctx.lineTo(end.x, end.y);
} else if (isCircle(obj)) {

@@ -1722,5 +1764,13 @@ ctx.arc(obj.c.x, obj.c.y, obj.r, 0, TWO_PI);

case "arrow":
return drawPath(m.add(n.inverse).add(p), m.add(n), m.add(n.inverse).add(p.inverse));
return drawPath(
m.add(n.inverse).add(p),
m.add(n),
m.add(n.inverse).add(p.inverse)
);
case "arrow2":
return drawPath(m.add(n.scale(-2)).add(p), m, m.add(n.scale(-2)).add(p.inverse)) + drawPath(m.add(p), m.add(n.scale(2)), m.add(p.inverse));
return drawPath(
m.add(n.scale(-2)).add(p),
m,
m.add(n.scale(-2)).add(p.inverse)
) + drawPath(m.add(p), m.add(n.scale(2)), m.add(p.inverse));
default:

@@ -1727,0 +1777,0 @@ return "";

{
"name": "@mathigon/euclid",
"version": "1.1.1",
"version": "1.1.2",
"license": "MIT",

@@ -35,17 +35,17 @@ "homepage": "https://mathigon.io/euclid",

"dependencies": {
"@mathigon/core": "1.1.1",
"@mathigon/fermat": "1.1.1"
"@mathigon/core": "1.1.2",
"@mathigon/fermat": "1.1.2"
},
"devDependencies": {
"@types/tape": "4.13.2",
"@typescript-eslint/eslint-plugin": "5.21.0",
"@typescript-eslint/parser": "5.21.0",
"esbuild": "0.14.38",
"eslint": "8.14.0",
"@typescript-eslint/eslint-plugin": "5.36.1",
"@typescript-eslint/parser": "5.36.1",
"esbuild": "0.15.6",
"eslint": "8.22.0",
"eslint-plugin-import": "2.26.0",
"tape": "5.5.3",
"ts-node": "10.7.0",
"tape": "5.6.0",
"ts-node": "10.9.1",
"tslib": "2.4.0",
"typescript": "4.6.4"
"typescript": "4.8.2"
}
}

@@ -45,2 +45,7 @@ // =============================================================================

/** Checks if `a` and `b` are roughly equivalent (by default, within one degree of eachother) */
static equals(a: Angle, b: Angle, precision = Math.PI / 360) {
return nearlyEquals(a.rad, b.rad, precision);
}
/** The size, in radians, of this angle. */

@@ -168,5 +173,4 @@ get rad() {

equals(_a: Angle) {
// TODO Implement
return false;
equals(a: Angle, precision?: number) {
return Angle.equals(a, this, precision);
}

@@ -173,0 +177,0 @@

@@ -7,3 +7,5 @@ // =============================================================================

import {isAngle, isCircle, isEllipse, isPolygonLike, isPolyline, isSegment} from './types';
import {intersections} from './intersection';
import {Rectangle} from './rectangle';
import {isAngle, isCircle, isEllipse, isLineLike, isPolygonLike, isPolyline, isRay, isSegment} from './types';
import {GeoElement, TWO_PI} from './utilities';

@@ -19,2 +21,3 @@

lineJoin?: CanvasLineJoin;
box?: Rectangle;
}

@@ -45,2 +48,10 @@

} else if (isLineLike(obj)) {
if (!options.box) return;
let [start, end] = intersections(obj, options.box);
if (isRay(obj)) end = obj.p1;
if (!start || !end) return;
ctx.moveTo(start.x, start.y);
ctx.lineTo(end.x, end.y);
} else if (isCircle(obj)) {

@@ -47,0 +58,0 @@ ctx.arc(obj.c.x, obj.c.y, obj.r, 0, TWO_PI);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc