Browse Source

Move predicate functions in Segment after the instanciators

better-rectangles
Tissevert 11 months ago
parent
commit
155f7471a8
  1. 18
      js/Geometry/Segment.js

18
js/Geometry/Segment.js

@ -5,15 +5,6 @@ return {
oNorm: oNorm
}
function contains(segmentA, segmentB) {
return segmentA.min <= segmentB.min && segmentB.max <= segmentA.max;
}
function intersects(segmentA, segmentB) {
return segmentA.min <= segmentB.min && segmentB.min <= segmentA.max
|| segmentB.min <= segmentA.min && segmentA.min <= segmentB.max;
}
function make(o) {
if(o.origin != undefined && o.norm != undefined) {
return {min: o.origin, max: o.origin + o.norm};
@ -25,3 +16,12 @@ function make(o) {
function oNorm(o, norm) {
return {o: 1*o + Math.min(0, 1*norm), norm: Math.abs(1*norm)};
}
function contains(segmentA, segmentB) {
return segmentA.min <= segmentB.min && segmentB.max <= segmentA.max;
}
function intersects(segmentA, segmentB) {
return segmentA.min <= segmentB.min && segmentB.min <= segmentA.max
|| segmentB.min <= segmentA.min && segmentA.min <= segmentB.max;
}
Loading…
Cancel
Save