1.0.1 • Published 8 years ago

line-segment-ops v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

line-segment-ops

Set Theory and Topological Relationships on Line Segments

Installation

Install with npm.

npm install --save line-segment-ops

Examples

Create Interval

Interval = require('line-interval-ops')

i = new Interval("1,2")             #from string
i = new Interval("1 2")             #from string
i = new Interval("1;2")             #from string

i = new Interval([1,2])             #from array

i = new Interval from: 1, to:2      #object
i = new Interval start: 1, end:2    #object
i = new Interval a: 1, b:2          #object

i = new Interval(1,2)               #from two numbers

##Spatial Relationships

I = require('line-interval-ops')

I(2, 8).within(I(1, 10))    #true
I(2, 8).within(I(1, 10))    #false, endpoints touching

I(1,1)                      #degenerate => true

I(2, 8).within(I(1, 10))    #disjoint => true

#Set Operations

Union

I(1, 10).union I(6, 13), I(3, 9)
# => I(1, 13)
I(1, 10).union I(12, 15)
# => [I(1, 10), I(12, 15)]

XOR

I(1, 10).xor I(6, 12)
# => [ I(1, 6), I(10, 12)]

API

ClassSummary
IntervalThe Interval class represents a line segment on the the number line.

IntervalCLASS

1.0.1

8 years ago

1.0.0

8 years ago

0.1.0

8 years ago