Module forma.raycasting

Ray tracing algorithms Algorithms for identifying visible segments of a pattern from a single cell.

This can be used for 'field of view' applications.

Sources:

http://www.adammil.net/blog/v125_Roguelike_Vision_Algorithms.html http://www.roguebasin.com/index.php?title=LOS_using_strict_definition

Functions

ray.cast (v0, v1, domain) Casts a ray from a start to an end cell.
ray.cast_octant (v0, domain, oct, ray_length) Casts rays from a start cell across an octant.
ray.cast_360 (v0, domain, ray_length) Casts rays from a starting cell in all directions


Functions

ray.cast (v0, v1, domain)
Casts a ray from a start to an end cell. Returns {true/false} if the cast is successful/blocked. Adapted from:

http://www.roguebasin.com/index.php?title=LOS_using_strict_definition

Parameters:

  • v0 starting cell of ray
  • v1 end cell of ray
  • domain the domain in which we are casting

Returns:

    true or false depending on whether the ray was successfully cast
ray.cast_octant (v0, domain, oct, ray_length)
Casts rays from a start cell across an octant.

Parameters:

  • v0 starting cell of ray
  • domain the domain in which we are casting
  • oct the octant identifier (integer between 1 and 8)
  • ray_length the maximum length of the ray

Returns:

    the pattern illuminated by the ray casting
ray.cast_360 (v0, domain, ray_length)
Casts rays from a starting cell in all directions

Parameters:

  • v0 starting cell of ray
  • domain the domain in which we are casting
  • ray_length the maximum length of the ray

Returns:

    the pattern illuminated by the ray casting
generated by LDoc 1.5.0 Last updated 2025-03-12 19:36:11