About the Project

This Project is one of my math exercises where I made 2D raycasts using linear functions.

It's made in Unity and is available as WebGL and Windows executable. 

The source code is available on GitHub: https://github.com/MichaCrivelli/MathRaycast

Controls

You can set the position of the ball by clicking/touching anywhere. After you let go it waits for a few seconds before it resumes the animation.

The white lines are solid walls and the gray ones are glass walls, which the raycast ignores.

Learnings

This is not the recomended way of solving this Problem because its very performance heavy. Another drawback of using linear functions is that you can't really draw vertical lines because the incline of such a function would be infinite.

The better way of doing this would be to calculate the line intersections like Daniel Shiffman has done in his coding challenge #145.

Download

Download
MathRaycast_win.zip 25 MB

Comments

Log in with itch.io to leave a comment.

(1 edit) (+1)

Ray-casting to vertices far more effective but requires splitting intersecting lines.

My old online exercise about this WARNING, READING SOURCE CAN CAUSE EYE BLEEDING

Based on Amit's Patel article

(+1)

My goal here was to use linear functions and calculating the intersections of them.
Your approach is far better for 2D visibility. I like your detailed visualisation of it.

Awesome article, thanks.