@flatten-js/core
Advanced tools
Comparing version 1.2.5 to 1.2.6
{ | ||
"name": "@flatten-js/core", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"description": "Javascript library for 2d geometry", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.cjs.js", |
@@ -11,2 +11,3 @@ /** | ||
import * as Intersection from "../algorithms/intersection"; | ||
import * as Relations from "../algorithms/relation"; | ||
@@ -371,10 +372,5 @@ /** | ||
} | ||
if (shape instanceof Flatten.Segment || shape instanceof Flatten.Arc) { | ||
let edge = new Flatten.Edge(shape); | ||
let rel = edge.setInclusion(this); | ||
return rel === Flatten.INSIDE || rel === Flatten.BOUNDARY; | ||
else { | ||
return Relations.cover(this, shape); | ||
} | ||
// TODO: support Box and Circle | ||
} | ||
@@ -381,0 +377,0 @@ |
@@ -228,2 +228,34 @@ /** | ||
}); | ||
it('Can check if contour contains segment (issue #31)', function() { | ||
const points = [ | ||
point(306, 306), | ||
point(647, 211), | ||
point(647, 109), | ||
point(147, 109), | ||
point(147, 491), | ||
point(600, 491), | ||
point(600, 401), | ||
point(379, 401), | ||
]; | ||
const poly = new Polygon(points); | ||
const lineA = line(point(550, 491), point(500, 401)); | ||
const lineB = line(point(520, 491), point(500, 401)); | ||
const intersectPointsA = poly.intersect(lineA); | ||
const intersectPointsB = poly.intersect(lineB); | ||
// const constSegmentOutA = new Segment(intersectPointsA[1], intersectPointsA[3]); | ||
expect(poly.contains(segment(intersectPointsA[0], intersectPointsA[1]))).to.be.true; | ||
expect(poly.contains(segment(intersectPointsA[1], intersectPointsA[2]))).to.be.false; | ||
expect(poly.contains(segment(intersectPointsA[2], intersectPointsA[3]))).to.be.true; | ||
expect(poly.contains(segment(intersectPointsA[0], intersectPointsA[2]))).to.be.false; | ||
expect(poly.contains(segment(intersectPointsA[1], intersectPointsA[3]))).to.be.false; | ||
expect(poly.contains(segment(intersectPointsB[0], intersectPointsB[1]))).to.be.true; | ||
expect(poly.contains(segment(intersectPointsB[1], intersectPointsB[2]))).to.be.false; | ||
expect(poly.contains(segment(intersectPointsB[2], intersectPointsB[3]))).to.be.true; | ||
expect(poly.contains(segment(intersectPointsB[0], intersectPointsB[2]))).to.be.false; | ||
expect(poly.contains(segment(intersectPointsB[1], intersectPointsB[3]))).to.be.false; | ||
expect(poly.contains(segment(intersectPointsA[2], intersectPointsB[3]))).to.be.true; | ||
expect(poly.contains(segment(intersectPointsA[2], intersectPointsB[2]))).to.be.true; | ||
}); | ||
it('Can measure distance between circle and polygon', function () { | ||
@@ -230,0 +262,0 @@ let points = [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5169158
32542