Clip coordinates in interleaved spatial queries to world boundaries.

This commit is contained in:
Sascha L. Teichmann
2014-09-07 21:36:59 +02:00
parent 6b717e41fb
commit eb9cfb9959
4 changed files with 27 additions and 5 deletions

View File

@ -59,6 +59,23 @@ func maxComponent(a, b int16) int16 {
return b
}
func clipComponent(x int16) int16 {
if x < minValue {
return minValue
}
if x > maxValue {
return maxValue
}
return x
}
func ClipCoord(c Coord) Coord {
return Coord{
X: clipComponent(c.X),
Y: clipComponent(c.Y),
Z: clipComponent(c.Z)}
}
func MinCoord(a, b Coord) Coord {
return Coord{
X: minComponent(a.X, b.X),