Ejemplo n.º 1
0
  Vec calc_collide_power(Ball p1, Ball p2, double dist) {
    if (dist > radius * 2) return new Vec(); // Friday, August 29, 2008 15:26:33: stickiness bug fix
    Vec speed_diff = p2.speed.sub(p1.speed);
    double force = 1000 * (dist - radius * 2);
    Vec npos1 = p1.pos.div(dist); // normalized
    Vec npos2 = p2.pos.div(dist);
    force += 10 * speed_diff.dot_mult(npos2.sub(npos1));
    Vec ans = npos2.sub(npos1).mult(force);
    return ans;
    /*    colide_power_x=force*(x2-x1)/dist;
    colide_power_y=force*(y2-y1)/dist;*/

  }
Ejemplo n.º 2
0
  Vec calc_spring_power(Ball p1, Ball p2) {
    double dist = p1.pos.calc_dist(p2.pos);
    // if (abs(dist-STRING_LEN)<.1)
    //	return;
    Vec speed_diff = p2.speed.sub(p1.speed);
    double force = 1000 * (dist - STRING_LEN);
    Vec npos1 = p1.pos.div(dist); // normalized
    Vec npos2 = p2.pos.div(dist);
    force += 100 * speed_diff.dot_mult(npos2.sub(npos1));
    Vec ans = npos2.sub(npos1).mult(force);
    return ans;
    // force*=force;
    //    colide_power_x=(x2-x1)/dist*force;
    //   colide_power_y=(y2-y1)/dist*force;

  }