Anzeige
Please help us to solve this question by using Java codes and to plot.docx
Please help us to solve this question by using Java codes and to plot.docx
Please help us to solve this question by using Java codes and to plot.docx
Nächste SlideShare
Digital ElectronicsDigital Electronics
Wird geladen in ... 3
1 von 3
Anzeige

Más contenido relacionado

Más de rtodd19(20)

Anzeige

Please help us to solve this question by using Java codes and to plot.docx

  1. Please help us to solve this question by using Java codes and to plot graph of it!!! Solution package examples; import java.io.*; import java.util.*; import sos.db.*; public boolean checkBounds() { if(bX1 == bX2 || bY1 == bY2) { return false; } double xa = 0D; double ya = 0D; int a = 0; boolean hC = false; double xn = 0D; double yn = 0D; for(double[] vertex : this.getShape().getVerticies()) { if(vertex[0] >= bX2) { xa += vertex[0]; ya += vertex[1]; a++; hC = true; xn -= 1D; } if(vertex[0] <= bX1) { xa += vertex[0]; ya += vertex[1]; a++; hC = true; xn += 1D; } if(vertex[1] >= bY2) {
  2. xa += vertex[0]; ya += vertex[1]; a++; hC = true; yn -= 1D; } if(vertex[1] <= bY1) { xa += vertex[0]; ya += vertex[1]; a++; hC = true; yn += 1D; } } if(hC) { Vec2 n = new Vec2(xn, yn).uscale(); Vec2 cp = new Vec2(xa / a, ya / a); Vec2 rap = cp.sub(getShape().getCM()); Vec2 va = getVelocityAt(rap); Vec2 rva = va; Vec2 rvb = Vec2.ZERO_VEC.sub(va); double pj = -(1D + getElasticity()) * rva.dot(n); double j = pj / (1 / getShape().getMass() + Math.pow(rap.cross(n), 2D) / getShape().getMass()); applyForce(new AppliedForce(n.scale(j), rap, getShape().getMass())); } return hC; } public void applyForce(AppliedForce... f) { for(AppliedForce vec : f) { Vec2 a = vec.getForce().divide(getShape().getMass()); applyLinearAcceleration(a); double aa = a.relativeCosine(getShape().getTangent(vec.getOffsetCM())) * a.getMagnitude() / getShape().getMass(); applyAngularAcceleration(aa); } }
Anzeige