StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
StackGenVis/frontend/node_modules/compare-angle/cmpangle.js

85 lines
1.7 KiB

"use strict"
module.exports = compareAngle
var orient = require("robust-orientation")
var sgn = require("signum")
var twoSum = require("two-sum")
var robustProduct = require("robust-product")
var robustSum = require("robust-sum")
function testInterior(a, b, c) {
var x0 = twoSum(a[0], -b[0])
var y0 = twoSum(a[1], -b[1])
var x1 = twoSum(c[0], -b[0])
var y1 = twoSum(c[1], -b[1])
var d = robustSum(
robustProduct(x0, x1),
robustProduct(y0, y1))
return d[d.length-1] >= 0
}
function compareAngle(a, b, c, d) {
var bcd = orient(b, c, d)
if(bcd === 0) {
//Handle degenerate cases
var sabc = sgn(orient(a, b, c))
var sabd = sgn(orient(a, b, d))
if(sabc === sabd) {
if(sabc === 0) {
var ic = testInterior(a, b, c)
var id = testInterior(a, b, d)
if(ic === id) {
return 0
} else if(ic) {
return 1
} else {
return -1
}
}
return 0
} else if(sabd === 0) {
if(sabc > 0) {
return -1
} else if(testInterior(a, b, d)) {
return -1
} else {
return 1
}
} else if(sabc === 0) {
if(sabd > 0) {
return 1
} else if(testInterior(a, b, c)) {
return 1
} else {
return -1
}
}
return sgn(sabd - sabc)
}
var abc = orient(a, b, c)
if(abc > 0) {
if(bcd > 0 && orient(a, b, d) > 0) {
return 1
}
return -1
} else if(abc < 0) {
if(bcd > 0 || orient(a, b, d) > 0) {
return 1
}
return -1
} else {
var abd = orient(a, b, d)
if(abd > 0) {
return 1
} else {
if(testInterior(a, b, c)) {
return 1
} else {
return -1
}
}
}
}