python - Is there a numpy function to perform coordinate transformations? -
i'm developing lecture notes on numerical methods in ipython notebook, , need include coordinate transformation functions. i've coded these functions (below), details aren't fundamental topic, , simplify lecture if call pre-written functions.
i see scipy image rotation function, need coordinate translation , rotation. ie
# transform global 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 global coordinates def rotateuv( self, u, v): = u*self.sx-v*self.sy vp = v*self.sx+u*self.sy return [ up, vp ]
in these, sx
, sy
unit tangent vector components.
copied , expanded previous comment:
you can move own functions separate .py file , import them there. way internals hidden in notebook. if place them in file/module called e.g. transformation.py
, place file next notebook file , can import functions from transformation import *
as has been suggested in deleted answer, recommend using matrices transformation, rotations. in opinion clearer element-wise modifications.
edit: afaik there no predefined coordinate-transformation functions in numpy. in sympy there something, i'm not sure how useful is, seams bit simple transformation. transformations via matrices google found me module, appears quite comprehensive.
Comments
Post a Comment