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

@thi.ng/quad-edge

Package Overview
Dependencies
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/quad-edge - npm Package Compare versions

Comparing version 3.1.42 to 3.1.43

2

CHANGELOG.md
# Change Log
- **Last updated**: 2023-12-09T19:12:03Z
- **Last updated**: 2023-12-11T10:07:09Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -5,0 +5,0 @@

import { assert } from "@thi.ng/errors/assert";
export function defEdge(id, src, dest) {
assert((id & 3) === 0, `id must be multiple of 4`);
const quad = new Array(4);
const a = (quad[0] = new Edge(quad, id));
const b = (quad[1] = new Edge(quad, id + 1));
const c = (quad[2] = new Edge(quad, id + 2));
const d = (quad[3] = new Edge(quad, id + 3));
a.onext = a;
c.onext = c;
b.onext = d;
d.onext = b;
src && dest && a.setEnds(src, dest);
return a;
function defEdge(id, src, dest) {
assert((id & 3) === 0, `id must be multiple of 4`);
const quad = new Array(4);
const a = quad[0] = new Edge(quad, id);
const b = quad[1] = new Edge(quad, id + 1);
const c = quad[2] = new Edge(quad, id + 2);
const d = quad[3] = new Edge(quad, id + 3);
a.onext = a;
c.onext = c;
b.onext = d;
d.onext = b;
src && dest && a.setEnds(src, dest);
return a;
}
/**
* Quad-edge implementation after Guibas & Stolfi. Based on C++ versions by Paul
* Heckbert, Dani Lischinski et al:
*
* References:
*
* - http://www.cs.cmu.edu/afs/andrew/scs/cs/15-463/2001/pub/src/a2/quadedge.html
* - http://www.cs.cmu.edu/afs/andrew/scs/cs/15-463/2001/pub/src/a2/lischinski/114.ps
*/
export class Edge {
id;
parent;
origin;
constructor(parent, id) {
this.parent = parent;
this.id = id;
}
/**
* Next CCW edge from this edge's origin.
*/
onext;
/**
* Next CW edge from this edge's origin.
*/
get oprev() {
return this.rot.onext.rot;
}
/**
* Dual of this edge, right -> left.
*/
get rot() {
return this.parent[(this.id + 1) & 3];
}
/**
* Dual of this edge, left -> right.
* I.e same as `this.rot.sym`
*/
get invrot() {
return this.parent[(this.id + 3) & 3];
}
/**
* Symmetric partner edge of this edge, from dest -> src.
* I.e. `this === this.sym.sym`
*/
get sym() {
return this.parent[(this.id + 2) & 3];
}
/**
* Next CCW edge to this edge's dest.
*/
get dnext() {
return this.sym.onext.sym;
}
/**
* Next CW edge to this edge's dest.
*/
get dprev() {
return this.invrot.onext.invrot;
}
/**
* Next CCW edge around the left face (dual vertex) from this edge's
* dest.
*/
get lnext() {
return this.invrot.onext.rot;
}
/**
* Next CCW edge around the left face (dual vertex) to this edge's
* origin.
*/
get lprev() {
return this.onext.sym;
}
/**
* Next CCW edge around the right face (dual vertex) to this edge's
* dest.
*/
get rnext() {
return this.rot.onext.invrot;
}
/**
* Next CCW edge around the right face (dual vertex) to this edge's
* origin.
*/
get rprev() {
return this.sym.onext;
}
/**
* Returns this edge's dest vertex. I.e. `this.sym.origin`
*/
get dest() {
return this.sym.origin;
}
/**
* Sets the origin & dest vertices of this edge (in other words, the
* origins of this edge and `this.sym`).
*
* @param o -
* @param d -
*/
setEnds(o, d) {
this.origin = o;
this.sym.origin = d;
}
connect(e, id) {
const n = defEdge(id);
n.splice(this.lnext);
n.sym.splice(e);
n.setEnds(this.dest, e.origin);
return n;
}
swap() {
const a = this.oprev;
const b = this.sym.oprev;
this.splice(a);
this.sym.splice(b);
this.splice(a.lnext);
this.sym.splice(b.lnext);
this.setEnds(a.dest, b.dest);
}
remove() {
this.splice(this.oprev);
this.sym.splice(this.sym.oprev);
delete this.parent;
}
/**
* Modifies the edge rings around the origins of this edge and `e`,
* as well as, independently, the edge rings of both edges' left
* dual vertex. In each case, if the rings are separate, this
* operator will join them and if both rings are the same ring, they
* will be split / separated. Therefore, splice` is it's own reverse
* operator and the only operator needed to edit quad edge
* topologies.
*
* @param e -
*/
splice(e) {
const alpha = this.onext.rot;
const beta = e.onext.rot;
const t1 = e.onext;
const t2 = this.onext;
const t3 = beta.onext;
const t4 = alpha.onext;
this.onext = t1;
e.onext = t2;
alpha.onext = t3;
beta.onext = t4;
return this;
}
class Edge {
id;
parent;
origin;
constructor(parent, id) {
this.parent = parent;
this.id = id;
}
/**
* Next CCW edge from this edge's origin.
*/
onext;
/**
* Next CW edge from this edge's origin.
*/
get oprev() {
return this.rot.onext.rot;
}
/**
* Dual of this edge, right -> left.
*/
get rot() {
return this.parent[this.id + 1 & 3];
}
/**
* Dual of this edge, left -> right.
* I.e same as `this.rot.sym`
*/
get invrot() {
return this.parent[this.id + 3 & 3];
}
/**
* Symmetric partner edge of this edge, from dest -> src.
* I.e. `this === this.sym.sym`
*/
get sym() {
return this.parent[this.id + 2 & 3];
}
/**
* Next CCW edge to this edge's dest.
*/
get dnext() {
return this.sym.onext.sym;
}
/**
* Next CW edge to this edge's dest.
*/
get dprev() {
return this.invrot.onext.invrot;
}
/**
* Next CCW edge around the left face (dual vertex) from this edge's
* dest.
*/
get lnext() {
return this.invrot.onext.rot;
}
/**
* Next CCW edge around the left face (dual vertex) to this edge's
* origin.
*/
get lprev() {
return this.onext.sym;
}
/**
* Next CCW edge around the right face (dual vertex) to this edge's
* dest.
*/
get rnext() {
return this.rot.onext.invrot;
}
/**
* Next CCW edge around the right face (dual vertex) to this edge's
* origin.
*/
get rprev() {
return this.sym.onext;
}
/**
* Returns this edge's dest vertex. I.e. `this.sym.origin`
*/
get dest() {
return this.sym.origin;
}
/**
* Sets the origin & dest vertices of this edge (in other words, the
* origins of this edge and `this.sym`).
*
* @param o -
* @param d -
*/
setEnds(o, d) {
this.origin = o;
this.sym.origin = d;
}
connect(e, id) {
const n = defEdge(id);
n.splice(this.lnext);
n.sym.splice(e);
n.setEnds(this.dest, e.origin);
return n;
}
swap() {
const a = this.oprev;
const b = this.sym.oprev;
this.splice(a);
this.sym.splice(b);
this.splice(a.lnext);
this.sym.splice(b.lnext);
this.setEnds(a.dest, b.dest);
}
remove() {
this.splice(this.oprev);
this.sym.splice(this.sym.oprev);
delete this.parent;
}
/**
* Modifies the edge rings around the origins of this edge and `e`,
* as well as, independently, the edge rings of both edges' left
* dual vertex. In each case, if the rings are separate, this
* operator will join them and if both rings are the same ring, they
* will be split / separated. Therefore, splice` is it's own reverse
* operator and the only operator needed to edit quad edge
* topologies.
*
* @param e -
*/
splice(e) {
const alpha = this.onext.rot;
const beta = e.onext.rot;
const t1 = e.onext;
const t2 = this.onext;
const t3 = beta.onext;
const t4 = alpha.onext;
this.onext = t1;
e.onext = t2;
alpha.onext = t3;
beta.onext = t4;
return this;
}
}
export {
Edge,
defEdge
};
{
"name": "@thi.ng/quad-edge",
"version": "3.1.42",
"version": "3.1.43",
"description": "Quadedge data structure after Guibas & Stolfi",

@@ -27,3 +27,5 @@ "type": "module",

"scripts": {
"build": "yarn clean && tsc --declaration",
"build": "yarn build:esbuild && yarn build:decl",
"build:decl": "tsc --declaration --emitDeclarationOnly",
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
"clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",

@@ -37,6 +39,7 @@ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",

"dependencies": {
"@thi.ng/errors": "^2.4.5"
"@thi.ng/errors": "^2.4.6"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.38.3",
"esbuild": "^0.19.8",
"rimraf": "^5.0.5",

@@ -81,3 +84,3 @@ "tools": "^0.0.1",

},
"gitHead": "25f2ac8ff795a432a930119661b364d4d93b59a0\n"
"gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
}
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