473,405 Members | 2,141 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,405 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 1800
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.