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

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


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


   */
  public void set(PhysicsAgent2D<?> b1, PhysicsAgent2D<?> b2, Vector2f anchor) {
    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(anchor);
    a1.sub(body1.getPosition());
    localAnchor1 = MathUtil.mul(rot1T,a1);
    Vector2f a2 = new Vector2f(anchor);
View Full Code Here

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

  /**
   * @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());
    r1 = MathUtil.mul(rot1, anchor1);
    r2 = MathUtil.mul(rot2, anchor2);

    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);

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

   */
  public void set(PhysicsAgent2D<?> b1, PhysicsAgent2D<?> 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
   */
  @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 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

                  ROVector2f h,
                  ROVector2f pos,
                  Matrix2f rot, Vector2f normal) {
    // The normal is from the reference box. Convert it
    // to the incident boxe's frame and flip sign.
    Matrix2f rotT = rot.transpose();
    Vector2f n = MathUtil.scale(MathUtil.mul(rotT,normal),-1);
    Vector2f nAbs = MathUtil.abs(n);

    if (nAbs.x > nAbs.y)
    {
View Full Code Here

    //Vector2f hB = MathUtil.scale(bodyB.getSize(), 0.5f);

    ROVector2f posA = bodyA.getPosition();
    ROVector2f posB = bodyB.getPosition();

    Matrix2f rotA = new Matrix2f(bodyA.getRotation());
    Matrix2f rotB = new Matrix2f(bodyB.getRotation());

    Matrix2f RotAT = rotA.transpose();
    Matrix2f RotBT = rotB.transpose();

    // unused?
//    Vector2f a1 = rotA.col1;
//    Vector2f a2 = rotA.col2;
//    Vector2f b1 = rotB.col1;
//    Vector2f b2 = rotB.col2;

    Vector2f dp = MathUtil.sub(posB,posA);
    Vector2f dA = MathUtil.mul(RotAT,dp);
    Vector2f dB = MathUtil.mul(RotBT,dp);

    Matrix2f C = MathUtil.mul(RotAT,rotB);
    Matrix2f absC = MathUtil.abs(C);
    Matrix2f absCT = absC.transpose();

    // Box A faces
    Vector2f faceA = MathUtil.abs(dA);
    faceA.sub(hA);
    faceA.sub(MathUtil.mul(absC,hB));
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

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.