Safe Haskell | None |
---|---|

Language | Haskell98 |

Various ray casting algorithms.

# Documentation

castSegIntoCellularQuadTree Source

:: Point | (P1) Starting point of seg. |

-> Point | (P2) Final point of seg. |

-> Extent | Extent convering the whole tree. |

-> QuadTree a | The tree. |

-> Maybe (Point, Extent, a) | Intersection point, extent of cell, value of cell (if any). |

The quadtree contains cells of unit extent (NetHack style). Given a line segement (P1-P2) through the tree, get the cell closest to P1 that intersects the segment, if any.

TODO: This currently uses a naive algorithm. It just calls
`traceSegIntoCellularQuadTree`

and sorts the results
to get the one closest to P1. It'd be better to do a
proper walk over the tree in the direction of the ray.

traceSegIntoCellularQuadTree Source

:: Point | (P1) Starting point of seg. |

-> Point | (P2) Final point of seg. |

-> Extent | Extent covering the whole tree. |

-> QuadTree a | The tree. |

-> [(Point, Extent, a)] | Intersection point, extent of cell, value of cell. |

The quadtree contains cells of unit extent (NetHack style). Given a line segment (P1-P2) through the tree, return the list of cells that intersect the segment.