I am working on a visual python program that is meant to model the orbit of an electron around the core of a Hydrogen atom. In order to avoid the singularity at r = 0 in the equation for coulomb force, I am modelling this scenario in semi-parabolic coordinates. My question then is how can I change from cartesian coordinates to semi-parabolic coordinates within python?
Python – Changing coordinate systems in python
mathphysicspython
Related Solutions
I know this is an old post, but I saw this post being referenced and dislike the chosen answer's tone.
So I did a bit of investigation!
- DirectX is old. It was first released in 1995, when the world had much more than Nvidia and ATI, DirectX vs OpenGL. That's over 15 years, people.
- 3dfx Interactive's Glide (one of DirectX's competitors back in the day. OpenGL wasn't meant for gaming back then) used a left-handed coordinate system.
- POV-Ray and RenderMan (Pixar's rendering software), also use a left-handed coordinate system.
- DirectX 9+ can work with both coordinate systems.
- Both WPF and XNA (which work with DirectX under the scenes) use a right-handed coordinate system.
From this, I can speculate about a couple things:
- Industry standards aren't as standard as people like.
- Direct3D was built in a time everyone did things their own way, and the developers probably didn't know better.
- Left-handedness is optional, but customary in the DirectX world.
- Since conventions die out hard, everyone thinks DirectX can only work with left-handedness.
- Microsoft eventually learned, and followed the standard in any new APIs they created.
Therefore, my conclusion would be:
When they had to choose, they didn't know of the standard, chose the 'other' system, and everyone else just went along for the ride. No shady business, just an unfortunate design decision that was carried along because backward compatibility is the name of Microsoft's game.
The math module is a builtin, so short of modifying the Python interpreter itself, I don't think you can modify it. However, writing a module is definitely something you can do.
If you structure your files like this:
somefolder
mymath.py
myprogram.py
...you could simply do import mymath
inside myprogram.py
, and use any functions or classes inside mymath.py
as normal.
So if mymath.py
looks like this:
def quadratic(a, b, c):
# blah blah blah
You could do the below inside myprogram.py
import mymath
print mymath.quadratic(1, 2, 3)
If you want the module you've written available for any program, you could either copy-and-paste it into the folder of any project you're working on, or add it to your PATH. (For example, you could include mymath.py
inside the site-packages folder, which is located at C:\Python27\Lib\site-packages
on my computer). Once you do that, you should be able to do import mymath
without ever having to copy-and-paste anything.
As a side-note, numpy has a pretty comprehensive set of math and science related functions that you could check out. It's pretty much the de-facto standard for numerical computation in Python, afaik.
Best Answer
I'd start with a pair of functions that converts from one coordinate system to another:
I hope you have the formulas and won't have trouble implementing the functions.
Then you convert the coordinates where it's convenient. I suppose that you should read input values, convert to parabolic, do your calculations, convert back to Cartesian and output.