Android examples for java.lang:Math Vector
Construct the vector specified by two points.
/******************************************************************************* * Copyright (c) 2011 MadRobot./*from ww w . j a va 2 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 { public static PointF createVector(float ax, float ay, float bx, float by) { PointF point = new PointF(); point.x = bx - ax; point.y = by - ay; return point; } /** * Construct the vector specified by two points. * * @param lineStart * The coordinate of the line starting point * @param lineEnd * The coordinate of the line ending point * * @return The Vector point */ public static PointF createVector(PointF lineStart, PointF lineEnd) { return createVector(lineStart.x, lineStart.y, lineEnd.x, lineEnd.y); } }