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
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 : - 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: - >>> 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.
Moved from Python Articles
Please be careful not to post questions in the Articles section.
Thanks you for your co-operation in this matter.
Jinkies bvdet! That was amazing!
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).
bvdet 2,851
Expert Mod 2GB
Here's the return trip: - 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[0])), \
-
pt.dot(Point(*m[1])), \
-
pt.dot(Point(*m[2])))
-
-
# 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)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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
...
|
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...
|
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...
|
by: VINITAG |
last post by:
<LineItem>pediatric...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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...
| |