static private void vp(List <Body> bv, int nstep) { MathVector dacc = MathVector.makeMathVector(); MathVector dvel = MathVector.makeMathVector(); double dthf = 0.5 * BH.DTIME; for (int i = 0; i < bv.Count; ++i) { Body b = bv[i]; MathVector acc1 = b.newAcc.cloneMathVector(); if (nstep > 0) { dacc.subtraction2(acc1, b.acc); dvel.multScalar2(dacc, dthf); dvel.addition(b.vel); b.vel = dvel.cloneMathVector(); } b.acc = acc1.cloneMathVector(); dvel.multScalar2(b.acc, dthf); MathVector vel1 = b.vel.cloneMathVector(); vel1.addition(dvel); MathVector dpos = vel1.cloneMathVector(); dpos.multScalar1(BH.DTIME); dpos.addition(b.pos); b.pos = dpos.cloneMathVector(); vel1.addition(dvel); b.vel = vel1.cloneMathVector(); } }
/** * Descend tree finding center of mass coordinates * * @return the mass of this node */ public override double hackcofm() { double mq = 0.0; MathVector tmpPos = MathVector.makeMathVector(); MathVector tmpv = MathVector.makeMathVector(); for (int i = 0; i < NSUB; i++) { Node r = this.subp[i]; if (r != null) { double mr = r.hackcofm(); mq = mr + mq; tmpv.multScalar2(r.pos, mr); tmpPos.addition(tmpv); } } mass = mq; pos = tmpPos; pos.divScalar(mass); return(mq); }