Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to measure which border will the ray "hit"  (Read 1686 times)

0 Members and 1 Guest are viewing this topic.

Szustarol

  • Newbie
  • *
  • Posts: 19
    • View Profile
How to measure which border will the ray "hit"
« 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?

JayhawkZombie

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: How to measure which border will the ray "hit"
« Reply #1 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.

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: How to measure which border will the ray "hit"
« Reply #2 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

Szustarol

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: How to measure which border will the ray "hit"
« Reply #3 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

 

anything