@flatten-js/core
Advanced tools
Comparing version 1.3.10 to 1.3.11
{ | ||
"name": "@flatten-js/core", | ||
"version": "1.3.10", | ||
"version": "1.3.11", | ||
"description": "Javascript library for 2d geometry", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.cjs.js", |
@@ -54,3 +54,3 @@ /** | ||
let ip = []; | ||
let prj = circle.pc.projectionOn(line); // projection of circle center on line | ||
let prj = circle.pc.projectionOn(line); // projection of circle center on a line | ||
let dist = circle.pc.distanceTo(prj)[0]; // distance from circle center to projection | ||
@@ -185,27 +185,17 @@ | ||
let new_ip = intersectLine2Line(line1, line2); | ||
if (new_ip.length > 0 && new_ip[0].on(seg1) && new_ip[0].on(seg2)) { | ||
ip.push(new_ip[0]); | ||
if (new_ip.length > 0) { | ||
if (isPointInSegmentBox(new_ip[0], seg1) && isPointInSegmentBox(new_ip[0], seg2)) { | ||
ip.push(new_ip[0]); | ||
} | ||
} | ||
// Fix missing intersection | ||
// const tol = 10*Flatten.DP_TOL; | ||
// if (ip.length === 0 && new_ip.length > 0 && (new_ip[0].distanceTo(seg1)[0] < tol || new_ip[0].distanceTo(seg2)[0] < tol) ) { | ||
// if (seg1.start.distanceTo(seg2)[0] < tol) { | ||
// ip.push(new_ip[0]); | ||
// } | ||
// else if (seg1.end.distanceTo(seg2)[0] < tol) { | ||
// ip.push(new_ip[0]); | ||
// } | ||
// else if (seg2.start.distanceTo(seg1)[0] < tol) { | ||
// ip.push(new_ip[0]); | ||
// } | ||
// else if (seg2.end.distanceTo(seg1)[0] < tol) { | ||
// ip.push(new_ip[0]); | ||
// } | ||
// } | ||
} | ||
return ip; | ||
} | ||
function isPointInSegmentBox(point, segment) { | ||
const box = segment.box; | ||
return Flatten.Utils.LE(point.x, box.xmax) && Flatten.Utils.GE(point.x, box.xmin) && | ||
Flatten.Utils.LE(point.y, box.ymax) && Flatten.Utils.GE(point.y, box.ymin) | ||
} | ||
export function intersectSegment2Circle(segment, circle) { | ||
@@ -220,3 +210,3 @@ let ips = []; | ||
if (segment.isZeroLength()) { | ||
let [dist, shortest_segment] = segment.ps.distanceTo(circle.pc); | ||
let [dist, _] = segment.ps.distanceTo(circle.pc); | ||
if (Flatten.Utils.EQ(dist, circle.r)) { | ||
@@ -361,3 +351,3 @@ ips.push(segment.ps); | ||
export function intersectArc2Arc(arc1, arc2) { | ||
var ip = []; | ||
let ip = []; | ||
@@ -364,0 +354,0 @@ if (arc1.box.not_intersect(arc2.box)) { |
@@ -6,3 +6,3 @@ /** | ||
import Flatten from '../flatten'; | ||
import SVGAttributes, {convertToString} from "../utils/attributes"; | ||
import {convertToString} from "../utils/attributes"; | ||
@@ -60,4 +60,10 @@ /** | ||
if (args.length === 2) { | ||
if (Decimal.isDecimal(args[0]) && Decimal.isDecimal(args[1])) { | ||
this.x = args[0]; | ||
this.y = args[1]; | ||
return; | ||
} | ||
} | ||
throw Flatten.Errors.ILLEGAL_PARAMETERS; | ||
} | ||
@@ -64,0 +70,0 @@ |
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
Sorry, the diff of this file is too big to display
5649846
36349