Android Open Source - android-plotter Angle






From Project

Back to project page android-plotter.

License

The source code is released under:

Apache License

If you think the Android project android-plotter 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 org.solovyev.android.plotter;
//w  w w . j a  va  2  s .  co  m
import android.opengl.Matrix;
import android.os.Parcel;
import android.os.Parcelable;

import javax.annotation.Nonnull;

final class Angle implements Parcelable {

  @Nonnull
  public static final Creator<Angle> CREATOR = new Creator<Angle>() {
    public Angle createFromParcel(@Nonnull Parcel in) {
      return new Angle(in);
    }

    public Angle[] newArray(int size) {
      return new Angle[size];
    }
  };

  @Nonnull
  private final float[] rotation = new float[16];

  @Nonnull
  private final float[] tmp = new float[16];

  public float x;
  public float y;

  Angle() {
  }

  Angle(float x, float y) {
    this.x = x;
    this.y = y;
  }

  public Angle(@Nonnull Parcel in) {
    this.x = in.readFloat();
    this.y = in.readFloat();
  }

  public void add(@Nonnull Angle angle) {
    x += angle.x;
    y += angle.y;

    if (x >= 180) {
      x -= 360;
    }

    if (x < -180) {
      x += 360;
    }

    if (y >= 180) {
      y -= 360;
    }

    if (y < -180) {
      y += 360;
    }
  }

  @Nonnull
  public float[] getMatrix() {
    final float[] matrix = new float[16];
    rotateTo(matrix);
    return matrix;
  }

  public void rotateTo(@Nonnull float[] matrix) {
    Matrix.setIdentityM(matrix, 0);
    Matrix.rotateM(matrix, 0, x, 1, 0, 0);
    Matrix.rotateM(matrix, 0, y, 0, 1, 0);
  }

  public void rotateBy(@Nonnull float[] matrix) {
    Matrix.setIdentityM(rotation, 0);
    Matrix.rotateM(rotation, 0, x, 1, 0, 0);
    Matrix.rotateM(rotation, 0, y, 0, 1, 0);
    Matrix.multiplyMM(tmp, 0, rotation, 0, matrix, 0);
    System.arraycopy(tmp, 0, matrix, 0, 16);
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(@Nonnull Parcel out, int flags) {
    out.writeFloat(x);
    out.writeFloat(y);
  }

  public void apply(@Nonnull Angle from) {
    this.x = from.x;
    this.y = from.y;
  }
}




Java Source Code List

com.android.texample.GLText.java
com.android.texample.SpriteBatch.java
com.android.texample.TexampleRenderer.java
com.android.texample.TextureRegion.java
com.android.texample.Vertices.java
org.solovyev.android.plotter.Angle.java
org.solovyev.android.plotter.AxisStyle.java
org.solovyev.android.plotter.Check.java
org.solovyev.android.plotter.Color.java
org.solovyev.android.plotter.DefaultPlotter.java
org.solovyev.android.plotter.Dimensions.java
org.solovyev.android.plotter.Frustum.java
org.solovyev.android.plotter.Function0.java
org.solovyev.android.plotter.Function1.java
org.solovyev.android.plotter.Function2.java
org.solovyev.android.plotter.Function.java
org.solovyev.android.plotter.LineStyle.java
org.solovyev.android.plotter.MeshConfig.java
org.solovyev.android.plotter.MultisampleConfigChooser.java
org.solovyev.android.plotter.PinchZoomTracker.java
org.solovyev.android.plotter.PlotData.java
org.solovyev.android.plotter.PlotFunction.java
org.solovyev.android.plotter.PlotRenderer.java
org.solovyev.android.plotter.PlotView.java
org.solovyev.android.plotter.Plot.java
org.solovyev.android.plotter.Plotter.java
org.solovyev.android.plotter.PlottingView.java
org.solovyev.android.plotter.Spf.java
org.solovyev.android.plotter.SuperFunction.java
org.solovyev.android.plotter.TouchHandler.java
org.solovyev.android.plotter.ZoomLevels.java
org.solovyev.android.plotter.Zoomer.java
org.solovyev.android.plotter.app.MainActivity.java
org.solovyev.android.plotter.app.PlotterApplication.java
org.solovyev.android.plotter.meshes.Arrays.java
org.solovyev.android.plotter.meshes.AxisGrid.java
org.solovyev.android.plotter.meshes.Axis.java
org.solovyev.android.plotter.meshes.BaseCube.java
org.solovyev.android.plotter.meshes.BaseCurve.java
org.solovyev.android.plotter.meshes.BaseMesh.java
org.solovyev.android.plotter.meshes.BaseSurface.java
org.solovyev.android.plotter.meshes.DimensionsAwareSwapper.java
org.solovyev.android.plotter.meshes.DimensionsAware.java
org.solovyev.android.plotter.meshes.DoubleBufferGroup.java
org.solovyev.android.plotter.meshes.DoubleBufferMesh.java
org.solovyev.android.plotter.meshes.FunctionGraph2d.java
org.solovyev.android.plotter.meshes.FunctionGraph3d.java
org.solovyev.android.plotter.meshes.FunctionGraphSwapper.java
org.solovyev.android.plotter.meshes.FunctionGraph.java
org.solovyev.android.plotter.meshes.Graph.java
org.solovyev.android.plotter.meshes.Group.java
org.solovyev.android.plotter.meshes.IndicesOrder.java
org.solovyev.android.plotter.meshes.ListGroup.java
org.solovyev.android.plotter.meshes.ListPool.java
org.solovyev.android.plotter.meshes.Mesh.java
org.solovyev.android.plotter.meshes.Meshes.java
org.solovyev.android.plotter.meshes.Pool.java
org.solovyev.android.plotter.meshes.Scene.java
org.solovyev.android.plotter.meshes.SolidCube.java
org.solovyev.android.plotter.meshes.SurfaceInitializer.java
org.solovyev.android.plotter.meshes.WireFrameCube.java