Android Open Source - android-augment-reality-framework Screen Position






From Project

Back to project page android-augment-reality-framework.

License

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.

Java Source Code

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 + " >";
    }
}




Java Source Code List

com.jwetherell.augmented_reality.activity.AugmentedReality.java
com.jwetherell.augmented_reality.activity.AugmentedView.java
com.jwetherell.augmented_reality.activity.Demo.java
com.jwetherell.augmented_reality.activity.SensorsActivity.java
com.jwetherell.augmented_reality.camera.CameraCompatibility.java
com.jwetherell.augmented_reality.camera.CameraModel.java
com.jwetherell.augmented_reality.camera.CameraSurface.java
com.jwetherell.augmented_reality.common.LowPassFilter.java
com.jwetherell.augmented_reality.common.Matrix.java
com.jwetherell.augmented_reality.common.Navigation.java
com.jwetherell.augmented_reality.common.Orientation.java
com.jwetherell.augmented_reality.common.ReusableString.java
com.jwetherell.augmented_reality.common.Vector.java
com.jwetherell.augmented_reality.data.ARData.java
com.jwetherell.augmented_reality.data.BuzzDataSource.java
com.jwetherell.augmented_reality.data.DataSource.java
com.jwetherell.augmented_reality.data.GooglePlacesDataSource.java
com.jwetherell.augmented_reality.data.LocalDataSource.java
com.jwetherell.augmented_reality.data.NetworkDataSource.java
com.jwetherell.augmented_reality.data.PhysicalLocation.java
com.jwetherell.augmented_reality.data.ScreenPosition.java
com.jwetherell.augmented_reality.data.TwitterDataSource.java
com.jwetherell.augmented_reality.data.WikipediaDataSource.java
com.jwetherell.augmented_reality.ui.IconMarker.java
com.jwetherell.augmented_reality.ui.Marker.java
com.jwetherell.augmented_reality.ui.Radar.java
com.jwetherell.augmented_reality.ui.objects.PaintableBox.java
com.jwetherell.augmented_reality.ui.objects.PaintableBoxedText.java
com.jwetherell.augmented_reality.ui.objects.PaintableCircle.java
com.jwetherell.augmented_reality.ui.objects.PaintableGps.java
com.jwetherell.augmented_reality.ui.objects.PaintableIcon.java
com.jwetherell.augmented_reality.ui.objects.PaintableLine.java
com.jwetherell.augmented_reality.ui.objects.PaintableObject.java
com.jwetherell.augmented_reality.ui.objects.PaintablePoint.java
com.jwetherell.augmented_reality.ui.objects.PaintablePosition.java
com.jwetherell.augmented_reality.ui.objects.PaintableRadarPoints.java
com.jwetherell.augmented_reality.ui.objects.PaintableText.java
com.jwetherell.augmented_reality.widget.VerticalSeekBar.java
com.jwetherell.augmented_reality.widget.VerticalTextView.java