Java Distance Calculate distance(float x1, float x2, float y1, float y2)

Here you can find the source of distance(float x1, float x2, float y1, float y2)

Description

Distance.

License

Open Source License

Parameter

Parameter Description
x1 the x1
x2 the x2
y1 the y1
y2 the y2

Return

the float

Declaration

public static float distance(float x1, float x2, float y1, float y2) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from w  w w.j a va  2 s . c  om
     * Distance.
     *
     * @param x1
     *            the x1
     * @param x2
     *            the x2
     * @param y1
     *            the y1
     * @param y2
     *            the y2
     * @return the float
     */
    public static float distance(float x1, float x2, float y1, float y2) {
        float dx = x1 - x2;
        float dy = y1 - y2;
        return (float) Math.sqrt((dx * dx) + (dy * dy));
    }
}

Related

  1. distance(float aX, float aY, float bX, float bY)
  2. distance(float speed, float delta)
  3. distance(float value1, float value2)
  4. distance(float value1, float value2)
  5. distance(float value1, float value2)
  6. distance(float x1, float y1, float x2, float y2)
  7. distance(float x1, float y1, float x2, float y2)
  8. distance(float x1, float y1, float x2, float y2)
  9. distance(float[] p1, float[] p2)