Package eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.math

Examples of eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.math.Matrix2f


   * @param invDT The amount of time the simulation is being stepped by
   */
  @Override
    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


   */
  @Override
    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 eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Joint#applyImpulse()
   */
  @Override
    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

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

    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    Matrix2f rot1T = rot1.transpose();
    Vector2f a1 = new Vector2f(anchor1);
    a1.sub(body1.getPosition());
    localAnchor1 = MathUtil.mul(rot1T,a1);
   
    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Matrix2f rot2T = rot2.transpose();
    Vector2f a2 = new Vector2f(anchor2);
    a2.sub(body2.getPosition());
    localAnchor2 = MathUtil.mul(rot2T,a2);
  }
View Full Code Here

    // but here it can
    float springConst;
   
    if ( springLength < minSpringSize || springLength > maxSpringSize ) {
      // 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);
     
      // the mass normal or 'k'
View Full Code Here

  /**
   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Joint#preStep(float)
   */
  @Override
    public void preStep(float invDT) {
    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

   * @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

TOP

Related Classes of eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.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.