Implementing ray casting

Hey guys i wanted to know if any one could point me in the right place to learn how to implement ray casting. I have searched every where and i cant find any thing on the subject that is actually helpful or not outdated. I need it in order to drag 2d sprites around a screen. Any help would be much appreciated.


I’ve never implemented ray casting myself, but I used it in physics engines like Bullet and Open Dynamics Engine. They are Open Source so you might want to learn from their code.

Here as a start:

Or this might help for 2d from Box2D:

Hope this helps.