Back to project page android-augment-reality-framework.
The source code is released under:
GNU General Public License
If you think the Android project android-augment-reality-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jwetherell.augmented_reality.data; /*w w w . java2s . c o m*/ import android.util.FloatMath; /** * This class is used mostly as a utility to calculate relative positions. * * @author Justin Wetherell <phishman3579@gmail.com> */ public class ScreenPosition { private float x = 0f; private float y = 0f; public ScreenPosition() { set(0, 0); } /** * Set method for X and Y. Should be used instead of creating new objects. * * @param x * X position. * @param y * Y position. */ public void set(float x, float y) { this.x = x; this.y = y; } /** * Get the X position. * * @return Float X position. */ public float getX() { return x; } /** * Set the X position. * * @param x * Float X position. */ public void setX(float x) { this.x = x; } /** * Get the Y position. * * @return Float Y position. */ public float getY() { return y; } /** * Set the Y position. * * @param y * Float Y position. */ public void setY(float y) { this.y = y; } /** * Rotate the positions around the angle t. * * @param t * Angle to rotate around. */ public void rotate(float t) { float xp = FloatMath.cos(t) * x - FloatMath.sin(t) * y; float yp = FloatMath.sin(t) * x + FloatMath.cos(t) * y; x = xp; y = yp; } /** * Add the X and Y to the positions X and Y. * * @param x * Float X to add to X. * @param y * Float Y to add to Y. */ public void add(float x, float y) { this.x += x; this.y += y; } /** * {@inheritDoc} */ @Override public String toString() { return "< x=" + x + " y=" + y + " >"; } }