Jump to content


Photo

Figuring distance from Point A to Point B


  • Please log in to reply
16 replies to this topic

#1 Eedis

Eedis
  • Members
  • 1591 posts

Posted 16 April 2011 - 12:57 AM

I posted this in General Chat as I am not asking for code, I just need the mathematical formula to figure out the problem.

I am two points, A and B. Given both the x and y coordinates and assuming the distance from x1 to x2 is 1P, what formula could I use to figure out the distance, in a straight line, from both points with completely different x coord's and y coord's. I figure I would need to figure the slope, but I have no idea where to go from there.

This is why I wish I paid more attention in Algebra. :/

#2 codybear

codybear
  • Members
  • 589 posts

Posted 16 April 2011 - 01:00 AM

I posted this in General Chat as I am not asking for code, I just need the mathematical formula to figure out the problem.

I am two points, A and B. Given both the x and y coordinates and assuming the distance from x1 to x2 is 1P, what formula could I use to figure out the distance, in a straight line, from both points with completely different x coord's and y coord's. I figure I would need to figure the slope, but I have no idea where to go from there.

This is why I wish I paid more attention in Algebra. :/


Distance formula:
Posted Image

[Edit]For more information: I got that image above from: <!-- m -->http://www.purplemat...es/distform.htm<!-- m -->
They usually have some good math tutorials at that site as I have used them to help tutor my friends in math along with a few others that have popped up during a google search.[/edit]

Hope this helps!

#3 nimda

nimda
  • Members
  • 4301 posts

Posted 16 April 2011 - 01:03 AM

X1:=0, Y1:=0, X2:=3, Y2:=3

distance := sqrt((y2-y1)**2+(X2-X1)**2)

MsgBox % Distance " should equal the square-root of 18:`n" sqrt(18)


#4 Eedis

Eedis
  • Members
  • 1591 posts

Posted 16 April 2011 - 01:03 AM

Awesome, thanks, I'll have to browse this for a bit. :)

#5 codybear

codybear
  • Members
  • 589 posts

Posted 16 April 2011 - 01:12 AM

Stupid image...it worked at first, must be hotlink protected lol.

#6 nimda

nimda
  • Members
  • 4301 posts

Posted 16 April 2011 - 01:27 AM

@codybear:
1.)Save image as
2.)upload to AutoHotkey.net
3.)???
4.)Profit

Posted Image

#7 codybear

codybear
  • Members
  • 589 posts

Posted 16 April 2011 - 03:04 AM

@codybear:
1.)Save image as
2.)upload to AutoHotkey.net
3.)???
4.)Profit

Posted Image

hahhah. Yeah, I was trying to take the easy way out. :D

#8 nimda

nimda
  • Members
  • 4301 posts

Posted 16 April 2011 - 11:48 AM

It's all done within the .htaccess file. All the hotlink wizardry, that is.

#9 a4u

a4u
  • Guests

Posted 16 April 2011 - 05:23 PM

This is why I wish I paid more attention in Algebra. :/

Pythagorean Theorem & Quadratic Formula - two things my Algebra II teacher said to Never Forget :wink:

#10 PEG

PEG
  • Guests

Posted 05 January 2012 - 03:30 PM

distcords(X1,Y1,X2,Y2)
	{
		Return sqrt((Y2-Y1)**2+(X2-X1)**2)
		;~ Round(sqrt((Y2-Y1)**2+(X2-X1)**2))
		
	}

Usage:
distcords(0,0,100,100)

would return ~141.421... (the rounded version 141.421 = 141)


#11 Mickers

Mickers
  • Members
  • 1229 posts

Posted 05 January 2012 - 04:33 PM

@Eadis
Is this for land navigation?

#12 Zaelia

Zaelia
  • Members
  • 705 posts

Posted 05 January 2012 - 11:31 PM

@Mickers: we will use other thing for land navigation, as "Orthodromy"
<!-- m -->http://en.wikipedia....circle_distance<!-- m -->
We need to use a lot trigonometry, else simple case is "Orthonormality" when "plan/map" is only in 2D and vector are in right angle and same unit length (therefore Pythagor), else only use vector formula (Chales and other)...

#13 Mickers

Mickers
  • Members
  • 1229 posts

Posted 06 January 2012 - 01:40 PM

Mabye it's too early in the morning but I can't translate anything you just said... :lol:

#14 IsNull

IsNull
  • Fellows
  • 990 posts

Posted 06 January 2012 - 04:23 PM

Mabye it's too early in the morning but I can't translate anything you just said... :lol:

I think she means that for real navigation calculations, complexer math would be requiered, as the world is not flat and even not a sphere. :) Pythagoras requires a (2D) right-angled triangle.

#15 Mickers

Mickers
  • Members
  • 1229 posts

Posted 06 January 2012 - 04:52 PM

Ok.

I just wanted to know if this was for passing Army land navigation tests which I have a lot of experience with. I was going to give any advice he may / may not need. :wink: