[orx-triangulation] Improve triangulation, add kotlin/js support

This commit is contained in:
Edwin Jakobs
2022-10-21 10:33:24 +02:00
parent ed6cda8cca
commit 1f16aa6a31
21 changed files with 1608 additions and 251 deletions

View File

@@ -0,0 +1,19 @@
package org.openrndr.extra.triangulation
internal fun orient2d(bx: Double, by: Double, ax: Double, ay: Double, cx: Double, cy: Double): Double {
// (ax,ay) (bx,by) are swapped such that the sign of the determinant is flipped. which is what Delaunator.kt expects.
/*
| a b | = | ax - cx ay - cy |
| c d | | bx - cx by - cy |
*/
val a = ax - cx
val b = ay - cy
val c = bx - cx
val d = by - cy
val determinant = ddDiffDd(twoProduct(a, d), twoProduct(b, c))
return determinant[1]
}