All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
commonMain.ru.casperix.math.intersection.IntersectionApi.kt Maven / Gradle / Ivy
package ru.casperix.math.intersection
import ru.casperix.math.geometry.*
import ru.casperix.math.vector.api.AbstractVector
/**
* https://blackpawn.com/texts/pointinpoly/default.html
*/
interface IntersectionApi> {
fun hasPointWithLine(P: Point, T: Line): Boolean
fun hasPointWithSegment(P: Point, T: Line): Boolean
fun hasPointWithTriangle(P: Point, triangle: Triangle): Boolean
fun hasPointWithPolygon(P: Point, polygon: Polygon): Boolean
fun hasTriangleWithTriangle(a: Triangle, b: Triangle): Boolean
fun hasQuadWithTriangle(a: Quad, b: Triangle): Boolean
fun getLineWithLine(S: Line, T: Line): Point?
fun getSegmentWithSegment(S: Line, T: Line): Point?
fun hasQuadWithQuad(a: Quad, b: Quad): Boolean
fun hasPointWithLine(P: Point, start: Point, finish: Point): Boolean {
return hasPointWithLine(P, Line(start, finish))
}
fun hasSegmentWithTriangle(S: Line, T: Triangle): Boolean {
if (getSegmentWithSegment(S, T.getEdge(0)) != null) return true
if (getSegmentWithSegment(S, T.getEdge(1)) != null) return true
if (getSegmentWithSegment(S, T.getEdge(2)) != null) return true
if (hasPointWithTriangle(S.v0, T)) return true
if (hasPointWithTriangle(S.v1, T)) return true
return false
}
fun hasPointWithQuad(point: Point, value: Quad): Boolean {
return hasPointWithTriangle(point, value.getFace(0)) || hasPointWithTriangle(point, value.getFace(1))
}
fun hasTriangleWithQuad(a: Triangle, b: Quad): Boolean {
return hasQuadWithTriangle(b, a)
}
fun hasPointWithTriangle(P: Point, A: Point, B: Point, C: Point): Boolean {
return hasPointWithTriangle(P, Triangle(A, B, C))
}
fun hasPointWithQuad(P: Point, A: Point, B: Point, C: Point, D: Point): Boolean {
return hasPointWithQuad(P, Quad(A, B, C, D))
}
fun getSegmentWithSegment(start1: Point, finish1: Point, start2: Point, finish2: Point): Point? {
return getSegmentWithSegment(Line(start1, finish1), Line(start2, finish2))
}
}