Android Open Source - 4est Misc






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.utility;
//from w w w.  j av  a  2s .  c  om
public class Misc {

  static final long prime1 = 961748941L;
  static final long prime2 = 961750903L;
  static final long prime3 = 961813667L;
  static final long prime4 = 982449059L;
  
  /**
   * clamp a number to limits
   * 
   * @param x number to clamp
   * @param l number representing lower bound
   * @param u number representing upper bound
   * @return clamped value
   */
  
  static public float clamp(float x, float l, float u) {
    if (x < l)
        return l;
    if (x > u)
        return u;
    return x;
  }
  
  /**
   * scale a number to specified limits
   * 
   * @param x number in range (0..1)
   * @param l lower bound
   * @param u upper bound
   * @return scaled value
   */
  
  static public float scale(float x, float l, float u) {
    return l + (u - l) * x;
  }

  /**
   * generate a hash value for a floating point vector
   */
  static public long hash(float x, float y, float z, long w) {
    return   (long)(x * prime1) ^ (long)(y * prime2) ^ 
        (long)(z * prime3) ^ (long)(w * prime4);
  }

  /**
   * copies rotation components from 4x4 matrix(es) to 3x3 matrix(es)
   * @param m3 array representing 3x3 matrix(es)
   * @param m3offset offset into 3x3 matrix array
   * @param m4 array representing 4x4 matrix(es)
   * @param m4offset offset into 4x4 matrix array
   */
  static public void copyM4To3(float[] m3, int m3offset, float[] m4, int m4offset) {
    int i3 = m3offset;
    int i4 = m4offset;
    
    m3[i3++] = m4[i4++];
    m3[i3++] = m4[i4++];
    m3[i3++] = m4[i4++];
    i4++;
    m3[i3++] = m4[i4++];
    m3[i3++] = m4[i4++];
    m3[i3++] = m4[i4++];
    i4++;
    m3[i3++] = m4[i4++];
    m3[i3++] = m4[i4++];
    m3[i3++] = m4[i4++];
  }
  
}




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