Exemple #1
0
  /**
   * Transform a Vector by a matrix and return the result in a destination vector.
   *
   * @param left The left matrix
   * @param right The right vector
   * @param dest The destination vector, or null if a new one is to be created
   * @return the destination vector
   */
  public static Vector2f transform(Matrix2f left, Vector2f right, Vector2f dest) {
    if (dest == null) dest = new Vector2f();

    float x = left.m00 * right.x + left.m10 * right.y;
    float y = left.m01 * right.x + left.m11 * right.y;

    dest.x = x;
    dest.y = y;

    return dest;
  }
Exemple #2
0
 /**
  * 将触摸屏幕的点转换为当前视图下的坐标
  *
  * @param touch
  */
 public void touchToWorld(Vector2f touch) {
   touch.x = (touch.x / glGraphics.getWidth()) * FrumWidth * zoom;
   touch.y = (touch.y / glGraphics.getHeight()) * FrumHeigh * zoom;
   // 在当前坐标系下的坐标
   touch.add(postion).sub(FrumWidth * zoom / 2, FrumHeigh * zoom / 2);
 }
Exemple #3
0
  /**
   * Multiplies this matrix with the vector and returns the resulting vector.
   *
   * @param v The vector to multiply this matrix with from the right hand side.
   * @return The result of the multiplication.
   */
  public Vector2f multiply(Vector2f v) {
    float x = m00 * v.x() + m01 * v.y();
    float y = m10 * v.x() + m11 * v.y();

    return new Vector2f(x, y);
  }