SFML community forums

Help => General => Topic started by: Szustarol on September 26, 2017, 05:52:39 pm

Title: How to measure which border will the ray "hit"
Post by: Szustarol on September 26, 2017, 05:52:39 pm
I think the image explains it all, Is it possible to measure which border will a ray "hit" if it was longer without using complex trigonometry?
Title: Re: How to measure which border will the ray "hit"
Post by: JayhawkZombie on September 27, 2017, 06:50:28 am
Do you need to calculate where it intersects or just know if it intersects?
Neither require trig, but calculating the intersections just requires you to use a (linear) system of 2 equations.
Title: Re: How to measure which border will the ray "hit"
Post by: dabbertorres on September 27, 2017, 11:45:41 am
Especially easy if you're doing digital differential analysis for the raycast:
https://github.com/dabbertorres/raycast-sfml/blob/master/Raycast-SFML/math.cpp#L43
Title: Re: How to measure which border will the ray "hit"
Post by: Szustarol on September 27, 2017, 03:11:43 pm
IF i know which side it hits calculating where it hits is really simple so i jest need to know which side