Android examples for java.lang:Math Geometry
Return the slope of a line
/******************************************************************************* * Copyright (c) 2011 MadRobot./*from w ww. j a va2 s.co m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * Elton Kent - initial API and implementation ******************************************************************************/ //package com.java2s; import android.graphics.PointF; public class Main { /** * Return the slope of a line * * @param lineStart * @param lineEnd * @return */ public static double getSlope(PointF lineStart, PointF lineEnd) { return (((lineStart.y) - lineEnd.y) / ((lineStart.x) - lineEnd.x)); } }