Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.
Moderator: Coders of Rage
MadPumpkin
Chaos Rift Maniac
Posts: 484 Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk
Post
by MadPumpkin » Sun May 29, 2011 4:20 pm
When I use Pythagorean theorem I always get same answer as when I use this:
Which makes perfect sense, one just checks based on sides, and one checks using another method. However, when I do this:
Code: Select all
sqrt( (x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)
OR
cuberoot( (x1-x1)^2 + (y2-y1)^2 + (z2-z1)^2)
Either way I get a different answer than what Pythagoras yields. I'm not sure which ones right, any help? Alright well I said that wrong, I AM sure which ones right, Pythagoras is god. I just want to know, what I can do to make the other way of doing it correct too, or another similar way anyways.
Last edited by
MadPumpkin on Sun May 29, 2011 4:39 pm, edited 1 time in total.
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Ginto8
ES Beta Backer
Posts: 1064 Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java
Post
by Ginto8 » Sun May 29, 2011 4:37 pm
for 3D it should be the first, just subtract the 2 z's instead of adding them.
Quit procrastinating and make something awesome.
Ducky wrote: Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
MadPumpkin
Chaos Rift Maniac
Posts: 484 Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk
Post
by MadPumpkin » Sun May 29, 2011 4:43 pm
Ginto8 wrote: for 3D it should be the first, just subtract the 2 z's instead of adding them.
Yea I had just barely fixed that >.< I meant to put subtraction. I might have just been doing my math on paper wrong. So I'm about to do it.
Well my god, thanks Ginto8. In my math, I
squared x and
y but forgot to
square z before adding them.
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock