Java Distance Calculate distance(float aX, float aY, float bX, float bY)

Here you can find the source of distance(float aX, float aY, float bX, float bY)

Description

distance

License

Apache License

Declaration

public static float distance(float aX, float aY, float bX, float bY) 

Method Source Code

//package com.java2s;
/*//from ww  w. jav a 2  s.  c om
 * Copyright 2012 ZXing authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    public static float distance(float aX, float aY, float bX, float bY) {
        float xDiff = aX - bX;
        float yDiff = aY - bY;
        return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff);
    }

    public static float distance(int aX, int aY, int bX, int bY) {
        int xDiff = aX - bX;
        int yDiff = aY - bY;
        return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff);
    }
}

Related

  1. distance(final double[] a, final double[] b)
  2. Distance(final double[] minCorner, final double[] maxCorner)
  3. distance(final double[] p, final double[] q)
  4. distance(final double[] t1, final double[] t2)
  5. distance(final String c1, final String c2, final String c1Prev, final String c2Prev)
  6. distance(float speed, float delta)
  7. distance(float value1, float value2)
  8. distance(float value1, float value2)
  9. distance(float value1, float value2)