Pwnna
Pwnna

Reputation: 9538

Simplified version of Ray Tracing to find the nearest object extending out from a vector

I have a 2D array consisting of 0s and 1s. I have a vector originating from a 0 to any direction and I need to find the nearest 1 that intersects with the vector in that direction and its distance

So I've looked into ray tracing, but most materials on the subject seemed rather unintuitive and mostly talked about how to do refraction and color calculations.

Is there something simpler than the said algorithm?

Thanks.

Upvotes: 1

Views: 396

Answers (1)

Alexander Pelekhan
Alexander Pelekhan

Reputation: 66

You can adapt the Bresenham' line algorithm to this task.

Upvotes: 3

Related Questions