Nevada
2007.03.10, 02:17 PM
I have a simple but very frustrating problem with Python. I know it should have a simple answer, but I'm just not familiar enough with Python to figure it out.
I need to do a 90 degree rotation of a velocity vector, but I'm having some trouble with the fact that Python, unlike C, treats assigned variables like pointers, rather than copies. My code is similar to this:
oldx = x
x = y
y = -oldx
The problem is that setting x = y also sets oldx = y, so I just get x = y and y = -y. Does anyone know how I can get a copy of a variable?
I need to do a 90 degree rotation of a velocity vector, but I'm having some trouble with the fact that Python, unlike C, treats assigned variables like pointers, rather than copies. My code is similar to this:
oldx = x
x = y
y = -oldx
The problem is that setting x = y also sets oldx = y, so I just get x = y and y = -y. Does anyone know how I can get a copy of a variable?