By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,630 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
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
Share this Question
Share on Google+
5 Replies


bvdet
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
  1. from macrolib.PointPlane3D import Point
  2.  
  3. def determinant3(a,b,c,m,n,k,u,v,w):
  4.         return a*n*w + b*k*u + m*v*c - c*n*u - b*m*w - a*k*v
  5.  
  6. def translate(A, B, N, pt):
  7.  
  8.     X,Y,Z = tuple(pt)    
  9.  
  10.     '''
  11.     Normalize pt
  12.     '''
  13.     M = (X*X + Y*Y + Z*Z)**0.5
  14.     try:
  15.         X1, Y1, Z1 = X/M, Y/M, Z/M
  16.     except:
  17.         X1, Y1, Z1 = 0.0, 0.0, 0.0
  18.  
  19.     D = determinant3(A.x, A.y, A.z, N.x, N.y, N.z, B.x, B.y, B.z)
  20.     Dx = determinant3(X1, A.y, A.z, Z1, N.y, N.z, Y1, B.y, B.z)
  21.     Dy = determinant3(A.x, X1, A.z, N.x, Z1, N.z, B.x, Y1, B.z)
  22.     Dz = determinant3(A.x, A.y, X1, N.x, N.y, Z1, B.x, B.y, Y1)
  23.  
  24.     '''        
  25.     Calculate the resultant unit vector 'R1'
  26.     '''
  27.     R1 = Point(Dx/D, Dy/D, Dz/D)
  28.  
  29.     '''
  30.     Return the global coordinate vector
  31.     '''
  32.     return R1*M
  33.  
  34. # local basis 'X'
  35. a = Point(0.462352, 0.850215, 0.251725)
  36. # local basis 'Y'
  37. b = Point(0.791086, -0.267295, -0.550215)
  38. # local basis 'Z'
  39. n = Point(-0.400516, 0.453529, -0.796177)
  40.  
  41. print repr(translate(a, b, n, Point(12,12,12)))
  42.  
  43. '''
  44. >>> Point(10.235071, 12.437392, -13.136013)
  45. '''
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
  1. >>> c.p1
  2. Point(144.000000, 256.000000, 300.000000)
  3. >>> c.p2
  4. Point(324.000000, 587.000000, 398.000000)
  5. >>> c.p3
  6. Point(645.000000, 400.000000, 130.000000)
  7. >>> a = BasisTransToGlobal(c.p1, c.p2, c.p3, Point(12,12,12))
  8. >>> a.R
  9. Point(154.235075, 268.437392, 286.863999)
  10. >>> a.R-c.p1
  11. Point(10.235075, 12.437392, -13.136001)
  12. >>> 
BTW - This should have been posted to Python Forum instead of Python Articles.
Jun 6 '07 #2

bartonc
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

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

bvdet
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

bvdet
Expert Mod 2.5K+
P: 2,851
Here's the return trip:
Expand|Select|Wrap|Line Numbers
  1. def transToLocal(pt, m):
  2.     '''
  3.     pt - point object in the standard R3 orthonormal basis
  4.     vA - local 'X' unit vector
  5.     vB - local 'Y' unit vector
  6.     vN - local 'Z' unit vector
  7.  
  8.     'dot()' is a Point object method that returns the dot product    
  9.  
  10.     Return the local coordinate
  11.     Vector projection of: pt along vA, pt along vB, pt along vN
  12.     '''
  13.     return Point(pt.dot(Point(*m[0])), \
  14.                  pt.dot(Point(*m[1])), \
  15.                  pt.dot(Point(*m[2])))
  16.  
  17. # Local basis translation matrix
  18. m = [(0.462352, 0.850215, 0.251725), \
  19.      (0.791086, -0.267295, -0.550215), \
  20.      (-0.400516, 0.453529, -0.796177)]
  21. # Point object in standard orthonormal basis
  22. pt = Point(10.235071, 12.437392, -13.136013)
  23.  
  24. print repr(transToLocal(pt, m))
  25. # Point(12.000000, 12.000000, 12.000000)
Jun 8 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.