Example usage for android.graphics PointF length

List of usage examples for android.graphics PointF length

Introduction

In this page you can find the example usage for android.graphics PointF length.

Prototype

public final float length() 

Source Link

Document

Return the euclidian distance from (0,0) to the point

Usage

From source file:Main.java

/**
 * This method normalize specified vector.
 *
 * @param point {@link PointF}/*w  w  w  .j av  a  2 s .  c  o  m*/
 */
public static void normalizeVector(PointF point) {
    final float abs = point.length();
    point.set(point.x / abs, point.y / abs);
}

From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java

boolean isRectJumping(DkPolyRect[] dkPolyRects) {

    boolean isJumping = false;

    Log.d(TAG, "jumping?");

    if (dkPolyRects != null && mLastDkPolyRects != null) {
        Log.d(TAG, "check 1");
        if (dkPolyRects.length == 1 && mLastDkPolyRects.length == 1) {
            Log.d(TAG, "check 2");
            PointF distVec = mLastDkPolyRects[0].getLargestDistVector(dkPolyRects[0]);
            PointF normedPoint = mCVResult.normPoint(distVec);

            if (normedPoint.length() >= .05) {
                isJumping = true;/*www  .j av a2  s  .  co m*/
            }

            Log.d(TAG, "distance: " + normedPoint.length());
        }
    }

    return isJumping;
}

From source file:cc.flydev.launcher.Page.java

private PointF isFlingingToDelete() {
    ViewConfiguration config = ViewConfiguration.get(getContext());
    mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity());

    if (mVelocityTracker.getYVelocity() < mFlingToDeleteThresholdVelocity) {
        // Do a quick dot product test to ensure that we are flinging upwards
        PointF vel = new PointF(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity());
        PointF upVec = new PointF(0f, -1f);
        float theta = (float) Math
                .acos(((vel.x * upVec.x) + (vel.y * upVec.y)) / (vel.length() * upVec.length()));
        if (theta <= Math.toRadians(FLING_TO_DELETE_MAX_FLING_DEGREES)) {
            return vel;
        }/*w  ww.j a va2  s  .  c o  m*/
    }
    return null;
}

From source file:com.n2hsu.launcher.Page.java

private PointF isFlingingToDelete() {
    ViewConfiguration config = ViewConfiguration.get(getContext());
    mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity());

    if (mVelocityTracker.getYVelocity() < mFlingToDeleteThresholdVelocity) {
        // Do a quick dot product test to ensure that we are flinging
        // upwards
        PointF vel = new PointF(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity());
        PointF upVec = new PointF(0f, -1f);
        float theta = (float) Math
                .acos(((vel.x * upVec.x) + (vel.y * upVec.y)) / (vel.length() * upVec.length()));
        if (theta <= Math.toRadians(FLING_TO_DELETE_MAX_FLING_DEGREES)) {
            return vel;
        }/*from  w w w.  jav  a  2s  .c  o  m*/
    }
    return null;
}