I'm developing some lecture notes on numerical methods in an ipython notebook, and I need to include some coordinate transformation functions. I've already coded these functions (below), but the details aren't exactly fundamental to the topic, and it would simplify the lecture if I could call pre-written functions.
I see the scipy image rotation function, but I just need coordinate translation and rotation. ie
# transform from global to panel coordinates
def transformXY( self, x, y ):
xp = x-self.xc
yp = y-self.yc
xpp = xp*self.sx+yp*self.sy
ypp = yp*self.sx-xp*self.sy
return [ xpp, ypp ]
# rotate velocity back to global coordinates
def rotateUV( self, u, v):
up = u*self.sx-v*self.sy
vp = v*self.sx+u*self.sy
return [ up, vp ]
In these, sx
and sy
are the unit tangent vector components.