Example usage for android.util FloatMath sin

List of usage examples for android.util FloatMath sin

Introduction

In this page you can find the example usage for android.util FloatMath sin.

Prototype

public static float sin(float angle) 

Source Link

Document

Returns the closest float approximation of the sine of the argument.

Usage

From source file:gaobq.android.easyslidingmenu.CustomViewAbove.java

float distanceInfluenceForSnapDuration(float f) {
    f -= 0.5f; // center the values about 0.
    f *= 0.3f * Math.PI / 2.0f;/*from ww  w .  j a  v  a  2 s  . c  om*/
    return (float) FloatMath.sin(f);
}

From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java

/**
 * Distance influence for snap duration.
 *
 * @param f the f//  w w w  .  jav  a2 s.  c  om
 * @return the float
 */
float distanceInfluenceForSnapDuration(float f) {
    f -= 0.5f; // center the values about 0.
    f *= 0.3f * Math.PI / 2.0f;
    return (float) FloatMath.sin(f);
}

From source file:com.bofsoft.sdk.widget.menu.slidingmenu.CustomViewAbove.java

/**
 * Distance influence for snap duration.
 *
 * @param f the f/*from w  w w  .j a  v a  2s .c o  m*/
 * @return the float
 */
float distanceInfluenceForSnapDuration(float f) {
    f -= 0.5f; // center the values about 0.
    f *= 0.3f * Math.PI / 2.0f;
    return FloatMath.sin(f);
}

From source file:com.jiahuan.svgmapview.core.helper.map.SVGParser.java

private static void drawArc(Path p, float lastX, float lastY, float x, float y, float rx, float ry, float theta,
        int largeArc, int sweepArc) {
    // Log.d("drawArc", "from (" + lastX + "," + lastY + ") to (" + x + ","+
    // y + ") r=(" + rx + "," + ry +
    // ") theta=" + theta + " flags="+ largeArc + "," + sweepArc);

    // http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes

    if (rx == 0 || ry == 0) {
        p.lineTo(x, y);//w  w  w.j a  va  2s  . co  m
        return;
    }

    if (x == lastX && y == lastY) {
        return; // nothing to draw
    }

    rx = Math.abs(rx);
    ry = Math.abs(ry);

    final float thrad = theta * (float) Math.PI / 180;
    final float st = FloatMath.sin(thrad);
    final float ct = FloatMath.cos(thrad);

    final float xc = (lastX - x) / 2;
    final float yc = (lastY - y) / 2;
    final float x1t = ct * xc + st * yc;
    final float y1t = -st * xc + ct * yc;

    final float x1ts = x1t * x1t;
    final float y1ts = y1t * y1t;
    float rxs = rx * rx;
    float rys = ry * ry;

    float lambda = (x1ts / rxs + y1ts / rys) * 1.001f; // add 0.1% to be
    // sure that no out
    // of range occurs
    // due to
    // limited precision
    if (lambda > 1) {
        float lambdasr = FloatMath.sqrt(lambda);
        rx *= lambdasr;
        ry *= lambdasr;
        rxs = rx * rx;
        rys = ry * ry;
    }

    final float R = FloatMath.sqrt((rxs * rys - rxs * y1ts - rys * x1ts) / (rxs * y1ts + rys * x1ts))
            * ((largeArc == sweepArc) ? -1 : 1);
    final float cxt = R * rx * y1t / ry;
    final float cyt = -R * ry * x1t / rx;
    final float cx = ct * cxt - st * cyt + (lastX + x) / 2;
    final float cy = st * cxt + ct * cyt + (lastY + y) / 2;

    final float th1 = angle(1, 0, (x1t - cxt) / rx, (y1t - cyt) / ry);
    float dth = angle((x1t - cxt) / rx, (y1t - cyt) / ry, (-x1t - cxt) / rx, (-y1t - cyt) / ry);

    if (sweepArc == 0 && dth > 0) {
        dth -= 360;
    } else if (sweepArc != 0 && dth < 0) {
        dth += 360;
    }

    // draw
    if ((theta % 360) == 0) {
        // no rotate and translate need
        arcRectf.set(cx - rx, cy - ry, cx + rx, cy + ry);
        p.arcTo(arcRectf, th1, dth);
    } else {
        // this is the hard and slow part :-)
        arcRectf.set(-rx, -ry, rx, ry);

        arcMatrix.reset();
        arcMatrix.postRotate(theta);
        arcMatrix.postTranslate(cx, cy);
        arcMatrix.invert(arcMatrix2);

        p.transform(arcMatrix2);
        p.arcTo(arcRectf, th1, dth);
        p.transform(arcMatrix);
    }
}

From source file:com.domo.activity.swipeback.ViewDragHelper.java

@SuppressLint("FloatMath")
private float distanceInfluenceForSnapDuration(float f) {
    f -= 0.5f; // center the values about 0.
    f *= 0.3f * Math.PI / 2.0f;/*from  www .  ja  va2s . c om*/
    return FloatMath.sin(f);
}

From source file:bk.vinhdo.taxiads.utils.view.SlidingLayer.java

float distanceInfluenceForSnapDuration(float f) {
    f -= 0.5f; // center the values about 0.
    f *= 0.3f * Math.PI / 2.0f;
    return FloatMath.sin(f);
}