Android Open Source - splott Geom






From Project

Back to project page splott.

License

The source code is released under:

MIT License

If you think the Android project splott 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.geometry;
//from  www.ja  va 2 s  . com
import java.util.Arrays;

/**
 * miscellaneous operations
 */
public class Geom {

  /**
   * load orientation vectors into a 4x4 matrix
   * all vectors should be normalized!
   */
  public static void loadMatrix(float[] m, Vector front, Vector up, Vector right) {
    Arrays.fill(m, 0);
    m[0] = right.x;
    m[1] = right.y;
    m[2] = right.z;
    m[4] = up.x;
    m[5] = up.y;
    m[6] = up.z;
    m[8] = front.x;
    m[9] = front.y;
    m[10] = front.z;
    m[15] = 1;
  }

  /**
   * copies rotation components from 4x4 matrix to 3x3 matrix
   */
  public static void copyM4To3(float[] m3, float[] m4) {
    int i3 = 0, i4 = 0;
    
    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++];
  }
  
  /**
   * tests intersection between two squares
   */
  public static boolean squaresIntersect(float x0, float y0, float l0, float x1, float y1, float l1) {
    return   (x0 < (x1 + l1) && (x0 + l0) > x1) && 
        (y0 < (y1 - l1) && (y0 - l0) > y1);
  }
  
  /**
   * returns true if point in square
   * note that sx, sy is the CORNER point
   */
  public static boolean pointInSquare(float x, float y, float sx, float sy, float sl) {
    return (x >= sx) && (x <= (sx + sl)) && (y >= sy) && (sy <= (sy + sl));
  }
}




Java Source Code List

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
com.wordsaretoys.splott.MainActivity.java
com.wordsaretoys.splott.parser.Compiler.java
com.wordsaretoys.splott.parser.SurfaceBaseListener.java
com.wordsaretoys.splott.parser.SurfaceLexer.java
com.wordsaretoys.splott.parser.SurfaceListener.java
com.wordsaretoys.splott.parser.SurfaceParser.java
com.wordsaretoys.splott.parser.SyntaxChecker.java
com.wordsaretoys.splott.parser.Vm.java
com.wordsaretoys.splott.plotter.GlView.java
com.wordsaretoys.splott.plotter.Render.java
com.wordsaretoys.splott.plotter.Surface.java