473,226 Members | 1,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Transforming the Point using list

440 256MB
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 1791
bvdet
2,851 Expert Mod 2GB
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
6,596 Expert 4TB
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
3,237 Expert 2GB
Jinkies bvdet! That was amazing!
Jun 7 '07 #4
bvdet
2,851 Expert Mod 2GB
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
2,851 Expert Mod 2GB
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

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

Similar topics

34
by: jblazi | last post by:
Let us assume I have a list like and would like to transoform it into the string '{1,2},{7,8},{12,13}' Which is the simplest way of achiebing this? (The list is in fact much longer and...
0
by: David Furey | last post by:
Hi, I am using the XSLT document to filter records from an XML document The XSL is shown below: I have a parameter named "search-for" that is used to bring back a list of Vendor Names that...
5
by: Jody Greening | last post by:
Transforming with XSLT, Grouping elements until difference found. I am seeking some help with the following problem, I am fairly new at XSLT transformations, and my problem may lie in looking at...
4
by: Showjumper | last post by:
I am using the NITF DTD for my xml files and i need to use 2 xsl files to do the transform: one for the <body.head> and the second for the <body.content>. I've got this so far for transforming...
3
by: Sergio Otoya | last post by:
Hi all, I need to transform an xml document, using xsl to a HTML output. I can do this successfully using the XslTransform class as below: Dim oTrans As New XslTransform ...
4
by: Cathie | last post by:
Hi All, I am trying to get my style sheet to work. It works fine in IE but I can't get it to work in .net. Below is the function I use for transforming, where advancedOptionsFile is the path...
6
by: Adam Clauss | last post by:
I have a list of points (their coming in as decimal types, I can convert to PointF) that I am trying to draw to a form. Unfortunately, the coordinate system these points are coming from is not...
1
by: VINITAG | last post by:
<LineItem>pediatric...
5
by: james_027 | last post by:
hi, i have a list from a resultset like this 1,"Chicago Bulls",,,"" 2,"Cleveland Caveliers",,,"" 4,"Detroit Pistons",1,"23686386.35" 4,"Detroit Pistons",2,"21773898.07" 4,"Detroit...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.