Package net.phys2d.math

Examples of net.phys2d.math.Matrix2f


   * @see net.phys2d.raw.Joint#preStep(float)
   */
  public void preStep(float invDT) {
    float biasFactor=0.01f;
    float biasImpulse=0.0f;
    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    Matrix2f rot2 = new Matrix2f(body2.getRotation());

     r1 = MathUtil.mul(rot1,anchor1);
     r2 = MathUtil.mul(rot2,anchor2);
   
    Vector2f p1 = new Vector2f(body1.getPosition());
View Full Code Here


   * @param pos The centre of the box
   * @param rotation The rotation of the box
   * @return The points building up a box at this position and rotation
   */
  public Vector2f[] getPoints(ROVector2f pos, float rotation) {
    Matrix2f R = new Matrix2f(rotation);
    Vector2f[] pts = new Vector2f[4];
    ROVector2f h = MathUtil.scale(getSize(),0.5f);

    pts[0] = MathUtil.mul(R, new Vector2f(-h.getX(), -h.getY()));
    pts[0].add(pos);
View Full Code Here

   */
  public void set(Body b1, Body b2) {
    body1 = b1;
    body2 = b2;

    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    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());
View Full Code Here

   *
   * @param invDT The amount of time the simulation is being stepped by
   */
  public void preStep(float invDT) {
    // Pre-compute anchors, mass matrix, and bias.
    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    Matrix2f rot2 = new Matrix2f(body2.getRotation());

    r1 = MathUtil.mul(rot1,localAnchor1);
    r2 = MathUtil.mul(rot2,localAnchor2);

    // deltaV = deltaV0 + K * impulse
    // invM = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) * invI2 * skew(r2)]
    //      = [1/m1+1/m2     0    ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y]
    //        [    0     1/m1+1/m2]           [-r1.x*r1.y r1.x*r1.x]           [-r1.x*r1.y r1.x*r1.x]
    Matrix2f K1 = new Matrix2f();
    K1.col1.x = body1.getInvMass() + body2.getInvMass();  K1.col2.x = 0.0f;
    K1.col1.y = 0.0f;                K1.col2.y = body1.getInvMass() + body2.getInvMass();

    Matrix2f K2 = new Matrix2f();
    K2.col1.x =  body1.getInvI() * r1.y * r1.y;    K2.col2.x = -body1.getInvI() * r1.x * r1.y;
    K2.col1.y = -body1.getInvI() * r1.x * r1.y;    K2.col2.y =  body1.getInvI() * r1.x * r1.x;

    Matrix2f K3 = new Matrix2f();
    K3.col1.x =  body2.getInvI() * r2.y * r2.y;    K3.col2.x = -body2.getInvI() * r2.x * r2.y;
    K3.col1.y = -body2.getInvI() * r2.x * r2.y;    K3.col2.y =  body2.getInvI() * r2.x * r2.x;

    Matrix2f K = MathUtil.add(MathUtil.add(K1,K2),K3);
    M = K.invert();

    Vector2f p1 = new Vector2f(body1.getPosition());
    p1.add(r1);
    Vector2f p2 = new Vector2f(body2.getPosition());
    p2.add(r2);
View Full Code Here

   * @see net.phys2d.raw.Joint#applyImpulse()
   */
  public void applyImpulse() {
    if (bounceSide == BOUNCE_NONE)
      return;
    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Vector2f r1 = MathUtil.mul(rot1, anchor1);
    Vector2f r2 = MathUtil.mul(rot2, anchor2);

    Vector2f relativeVelocity = new Vector2f(body2.getVelocity());
    relativeVelocity.add(MathUtil.cross(r2, body2.getAngularVelocity()));
View Full Code Here

    float RB = body1.getRotation() + rotateB;

    Vector2f VA = new Vector2f((float) Math.cos(RA), (float) Math.sin(RA));
    Vector2f VB = new Vector2f((float) Math.cos(RB), (float) Math.sin(RB));

    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Vector2f r1 = MathUtil.mul(rot1, anchor1);
    Vector2f r2 = MathUtil.mul(rot2, anchor2);

    Vector2f p1 = new Vector2f(body1.getPosition());
    p1.add(r1);
View Full Code Here

  /**
   * @see net.phys2d.raw.Joint#applyImpulse()
   */
  public void applyImpulse() {
    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Vector2f r1 = MathUtil.mul(rot1, anchor1);
    Vector2f r2 = MathUtil.mul(rot2, anchor2);

    Vector2f relativeVelocity = new Vector2f(body2.getVelocity());
    relativeVelocity.add(MathUtil.cross(r2, body2.getAngularVelocity()));
View Full Code Here

    float biasImpulse = 0.0f;
    float RA = body1.getRotation() + rotateA;

    Vector2f VA = new Vector2f((float) Math.cos(RA), (float) Math.sin(RA));

    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Vector2f r1 = MathUtil.mul(rot1, anchor1);
    Vector2f r2 = MathUtil.mul(rot2, anchor2);

    Vector2f p1 = new Vector2f(body1.getPosition());
    p1.add(r1);
View Full Code Here

    return i;
  }

  private strictfp void computeIncidentEdge(ClipVertex[] paramArrayOfClipVertex, ROVector2f paramROVector2f1, ROVector2f paramROVector2f2, Matrix2f paramMatrix2f, Vector2f paramVector2f)
  {
    Matrix2f localMatrix2f = paramMatrix2f.transpose();
    Vector2f localVector2f1 = MathUtil.scale(MathUtil.mul(localMatrix2f, paramVector2f), -1.0F);
    Vector2f localVector2f2 = MathUtil.abs(localVector2f1);
    if (localVector2f2.x > localVector2f2.y)
    {
      if (MathUtil.sign(localVector2f1.x) > 0.0F)
View Full Code Here

    hA.scale(0.5F);
    hB.set(((Box)paramBody2.getShape()).getSize());
    hB.scale(0.5F);
    ROVector2f localROVector2f1 = paramBody1.getPosition();
    ROVector2f localROVector2f2 = paramBody2.getPosition();
    Matrix2f localMatrix2f1 = new Matrix2f(paramBody1.getRotation());
    Matrix2f localMatrix2f2 = new Matrix2f(paramBody2.getRotation());
    Matrix2f localMatrix2f3 = localMatrix2f1.transpose();
    Matrix2f localMatrix2f4 = localMatrix2f2.transpose();
    Vector2f localVector2f1 = MathUtil.sub(localROVector2f2, localROVector2f1);
    Vector2f localVector2f2 = MathUtil.mul(localMatrix2f3, localVector2f1);
    Vector2f localVector2f3 = MathUtil.mul(localMatrix2f4, localVector2f1);
    Matrix2f localMatrix2f5 = MathUtil.mul(localMatrix2f3, localMatrix2f2);
    Matrix2f localMatrix2f6 = MathUtil.abs(localMatrix2f5);
    Matrix2f localMatrix2f7 = localMatrix2f6.transpose();
    Vector2f localVector2f4 = MathUtil.abs(localVector2f2);
    localVector2f4.sub(hA);
    localVector2f4.sub(MathUtil.mul(localMatrix2f6, hB));
    if ((localVector2f4.x > 0.0F) || (localVector2f4.y > 0.0F))
      return 0;
View Full Code Here

TOP

Related Classes of net.phys2d.math.Matrix2f

Copyright © 2018 www.massapicom. 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.