You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
882 B

import {deg2rad, Graph, Point, Segment, Triangle} from "./pslg";
import {delaunay, delaunayRefine} from "./delaunayRefine";
import {plotGraph} from "./viz";
import {triangulate} from "./trapezoidTriangulation";
const pa = Point.from(1, 0)
const pb = Point.from(3, 3)
const pc = Point.from(5, 2)
const pd = Point.from(4, 0)
const sA = new Segment(pa, pb)
const sB = new Segment(pb, pc)
const sC = new Segment(pc, pd)
const sD = new Segment(pd, pa)
const g = new Graph([pa, pb, pc, pd], [sA, sB, sC, sD])
console.log(g)
// plotGraph(g)
const refined = triangulate(g)
console.log(refined)
plotGraph(refined)
/*
const p1 = Point.from(1, 1)
const p2 = Point.from(5, 1)
const pLeft = Point.from(3, 3)
const pRight = Point.from(3, -3)
const seg = new Segment(p1, p2)
console.log('det of pLeft', seg.pointIsLeftOf(pLeft))
console.log('det of pRight', seg.pointIsLeftOf(pRight))*/