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 0.6.3 to 0.6.4

37

dist/euclid.cjs.js

@@ -116,2 +116,7 @@ 'use strict';

}
static random(b) {
const x = fermat.Random.uniform(b.xMin, b.xMax);
const y = fermat.Random.uniform(b.yMin, b.yMax);
return new Point(x, y);
}
// ---------------------------------------------------------------------------

@@ -185,3 +190,3 @@ /** Transforms this point using a 2x3 matrix m. */

return this;
return new this.constructor(this.c, this.end, 2 * Math.PI - this.angle);
return new this.constructor(this.c, this.end, TWO_PI - this.angle);
}

@@ -191,3 +196,3 @@ get major() {

return this;
return new this.constructor(this.c, this.end, 2 * Math.PI - this.angle);
return new this.constructor(this.c, this.end, TWO_PI - this.angle);
}

@@ -450,2 +455,13 @@ get center() {

// ---------------------------------------------------------------------------
// These functions are just included for compatibility with GeoPath
project() {
return this.c;
}
at() {
return this.c;
}
contains() {
return false;
}
// ---------------------------------------------------------------------------
transform(m) {

@@ -506,3 +522,3 @@ return new Angle(this.a.transform(m), this.b.transform(m), this.c.transform(m));

at(t) {
const a = 2 * Math.PI * t;
const a = TWO_PI * t;
return this.c.shift(this.r * Math.cos(a), this.r * Math.sin(a));

@@ -804,3 +820,3 @@ }

static regular(n, radius = 1) {
const da = 2 * Math.PI / n;
const da = TWO_PI / n;
const a0 = Math.PI / 2 - da / 2;

@@ -1036,2 +1052,11 @@ const points = core.tabulate((i) => Point.fromPolar(a0 + da * i, radius), n);

}
contains(p) {
return this.containsX(p) && this.containsY(p);
}
containsX(p) {
return fermat.isBetween(p.x, this.xMin, this.xMax);
}
containsY(p) {
return fermat.isBetween(p.y, this.yMin, this.yMax);
}
get dx() {

@@ -1074,3 +1099,3 @@ return this.xMax - this.xMin;

else if (isCircle(obj)) {
ctx.arc(obj.c.x, obj.c.y, obj.r, 0, 2 * Math.PI);
ctx.arc(obj.c.x, obj.c.y, obj.r, 0, TWO_PI);
}

@@ -1291,3 +1316,3 @@ else if (isPolygon(obj)) {

at(t) {
const th = 2 * Math.PI * t;
const th = TWO_PI * t;
return this.c.shift(this.a * Math.cos(th), this.b * Math.sin(th));

@@ -1294,0 +1319,0 @@ }

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

import { mod, nearlyEquals, clamp, roundTo, square, lerp, isBetween, subsets, quadratic } from '@mathigon/fermat';
import { mod, nearlyEquals, clamp, roundTo, square, lerp, Random, isBetween, subsets, quadratic } from '@mathigon/fermat';
import { total, flatten, last, toLinkedList, tabulate, isOneOf } from '@mathigon/core';

@@ -112,2 +112,7 @@

}
static random(b) {
const x = Random.uniform(b.xMin, b.xMax);
const y = Random.uniform(b.yMin, b.yMax);
return new Point(x, y);
}
// ---------------------------------------------------------------------------

@@ -181,3 +186,3 @@ /** Transforms this point using a 2x3 matrix m. */

return this;
return new this.constructor(this.c, this.end, 2 * Math.PI - this.angle);
return new this.constructor(this.c, this.end, TWO_PI - this.angle);
}

@@ -187,3 +192,3 @@ get major() {

return this;
return new this.constructor(this.c, this.end, 2 * Math.PI - this.angle);
return new this.constructor(this.c, this.end, TWO_PI - this.angle);
}

@@ -446,2 +451,13 @@ get center() {

// ---------------------------------------------------------------------------
// These functions are just included for compatibility with GeoPath
project() {
return this.c;
}
at() {
return this.c;
}
contains() {
return false;
}
// ---------------------------------------------------------------------------
transform(m) {

@@ -502,3 +518,3 @@ return new Angle(this.a.transform(m), this.b.transform(m), this.c.transform(m));

at(t) {
const a = 2 * Math.PI * t;
const a = TWO_PI * t;
return this.c.shift(this.r * Math.cos(a), this.r * Math.sin(a));

@@ -800,3 +816,3 @@ }

static regular(n, radius = 1) {
const da = 2 * Math.PI / n;
const da = TWO_PI / n;
const a0 = Math.PI / 2 - da / 2;

@@ -1032,2 +1048,11 @@ const points = tabulate((i) => Point.fromPolar(a0 + da * i, radius), n);

}
contains(p) {
return this.containsX(p) && this.containsY(p);
}
containsX(p) {
return isBetween(p.x, this.xMin, this.xMax);
}
containsY(p) {
return isBetween(p.y, this.yMin, this.yMax);
}
get dx() {

@@ -1070,3 +1095,3 @@ return this.xMax - this.xMin;

else if (isCircle(obj)) {
ctx.arc(obj.c.x, obj.c.y, obj.r, 0, 2 * Math.PI);
ctx.arc(obj.c.x, obj.c.y, obj.r, 0, TWO_PI);
}

@@ -1287,3 +1312,3 @@ else if (isPolygon(obj)) {

at(t) {
const th = 2 * Math.PI * t;
const th = TWO_PI * t;
return this.c.shift(this.a * Math.cos(th), this.b * Math.sin(th));

@@ -1290,0 +1315,0 @@ }

12

package.json
{
"name": "@mathigon/euclid",
"version": "0.6.3",
"version": "0.6.4",
"description": "Euclidean geometry classes and tools for JavaScript.",

@@ -36,3 +36,3 @@ "keywords": [

"@types/tape": "4.13.0",
"rollup": "2.27.1",
"rollup": "2.28.2",
"tape": "5.0.1",

@@ -42,8 +42,8 @@ "ts-node": "9.0.0",

"typescript": "4.0.3",
"@typescript-eslint/eslint-plugin": "4.1.0",
"@typescript-eslint/parser": "4.1.0",
"eslint": "7.8.1",
"@typescript-eslint/eslint-plugin": "4.3.0",
"@typescript-eslint/parser": "4.3.0",
"eslint": "7.10.0",
"eslint-config-google": "0.14.0",
"eslint-plugin-import": "2.22.0"
"eslint-plugin-import": "2.22.1"
}
}

@@ -11,7 +11,7 @@ // =============================================================================

import {Point} from './point';
import {GeoElement, SimplePoint, TransformMatrix, TWO_PI} from './utilities';
import {GeoShape, SimplePoint, TransformMatrix, TWO_PI} from './utilities';
/** A 2-dimensional angle class, defined by three points. */
export class Angle implements GeoElement {
export class Angle implements GeoShape {
readonly type = 'angle';

@@ -70,3 +70,18 @@

// ---------------------------------------------------------------------------
// These functions are just included for compatibility with GeoPath
project() {
return this.c;
}
at() {
return this.c;
}
contains() {
return false;
}
// ---------------------------------------------------------------------------
transform(m: TransformMatrix) {

@@ -73,0 +88,0 @@ return new Angle(this.a.transform(m), this.b.transform(m), this.c.transform(m));

@@ -40,4 +40,3 @@ // =============================================================================

if (this.angle <= Math.PI) return this;
return new (<any> this.constructor)(this.c, this.end,
2 * Math.PI - this.angle);
return new (<any> this.constructor)(this.c, this.end, TWO_PI - this.angle);
}

@@ -47,4 +46,3 @@

if (this.angle >= Math.PI) return this;
return new (<any> this.constructor)(this.c, this.end,
2 * Math.PI - this.angle);
return new (<any> this.constructor)(this.c, this.end, TWO_PI - this.angle);
}

@@ -51,0 +49,0 @@

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

import {isBetween} from '@mathigon/fermat';
import {Point} from './point';

@@ -18,2 +19,14 @@ import {Rectangle} from './rectangle';

contains(p: Point) {
return this.containsX(p) && this.containsY(p);
}
containsX(p: Point) {
return isBetween(p.x, this.xMin, this.xMax);
}
containsY(p: Point) {
return isBetween(p.y, this.yMin, this.yMax);
}
get dx() {

@@ -20,0 +33,0 @@ return this.xMax - this.xMin;

@@ -49,3 +49,3 @@ // =============================================================================

at(t: number) {
const a = 2 * Math.PI * t;
const a = TWO_PI * t;
return this.c.shift(this.r * Math.cos(a), this.r * Math.sin(a));

@@ -52,0 +52,0 @@ }

@@ -9,3 +9,3 @@ // =============================================================================

import {isCircle, isPolygon, isPolyline, isSegment} from './types';
import {GeoElement} from './utilities';
import {GeoElement, TWO_PI} from './utilities';

@@ -45,3 +45,3 @@

} else if (isCircle(obj)) {
ctx.arc(obj.c.x, obj.c.y, obj.r, 0, 2 * Math.PI);
ctx.arc(obj.c.x, obj.c.y, obj.r, 0, TWO_PI);

@@ -48,0 +48,0 @@ } else if (isPolygon(obj)) {

@@ -11,3 +11,3 @@ // =============================================================================

import {ORIGIN, Point} from './point';
import {GeoShape, TransformMatrix} from './utilities';
import {GeoShape, TransformMatrix, TWO_PI} from './utilities';

@@ -70,3 +70,3 @@

at(t: number) {
const th = 2 * Math.PI * t;
const th = TWO_PI * t;
return this.c.shift(this.a * Math.cos(th), this.b * Math.sin(th));

@@ -73,0 +73,0 @@ }

@@ -8,3 +8,3 @@ // =============================================================================

import {total} from '@mathigon/core';
import {nearlyEquals, roundTo, square, clamp, lerp} from '@mathigon/fermat';
import {nearlyEquals, roundTo, square, clamp, lerp, Random} from '@mathigon/fermat';
import {Bounds} from './bounds';

@@ -137,2 +137,8 @@ import {Line} from './line';

static random(b: Bounds) {
const x = Random.uniform(b.xMin, b.xMax);
const y = Random.uniform(b.yMin, b.yMax);
return new Point(x, y);
}
// ---------------------------------------------------------------------------

@@ -139,0 +145,0 @@

@@ -12,3 +12,3 @@ // =============================================================================

import {ORIGIN, Point} from './point';
import {GeoShape, TransformMatrix} from './utilities';
import {GeoShape, TransformMatrix, TWO_PI} from './utilities';

@@ -141,3 +141,3 @@

static regular(n: number, radius = 1) {
const da = 2 * Math.PI / n;
const da = TWO_PI / n;
const a0 = Math.PI / 2 - da / 2;

@@ -144,0 +144,0 @@

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