get Line Slope - Android java.lang

Android examples for java.lang:Math Geometry

Description

get Line Slope

Demo Code


//package com.java2s;

public class Main {

    public static float getSlope(float x1, float y1, float x2, float y2) {
        float x = (x2 - x1);
        float y = y2 - y1;
        if (x == 0) {
            return Float.NaN;
        }/* ww  w.  j av  a 2  s . c o  m*/
        return y / x;
    }
}

Related Tutorials