Sign in to follow this  

Why isn't my Distance to Point scirpt working?

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
This topic is now closed to further replies.
Sign in to follow this