Maintenance - We're currently working on things and you might experience some issues. Should be wrapped up soon!

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
2D distance calculation problem
Post Body

i've tried to calculate the hypotenuse between 2 points using this line:

"double distanceXY = (Math.Sqrt((Math.Pow((deltaX), 2)) Math.Pow((deltaY), 2)));"

but it keeps giving me the root of a single delta^2 rather than adding both and then rooting them. i searched the web a bit and someone reccomended this line:

"double distanceXY = (Math.Sqrt((Math.Pow(Math.Abs(point2X - point1X), 2)) Math.Pow(Math.Abs(point2Y - point1Y), 2)));"

im interested to know why the first does no work and the second does because i think both should work properly.

any help would be appreciated :)

Author
Account Strength
90%
Account Age
8 years
Verified Email
Yes
Verified Flair
No
Total Karma
2,938
Link Karma
130
Comment Karma
2,808
Profile updated: 3 days ago
Posts updated: 3 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
6 years ago