Also, please use code-tags when posting code rather than a wall of plain-text.
FYI: There’s also a dedicated physics sub-forum here.
Thanks.