Package net.phys2d.math

Examples of net.phys2d.math.Vector2f.sub()


    // the closest point could be on one of the closest point's edges
    // this happens when the angle between v[m-1]-v[m] and p-v[m] is
    // smaller than 90 degrees, same for v[m+1]-v[m]
    int length = vertices.length;
    Vector2f pm = new Vector2f(p);
    pm.sub(vertices[m]);
    Vector2f l1 = new Vector2f(vertices[(m-1+length)%length]);
    l1.sub(vertices[m]);
    Vector2f l2 = new Vector2f(vertices[(m+1)%length]);
    l2.sub(vertices[m]);
   
View Full Code Here


    // smaller than 90 degrees, same for v[m+1]-v[m]
    int length = vertices.length;
    Vector2f pm = new Vector2f(p);
    pm.sub(vertices[m]);
    Vector2f l1 = new Vector2f(vertices[(m-1+length)%length]);
    l1.sub(vertices[m]);
    Vector2f l2 = new Vector2f(vertices[(m+1)%length]);
    l2.sub(vertices[m]);
   
    Vector2f normal;
    if ( pm.dot(l1) > 0 ) {
View Full Code Here

    Vector2f pm = new Vector2f(p);
    pm.sub(vertices[m]);
    Vector2f l1 = new Vector2f(vertices[(m-1+length)%length]);
    l1.sub(vertices[m]);
    Vector2f l2 = new Vector2f(vertices[(m+1)%length]);
    l2.sub(vertices[m]);
   
    Vector2f normal;
    if ( pm.dot(l1) > 0 ) {
      normal = MathUtil.getNormal(vertices[(m-1+length)%length], vertices[m]);
    } else if ( pm.dot(l2) > 0 ) {
View Full Code Here

   * @param b The vector to subtract
   * @return A newly created containing the result
   */
  public static Vector2f sub(ROVector2f a,ROVector2f b) {
    Vector2f temp = new Vector2f(a);
    temp.sub(b);
   
    return temp;
  }
 
  /**
 
View Full Code Here

   * @param y endpoint of the line
   * @return a (normalised) normal
   */
  public static Vector2f getNormal(ROVector2f x, ROVector2f y) {
    Vector2f normal = new Vector2f(y);
    normal.sub(x);
   
    normal = new Vector2f(normal.y, -normal.x);
    normal.normalise();
   
    return normal;
View Full Code Here

   *
   * @return The change in position in the last update
   */
  public ROVector2f getPositionDelta() {
    Vector2f vec = new Vector2f(getPosition());
    vec.sub(getLastPosition());
   
    return vec;
  }
 
  /**
 
View Full Code Here

   *
   * @return The change in velocity in the last update
   */
  public ROVector2f getVelocityDelta() {
    Vector2f vec = new Vector2f(getVelocity());
    vec.sub(getLastVelocity());
   
    return vec;
  }
 
  /**
 
View Full Code Here

    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Matrix2f rot1T = rot1.transpose();
    Matrix2f rot2T = rot2.transpose();

    Vector2f a1 = new Vector2f(body2.getPosition());
    a1.sub(body1.getPosition());
    localAnchor1 = MathUtil.mul(rot1T,a1);
    Vector2f a2 = new Vector2f(body1.getPosition());
    a2.sub(body2.getPosition());
    localAnchor2 = MathUtil.mul(rot2T,a2);
View Full Code Here

    Vector2f a1 = new Vector2f(body2.getPosition());
    a1.sub(body1.getPosition());
    localAnchor1 = MathUtil.mul(rot1T,a1);
    Vector2f a2 = new Vector2f(body1.getPosition());
    a2.sub(body2.getPosition());
    localAnchor2 = MathUtil.mul(rot2T,a2);

    accumulatedImpulse.set(0.0f, 0.0f);
    relaxation = 1.0f;
  }
View Full Code Here

    Vector2f p1 = new Vector2f(body1.getPosition());
    p1.add(r1);
    Vector2f p2 = new Vector2f(body2.getPosition());
    p2.add(r2);
    Vector2f dp = new Vector2f(p2);
    dp.sub(p1);
   
    bias = new Vector2f(dp);
    bias.scale(-0.1f);
    bias.scale(invDT);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.