def main(): vel = t.getVector3d("Velocity :") pos = t.getVector3d("Position :", [0, 0, 0]) # org = t.getVector3d("Origin :",[0,0,0]) left = p.Particle(pos, vel, mass=5, title="Left") right = p.Particle(pos, -3.0 * vel, mass=10, title="Right") t.tprint(left) t.tprint(right) mom = left.getLinearMomentum() + right.getLinearMomentum() k = left.getKineticEnergy() + right.getKineticEnergy() t.tprint("Inital linear momentum is : ", mom) t.tprint("Initial Energy is : ", k) left.elasticCollision(right) t.tprint(left) t.tprint(right) mom = left.getLinearMomentum() + right.getLinearMomentum() k = left.getKineticEnergy() + right.getKineticEnergy() t.tprint("Final linear momentum is : ", mom) t.tprint("Final Energy is : ", k)
def main(): ps = p.ParticleSystem().readFile(t.openFile("File",defaulttype="part")) t.tprint(ps) while True: pos = t.getVector3d("Position") ef = ps.getElectrostaticPotential(pos) t.tprint("Field at : ",pos," is : ",ef)
def main(): xdata = [] ydata = [] a = t.getVector3d("Central", [5, 1, 0]) t.tprint(a) for i in range(0, 100): x = i / 10.0 xdata.append(x) b = v.Vector3d(x, 0, 0) f = a.inverseSquare(b, -1.0) t.tprint(f), ydata.append(abs(f)) pt.plot(xdata, ydata) pt.show()
def main(): a = tio.getVector3d("Give a vector",[1,2,3]) tio.tprint(repr(a)) r,u = a.unitPair() tio.tprint("Abs is : ",r," Unit is : ",u) u = v.Unit3d(a) tio.tprint("Unit vector is " , repr(u)) ang = v.Angle(u) tio.tprint("Angle of u is ", repr(ang)) ang = v.Angle(a) tio.tprint("Angle of a is ", repr(ang)) w = v.Unit3d(ang) tio.tprint("Unit 3d from angle is ",w) d = tio.getAngle("Give angle pair",[0.5,0.6]) tio.tprint(repr(d))
def main(): f = tio.openFile("Give file","r","lens") for l in f.readlines(): tio.tprint(l) z = tio.getComplex("Give complex",complex(1,1)) tio.tprint("Complex is " + repr(z)) v = tio.getVector3d("Vector") tio.tprint("vector is : " + repr(v)) options = ["start","close","quit","restart"] n,nopt = tio.getOption("Option",options) tio.tprint("Option {0:d} chosen, name is {1:s}".format(n,nopt)) x = tio.getFloat("float",3.0,0.0,5.0) tio.tprint(x) st = tio.getString("and a string") tio.tprint(st)