| We hope you enjoy your visit. You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you are already a member please log in to your account to access all of our features: |
- Pages:
- 1
- 2
| Game Math c++ code snippets; Can be adapted to use in other languages | |
|---|---|
| Tweet Topic Started: Dec 12 2009, 10:28 PM (2,554 Views) | |
| Dr. Best | Feb 26 2010, 12:53 AM Post #16 |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Ok, enough fun. Time to clear some things up. Your new code still does not give the Manhattan-Distance, because it is basically equivalent to this:
Or if you change it a little bit further it is this:
It is easy to see that this is not right, because it gives PointDistance(-1,1,1,-1)==0, but the correct Manhattan-Distance in this case would be 4. A correct function for the Manhattan-Distance would be:
To contribute a little to the topic here is a function for arbitrary metrics induced by p-Norms. Attend Analysis lectures at the college of your choice to find out what that is.
For P=2.0 you get the Euclidean distance, which is the length of the shortest way between the two points, for P=1.0 you get the Manhattan-Distance, which is the length of the shortest way between the two points, if you can move only along the axes of the coordinate-system. |
![]() |
|
| Sothh | Feb 26 2010, 05:48 PM Post #17 |
|
Shaman Of Time
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I got that code of the internet in the first place. I know nothing of geometry... |
|
“You can’t outrun Death forever. But you can make the Bastard work for it.” Major Korgo Korgar “Last of The Lancers” - AFC 32 (Andromeda Ascendant Record Database) | |
![]() |
|
| Gandalf20000 | Mar 7 2010, 10:44 PM Post #18 |
![]()
Geek
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Here's one that is blatantly obvious, but I feel it should be mentioned anyway: You mentioned a radians to degrees method, but not a degrees to radians method, which is just as simple, but you flip the 180 and the pi values.
|
![]() |
|
| « Previous Topic · Tutorials · Next Topic » |
- Pages:
- 1
- 2





![]](http://z1.ifrm.com/static/1/pip_r.png)




9:01 PM Jul 11