Example usage for java.lang Math sqrt

List of usage examples for java.lang Math sqrt

Introduction

In this page you can find the example usage for java.lang Math sqrt.

Prototype

@HotSpotIntrinsicCandidate
public static double sqrt(double a) 

Source Link

Document

Returns the correctly rounded positive square root of a double value.

Usage

From source file:Main.java

public static float getNormalizeScaling(final float x, final float y, final float z) {
    return (float) (1.0 / Math.sqrt(x * x + y * y + z * z));
}

From source file:Main.java

public static float distance(float x1, float y1, float x2, float y2) {
    Log.d("Data: ", "" + Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
    return (float) Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

From source file:Main.java

public static double calcularHipotenusa(double catetoA, double catetoB) {
    //TODO suponemos valores correctos

    return Math.sqrt(Math.pow(catetoA, 2) + Math.pow(catetoB, 2));
}

From source file:Main.java

public static int calcularForca(float x, float y, float z) {
    int forca = (int) Math.sqrt((x * x + y * y + z * z));

    return forca - GRAVIDADE;
}

From source file:Main.java

public static float getDistance(float x1, float y1, float x2, float y2) {
    return (float) Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

From source file:Main.java

private static float distance(Context context, float diff) {
    float distanceInPx = (float) Math.sqrt(diff * diff);
    return pxToDp(context, distanceInPx);
}

From source file:Main.java

private static float calDistance(float x1, float y1, float x2, float y2) {
    return (float) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
}

From source file:Main.java

public static double calculateDPI(int width, int height, double screenSize) {
    return Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) / screenSize;
}

From source file:Main.java

public static float getSampleStdDev(float[] values) {
    return (float) Math.sqrt(getSampleVariance(values));
}

From source file:Main.java

public static float[] naivMatrixMultiply(float[] B, float[] A) {
    int mA, nA, mB, nB;
    mA = nA = (int) Math.sqrt(A.length);
    mB = nB = (int) Math.sqrt(B.length);
    if (nA != mB)
        throw new RuntimeException("Illegal matrix dimensions.");

    float[] C = new float[mA * nB];

    for (int i = 0; i < mA; i++)
        for (int j = 0; j < nB; j++)
            for (int k = 0; k < nA; k++)
                C[i + nA * j] += (A[i + nA * k] * B[k + nB * j]);
    return C;//from ww w.  j  a v a  2  s.  co  m
}