440,630 Members | 1,252 Online Need help? Post your question and get tips & solutions from a community of 440,630 IT Pros & Developers. It's quick & easy.

# Transforming the Point using list

 100+ P: 440 Hi, I have a Point and Transfoirmation matrix.How to translate the Point from one Coordinate system to other using list . Point1 = [1,2,3] #Transformation Matrix T = [ [1,0,0], [0,1,0], [0,0,1]] I have to get the TransPoint = Point1 * T Other than list,is there any other approach is possible to get the transformation of point Thanks PSB Jun 6 '07 #1
5 Replies

 Expert Mod 2.5K+ P: 2,851 Hi, I have a Point and Transfoirmation matrix.How to translate the Point from one Coordinate system to other using list . Point1 = [1,2,3] #Transformation Matrix T = [ [1,0,0], [0,1,0], [0,0,1]] I have to get the TransPoint = Point1 * T Other than list,is there any other approach is possible to get the transformation of point Thanks PSB The transformation matrix you have defined (T) is the standard orthonormal basis for R3. What is the basis for Point 1? Given an orthonormal basis in R3, a point relative to that basis can be translated to the standard basis : Expand|Select|Wrap|Line Numbers from macrolib.PointPlane3D import Point   def determinant3(a,b,c,m,n,k,u,v,w):         return a*n*w + b*k*u + m*v*c - c*n*u - b*m*w - a*k*v   def translate(A, B, N, pt):       X,Y,Z = tuple(pt)           '''     Normalize pt     '''     M = (X*X + Y*Y + Z*Z)**0.5     try:         X1, Y1, Z1 = X/M, Y/M, Z/M     except:         X1, Y1, Z1 = 0.0, 0.0, 0.0       D = determinant3(A.x, A.y, A.z, N.x, N.y, N.z, B.x, B.y, B.z)     Dx = determinant3(X1, A.y, A.z, Z1, N.y, N.z, Y1, B.y, B.z)     Dy = determinant3(A.x, X1, A.z, N.x, Z1, N.z, B.x, Y1, B.z)     Dz = determinant3(A.x, A.y, X1, N.x, N.y, Z1, B.x, B.y, Y1)       '''             Calculate the resultant unit vector 'R1'     '''     R1 = Point(Dx/D, Dy/D, Dz/D)       '''     Return the global coordinate vector     '''     return R1*M   # local basis 'X' a = Point(0.462352, 0.850215, 0.251725) # local basis 'Y' b = Point(0.791086, -0.267295, -0.550215) # local basis 'Z' n = Point(-0.400516, 0.453529, -0.796177)   print repr(translate(a, b, n, Point(12,12,12)))   ''' >>> Point(10.235071, 12.437392, -13.136013) ''' Please, check my math! Given three non-collinear points in R3, you can define an orthonormal basis. Let's say point1 is the basis origin, point2 defines the X axis with respect to the origin, and point 3, in combination with p1 and p2, defines the plane: Expand|Select|Wrap|Line Numbers >>> c.p1 Point(144.000000, 256.000000, 300.000000) >>> c.p2 Point(324.000000, 587.000000, 398.000000) >>> c.p3 Point(645.000000, 400.000000, 130.000000) >>> a = BasisTransToGlobal(c.p1, c.p2, c.p3, Point(12,12,12)) >>> a.R Point(154.235075, 268.437392, 286.863999) >>> a.R-c.p1 Point(10.235075, 12.437392, -13.136001) >>>  BTW - This should have been posted to Python Forum instead of Python Articles. Jun 6 '07 #2

 Expert 5K+ P: 6,596 Moved from Python Articles Please be careful not to post questions in the Articles section. Thanks you for your co-operation in this matter. Jun 7 '07 #3

 Expert 2.5K+ P: 3,235 Jinkies bvdet! That was amazing! Jun 7 '07 #4

 Expert Mod 2.5K+ P: 2,851 Jinkies bvdet! That was amazing! Nuthin' to it Motoma. I've been working on this module for about a year (in my spare time of course). Jun 8 '07 #5

 Expert Mod 2.5K+ P: 2,851 Here's the return trip: Expand|Select|Wrap|Line Numbers def transToLocal(pt, m):     '''     pt - point object in the standard R3 orthonormal basis     vA - local 'X' unit vector     vB - local 'Y' unit vector     vN - local 'Z' unit vector       'dot()' is a Point object method that returns the dot product           Return the local coordinate     Vector projection of: pt along vA, pt along vB, pt along vN     '''     return Point(pt.dot(Point(*m)), \                  pt.dot(Point(*m)), \                  pt.dot(Point(*m)))   # Local basis translation matrix m = [(0.462352, 0.850215, 0.251725), \      (0.791086, -0.267295, -0.550215), \      (-0.400516, 0.453529, -0.796177)] # Point object in standard orthonormal basis pt = Point(10.235071, 12.437392, -13.136013)   print repr(transToLocal(pt, m)) # Point(12.000000, 12.000000, 12.000000) Jun 8 '07 #6 