-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem getting morphed binary stars code to work #26
Comments
Update -- when I replaced the radius arg with a size vector arg for the spheres the code started working from glow import * glow('pydiv') scene.forward = vec(0,-.3,-1).to_glowscript() G = 6.7e-11 giant = sphere(pos=vec(-1e11,0,0), size=vec(2e10,2e10,2e10), color=color.red,make_trail=True, trail_type='points', interval=10, retain=50) dwarf = sphere(pos=vec(1.5e11,0,0), size=vec(1e10,1e10,1e10), color=color.yellow,make_trail=True,trail_type='points', interval=10, retain=40) dt = 1e5 move() |
Actually one of the issues above -- the (a) issue -- is because you cant do Number*vec(): from glow import * a=vec(1,2,1) |
Thanks for reporting this issue, and figuring out most of the issues. I'll look into adding/fixing the issue dealing with multiplying a vector by a number. |
This program below is an attempt to implement the one here : http://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/BinaryStar-VPython/edit
but it doesnt work.. This was on Chrome beta 42.0 on Ubuntu 14.04
Notes:
(a) I replaced the while True with the recursive version as in Pyschool's bounce
(a) There seem to be some associative rule issues : the expression
F = G * giant.mass * dwarf.mass * norm(r) / mag2(r)
doesnt work even with r.norm() and r.mag2() so that I had to use :
coeff = G * giant.mass * dwarf.mass/r.mag2()
F = r.norm() * coeff
to make it work..
(b) Initially I had the make_trail params to the spheres left as in the original vPython. But the program seemed to be executing with canvas/scene completely blank. Since I recall reading somewhere that make_trail had issues in brython-glow, I removed the make_trail params but still the canvas/scene is blank..
from glow import *
glow('pydiv')
scene = canvas()
scene.forward = vec(0,-.3,-1).to_glowscript()
G = 6.7e-11
giant = sphere(pos=vec(-1e11,0,0), radius=2e10, color=color.red)
giant.mass = 2e30
giant.p = vec(0, 0, -1e4) * giant.mass
dwarf = sphere(pos=vec(1.5e11,0,0), radius=1e10, color=color.yellow)
dwarf.mass = 1e30
dwarf.p = vec(0,0,0)-giant.p
r = dwarf.pos - giant.pos
coeff = G * giant.mass * dwarf.mass/r.mag2()
q = r.norm()*coeff
print("q",q)
dt = 1e5
def move():
r = dwarf.pos - giant.pos
#F = G * giant.mass * dwarf.mass * norm(r) / mag2(r)
coeff = G * giant.mass * dwarf.mass/r.mag2()
F = r.norm() * coeff
giant.p = giant.p + F_dt
dwarf.p = dwarf.p - F_dt
giant.pos = giant.pos + (giant.p/giant.mass) * dt
dwarf.pos = dwarf.pos + (dwarf.p/dwarf.mass) * dt
print("start exec")
move()
The text was updated successfully, but these errors were encountered: