robust-orientation
Version:
Exactly computes the orientation of a tuple of points
111 lines (92 loc) • 1.54 kB
JavaScript
"use strict"
var tape = require("tape")
var orientation = require("../orientation.js")
tape("2d orientation", function(t) {
t.equals(orientation(
[],
[],
[]
), 0)
t.ok(orientation(
[],
[-1e-64,0],
[]
)>0)
t.equals(orientation(
[],
[],
[]
), 0)
t.ok(orientation(
[],
[],
[]
)<0)
var x = 1e-64
for(var i=0; i<200; ++i) {
t.ok(orientation(
[-x, 0],
[],
[]
)>0)
t.equals(orientation(
[-x, 0],
[],
[]
), 0)
t.ok(orientation(
[-x, 0],
[],
[]
)<0, "x=" + x)
t.ok(orientation(
[],
[],
[]
)<0, "x=" + x)
x *= 10
}
t.end()
})
tape("3d orientation", function(t) {
t.ok(orientation(
[],
[],
[],
[]
) < 0)
t.ok(orientation(
[],
[],
[],
[]
) > 0)
t.ok(orientation(
[],
[],
[],
[]
) > 0)
t.end()
})
tape("4d orientation", function(t) {
t.ok(orientation(
[],
[],
[],
[],
[]
) > 0)
t.end()
})
tape("5d orientation", function(t) {
t.ok(orientation(
[],
[],
[],
[],
[],
[]
) > 0)
t.end()
})