473,492 Members | 4,301 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Applying transformation matrix to 3D vertex coordinates

'''
################################################
Task:-
to apply a translation array to an array
of 3D vertex coordinates to produce the
resulting location of each vertices.

Translation array and vertex coordinates taken from
a Truespace COB file.

The text in the COB file looks like this:-

Transform
-2.11786 -0.817596 0.946387 0.864939
0.405189 1.25484 2.11894 0.434915
-1.16679 1.9198 -0.981965 1.13894
0 0 0 1
World Vertices 8
-0.200000 -0.029486 -0.236313
0.200000 0.029486 -0.163687
-0.200000 0.370514 -0.282911
-0.200000 0.370514 0.117089
-0.200000 -0.029486 0.163687
0.200000 0.029486 0.236313
0.200000 0.429486 -0.210286
0.200000 0.429486 0.189714

###############################################
'''
# script start

import Numeric

transArray = Numeric.array((
(-2.11786, -0.817596, 0.946387, 0.864939),
(0.405189, 1.25484, 2.11894, 0.434915),
(-1.16679, 1.9198, -0.981965, 1.1389),
(0, 0, 0, 1)
))

# a "1" added to the end of each set of vertix coordinates
vertArray = Numeric.array((
(-0.200000, -0.029486, -0.236313, 1),
(0.200000, 0.029486, -0.163687, 1),
(-0.200000, 0.370514, -0.282911, 1),
(-0.200000, 0.370514, 0.117089, 1),
(-0.200000, -0.029486, 0.163687, 1),
(0.200000, 0.029486, 0.236313, 1),
(0.200000, 0.429486, -0.210286, 1),
(0.200000, 0.429486, 0.189714, 1)
))

print transArray
print ""
print vertArray
print ""

transArray = Numeric.reshape(transArray,(4,4))
vertArray = Numeric.reshape(vertArray,(4,8))

print Numeric.matrixmultiply(transArray,vertArray)

# script end
'''
################################################## ################
Result:-

[[ 0.5708016 0.10309048 0.70481144 -1.12413 0.1022124
0.03400637 0.63866924 -1.12413 ]
[-0.6688108 0.57729922 -0.19537307 4.213884 0.3408408
0.72615216 0.66384632 4.213884 ]
[ 0.273571 1.26381257 -0.66763452 0.909945 -0.585931
1.13709619 0.39979 0.909945 ]
[ 0.2 0.429486 -0.210286 1. 0.2
0.429486 0.189714 1. ]]

Am I going in the right direction?
What do I do with the result? :)

Thanks,

PhilC
'''
Sep 3 '07 #1
1 2398
On Mon, 03 Sep 2007 23:24:42 -0500, Robert Kern
<ro*********@gmail.comwrote:
>transpose()

ahh yes I can see where that would work. Just tried it in the above
and I do get a last line of ones.

OK onward and upward :)

Many thanks Robert.
Sep 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1469
by: Matt Feinstein | last post by:
Is there an optimal way to apply a function to the elements of a two-d array? What I'd like to do is define some function: def plone(x): return x+1 and then apply it elementwise to a 2-D...
4
5227
by: Stephen | last post by:
I have the following that outputs an xml file to a div using ajax: <script type="text/javascript"> function ajaxXML(url,control_id){ if (document.getElementById) { var x =...
8
2384
by: nestini | last post by:
Hello everybody, I am student who just begin learning about programming I want to know what is Sprase Matrix. And would you please show me how to add the 2 Sprase Matrix in C soursecode.
0
882
by: gazza67 | last post by:
Hi People, I have a graphics problem. I have a diagram that is stored with all of its X,Y coordinates having an origin of Bottom right corner, when I display the diagram I want it with the...
1
2120
by: Tyler Eaves | last post by:
Got a 3d algorithmns question. Algorithmn will be implemented in python, so a library would be great if it works on windows. Basically my function would be defined as such. Problem is one of...
2
5828
by: Zhengzheng Pan | last post by:
Hi all, I'm trying to check whether a (stochastic/transition) matrix converges, i.e. a function/method that will return True if the input matrix sequence shows convergence and False otherwise....
2
7631
by: sanjeevron | last post by:
Define a class for an adjacency matrix representation of weighted, directed graphs in C++. 2. Implement the following essential methods in your class. Any input validation or exceptions must be...
1
3838
by: Thomas Bauer | last post by:
Hello, how can I make the transformation matrix? Zero point Left top Left bottom Right top Right bottom
14
9087
by: Thomas Bauer | last post by:
Hello, I search a example like that. (1,0,0,1,4,5 ) -- moving (1,0,0,1,0,0 ) -- normal matrix (-1,0,0,1,0,0 ) -- Mirror Y-Axis (0,-1,0,1,0,0 ) -- Mirror X-Axis I caluculate all in mm.
0
7118
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
6980
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7192
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6862
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4886
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...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.