Checks if a line is vertical. - Android java.lang

Android examples for java.lang:Math Geometry

Description

Checks if a line is vertical.

Demo Code

/*******************************************************************************
 * Copyright (c) 2011 MadRobot./*from  www .  ja  v  a 2  s .c  o  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 {
    /**
     * Defines the distance below which two points are considered to coincide.
     */
    public static final double VERY_SMALL_DISTANCE = 0.000001;

    /**
     * Checks if a line is vertical.
     * 
     * @param line
     *            the line to check
     * @return returns true if the line is vertical, false otherwise.
     */
    public static boolean isVertical(PointF lineStart, PointF lineEnd) {
        return ((Math.abs(lineStart.x - lineEnd.x) < VERY_SMALL_DISTANCE));
    }
}

Related Tutorials