Android Open Source - 4est Pattern






From Project

Back to project page 4est.

License

The source code is released under:

MIT License

If you think the Android project 4est 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.wordsaretoys.rise.pattern;
/*from   www  . ja va 2  s  . c  om*/

/**
 * classes and interfaces that generalize pattern generation 
 */
public class Pattern {
  
  /*
   * interfaces for real-valued functions
   */
  
  public interface F1F {
    public float get(float x);
  }

  public interface F2F {
    public float get(float x, float y);
  }
  
  public interface F3F {
    public float get(float x, float y, float z);
  }

  /*
   * interfaces for integer-valued functions
   */
  
  public interface I1F {
    public float get(int x);
  }

  public interface I2F {
    public float get(int x, int y);
  }
  
  public interface I3F {
    public float get(int x, int y, int z);
  }
  
  public interface I2I {
    public int get(int x, int y);
  }
  
  /**
   * cosine interpolation between two points
   */
  public static float cerp(float y0, float y1, float mu) {
    float m2 = (float)(1 - Math.cos(mu * Math.PI)) * 0.5f;
    return (1 - m2) * y0 + m2 * y1;
  }
  
  /**
   * cosine interpolation of I2F function
   */
  public static float ipolate(I2F f, float x, float y) {
    int ix = (int)Math.floor(x);
    float fx = x - ix;
    if (fx < 0) {
      fx += 1;
    }
    
    int iy = (int)Math.floor(y);
    float fy = y - iy;
    if (fy < 0) {
      fy += 1;
    }
    
    float s0 = f.get(ix, iy);
    float s1 = f.get(ix + 1, iy);
    float s2 = f.get(ix, iy + 1);
    float s3 = f.get(ix + 1, iy + 1);
    
    float s01 = cerp(s0, s1, fx);
    float s23 = cerp(s2, s3, fx);
    return cerp(s01, s23, fy);
  }
  
}




Java Source Code List

com.wordsaretoys.forest.Audio.java
com.wordsaretoys.forest.Debris.java
com.wordsaretoys.forest.Game.java
com.wordsaretoys.forest.GlView.java
com.wordsaretoys.forest.MainActivity.java
com.wordsaretoys.forest.Map.java
com.wordsaretoys.forest.Player.java
com.wordsaretoys.forest.Render.java
com.wordsaretoys.forest.Rotors.java
com.wordsaretoys.forest.Shared.java
com.wordsaretoys.forest.Skybox.java
com.wordsaretoys.rise.geometry.Camera.java
com.wordsaretoys.rise.geometry.Geom.java
com.wordsaretoys.rise.geometry.Mote.java
com.wordsaretoys.rise.geometry.Ortho.java
com.wordsaretoys.rise.geometry.Quaternion.java
com.wordsaretoys.rise.geometry.Vector.java
com.wordsaretoys.rise.glwrapper.Mesh.java
com.wordsaretoys.rise.glwrapper.Shader.java
com.wordsaretoys.rise.glwrapper.Texture.java
com.wordsaretoys.rise.meshutil.HeightMapper.java
com.wordsaretoys.rise.meshutil.IndexBuffer.java
com.wordsaretoys.rise.meshutil.SurfaceMapper.java
com.wordsaretoys.rise.meshutil.VertexBuffer.java
com.wordsaretoys.rise.meshutil.Vindexer.java
com.wordsaretoys.rise.pattern.Bitmap.java
com.wordsaretoys.rise.pattern.F2FSumMap.java
com.wordsaretoys.rise.pattern.I2FCutMap.java
com.wordsaretoys.rise.pattern.I2FMap.java
com.wordsaretoys.rise.pattern.I2IMap.java
com.wordsaretoys.rise.pattern.Pattern.java
com.wordsaretoys.rise.pattern.Ring.java
com.wordsaretoys.rise.utility.Asset.java
com.wordsaretoys.rise.utility.Board.java
com.wordsaretoys.rise.utility.Dbg.java
com.wordsaretoys.rise.utility.Interval.java
com.wordsaretoys.rise.utility.Misc.java
com.wordsaretoys.rise.utility.Needle.java