## [Algorithms] Quick Math Question

 [Algorithms] Quick Math Question From: oles - 2001-01-31 10:02:24 ```Hi. How to determine distance from 2D point to 2D ray? Line defined as (StartPosition, Direction). Thanx. Oles V. Shishkovtsov GSC GameWorld oles@... ```

 [Algorithms] Quick Math Question From: oles - 2001-01-31 10:02:24 ```Hi. How to determine distance from 2D point to 2D ray? Line defined as (StartPosition, Direction). Thanx. Oles V. Shishkovtsov GSC GameWorld oles@... ```
 Re: [Algorithms] Quick Math Question From: oles - 2001-01-31 10:19:02 ```Already solved :) N = (Direction.y, -Direction.x) c = -N.dot(StartPoint) distance_to_P = N.dot(P) + c Correct? Oles V. Shishkovtsov GSC GameWorld oles@... ```
 Re: [Algorithms] Quick Math Question From: Andrew Jones - 2001-01-31 10:44:52 ```There are quite a few good FAQs around for this sort of thing. http://www.faqs.org/faqs/graphics/algorithms-faq/ Andrew Jones ```
 Re: [Algorithms] Quick Math Question From: - 2001-01-31 15:13:04 ```oles wrote: >Already solved :) > >N =3D (Direction.y, -Direction.x) >c =3D -N.dot(StartPoint) > >distance_to_P =3D N.dot(P) + c > >Correct? > No, not always. In the first place, assuming that your Direction vector is a unit vector, this will give a signed distance (not what one usually means by "distance"). The sign is negative if the point lies on the right side of the line of the ray as you look in the direction of the ray (provided that your coordinate axis definition is the usual one). Take its absolute value to get an ordinary distance. =20 In the second place, this does not always give the distance from the point to the ray, but rather always the distance from the point to the line containing the ray. This will not be the same as the distance from the point to the ray if=20 Direction dot (P - StartPoint) < 0 In this case, P lies in the "back" half-plane defined by the line through StartPoint perpendicular to the ray and the distance from P to the ray is just the distance from P to StartPoint. ```
 [Algorithms] Detecting a NAT From: Tom Hubina - 2001-01-31 20:22:37 ```In our games we use WinSock for all networking. I was wondering if someone knows of a good way to detect that a server is being run behind a NAT so I can warn the user that the game won't work properly unless the NAT is configured to forward packets (either through DMZ or port forwarding) to the server machine (we have a lobby server running that can aid in the checks). I guess what I want to know is, how do I get return the address of the packet, and how do I get the IP address of the local interface being used (so I can compare them and warn if they're different). How do others deal with this? Tom ```
 AW: [Algorithms] Detecting a NAT From: Dirk Ringe - 2001-01-31 20:44:34 ```My preferred solution is always to do ALL communications via exactly ONE UDP port. So if I register "my own server" at the lobby, the lobby sees the IP/Port that was really used to contact him. This real IP/Port is then told all other clients who want to join the game on "My own server". This works only when the communication with the server and the communication for the game itself is run through the same port. For lobby aided detection of a NAT: the lobby calls recvfrom and gets the IP/port used by the NAT system this IP is sent back to the client the client gets his configured IP when calling gethostname and then gethostbyname. if the two IP/Ports differ, the client is using a NAT. Dirk -----Ursprungliche Nachricht----- Von: gdalgorithms-list-admin@... [mailto:gdalgorithms-list-admin@...]Im Auftrag von Tom Hubina Gesendet: Mittwoch, 31. Januar 2001 21:21 An: gdalgorithms-list@... Betreff: [Algorithms] Detecting a NAT In our games we use WinSock for all networking. I was wondering if someone knows of a good way to detect that a server is being run behind a NAT so I can warn the user that the game won't work properly unless the NAT is configured to forward packets (either through DMZ or port forwarding) to the server machine (we have a lobby server running that can aid in the checks). I guess what I want to know is, how do I get return the address of the packet, and how do I get the IP address of the local interface being used (so I can compare them and warn if they're different). How do others deal with this? Tom _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list@... http://lists.sourceforge.net/lists/listinfo/gdalgorithms-list ```