Main data structures¶
A ray is made up of a number of ray_segment structs in an array.
- ray_segment¶
This stores information about a section of a ray, from the point where it is initialised (x0, y0) until it refracts or reflects, and a new ray segment is generated. x, y and distance are updated at each timestep whilst the other variables do not change.
- double x0¶
Initial x position.
- double y0¶
Initial y position.
- double x¶
Current x position.
- double y¶
current y position.
- double vx¶
x direction.
- double vy¶
y direction.
- int depth¶
Number of refractions or reflections undergone.
- double distance¶
Distance travelled.
Three arrays store most of important information about the transform.
- ray_segment* rays¶
An array of ray_segment, of size (max_depth + 1) that has a new ray_segment initialised each time the ray being traced refracts or reflects. The ray_segment at index 0 is set to the initial random values.
- double* accumulator¶
An array of size w x h that is incremented by one when a ray passes through it for the first time.
- double* marked¶
An array that stops a single ray accumulating a pixel more than once. It only accumulates if the value of the pixel in this array is different to its id, and then sets the marked value to its id.