• Advertisement
Sign in to follow this  

Why isn't my Distance to Point scirpt working?

This topic is 4496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using the following code to calculate the distance between two 2d coordinates.
double PointDist(double x1, double y1, double x2, double y2){
	double rise, run, length;
	rise = y2 - y1;
	run = x2 - x1;
	length = sqrt(pow(rise, 2) + pow(run, 2));

	return length;
}

The number I always get is 0.6000000x, where x is where the variation actually starts in the number thats returned. Heres a couple of numbers i got back. 0.60000002318111012 0.60000002075052783 Can anyone see the problem?

Share this post


Link to post
Share on other sites
Advertisement
Looks fine to me (aside from style issues). Have you tried verifying the inputs? (Or for that matter, the intermediate results of the pow()'s?)

Share this post


Link to post
Share on other sites

This topic is 4496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement