List of utility methods to do Distance Calculate
float | dist(float x1, float y1, float x2, float y2) dist return sqrt(sq(x2 - x1) + sq(y2 - y1));
|
float | dist(float x1, float y1, float x2, float y2, float xp, float yp) Calculate the distance from point (xp, yp) to the line passing through points (x1, y1) and (x2, y2) float px = x2 - x1; float py = y2 - y1; float q = px * px + py * py; float u = ((xp - x1) * px + (yp - y1) * py) / q; if (u > 1f) { u = 1f; } else if (u < 0f) { u = 0f; ... |
float | dist(float x1, float y1, float z1, float x2, float y2, float z2) dist return sqrt(sq(x2 - x1) + sq(y2 - y1) + sq(z2 - z1));
|
int | dist(int i, int j, int width) dist int dX = abs(i % width - j % width); int dY = abs(i / width - j / width); return dX + dY; |
double | dist(int p1, int p2) dist return Math.sqrt(p1 * p1 + p2 * p2);
|
int | dist(int x1, int y1, int x2, int y2) dist return (int) Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))); |
double | dist14(double d12, double d23, double d34, double theta123, double theta234, double phi) Computes the 1-4 distance in an arbitrary (nonplanar) quadrangle, given d12, d13, d14, theta123 = angle(1,2,3), theta234 = angle(2,3,4) and phi = angle(plane(1,2,3), plane(2,3,4)). double alpha123 = Math.PI - theta123; double alpha234 = Math.PI - theta234; double a1 = Math.cos(alpha123) * d12; double a2 = Math.sin(alpha123) * d12; double b1 = Math.cos(alpha234) * d34; double b2 = Math.sin(alpha234) * d34; double c = a1 + d23 + b1; double e_sq = cosineTheorem(a2, b2, phi); ... |
double | dist2Degrees(double dist, double radius) Converts a distance in the units of the radius to degrees (360 degrees are in a circle). return Math.toDegrees(dist2Radians(dist, radius));
|
double | dist2Radians(double dist, double radius) Converts a distance in the units of radius (e.g.
return dist / radius;
|
double | distAlongRaySquared(double px, double py, double qx, double qy, double rx, double ry) dist Along Ray Squared double sx = px - qx; double sy = py - qy; double num = dot(sx, sy, rx, ry); return num * num / dot(rx, ry, rx, ry); |