I've just uploaded a new version of Game Objects. The 3D maths classes (Vector2, Vector3 and Matrix44) are reasonably stable now. I'd like to invite Python coders to play around with them, and suggest any improvements. My intention was to make something that was very easy to use, but well optimized. Game Objects is public domain. Do what you want with the code - go crazy!

There is no documentation at the moment I'm afraid, but here are a few edited highlights.

Vector3 class

>>> from gameobjects.vector3 import *
>>> A = (-5, 2, -6 )
>>> B = (10, 2, 8)
>>> AB = Vector3.from_points(A, B)
>>> print AB
(15, 0, 14)
>>> AB.length
20.518284528683193
>>> AB.length = 1
>>> print AB
(0.731055, 0, 0.682318)
>>> AB *= 2
>>> print AB
(1.462111, 0, 1.364637)
>>> AB += (1, 2, 3)
>>> print AB
(2.462111, 2, 4.364637)

Matrix44 Class

>>> from gameobjects.matrix44 import *
>>> identity = Matrix44()
>>> print identity
[ 1 0 0 0 ]
[ 0 1 0 0 ]
[ 0 0 1 0 ]
[ 0 0 0 1 ]
>>> scale = Matrix44.scale(2.)
>>> print scale
[ 2 0 0 0 ]
[ 0 2 0 0 ]
[ 0 0 2 0 ]
[ 0 0 0 1 ]
>>> scale.transform( (1, 2, 3) )
(2.0, 4.0, 6.0)
>>> from math import radians
>>> rotate = Matrix44.x_rotation(radians(45))
>>> print rotate
[ 1         0         0         0 ]
[ 0         0.707107  0.707107  0 ]
[ 0         -0.707107 0.707107  0 ]
[ 0         0         0         1 ]
>>> p = (5, 10, 0)
>>> rotated_p = rotate.transform(p)
>>> print rotated_p
(5.0, 7.0710678118654755, 7.0710678118654746)
>>> inverse_rotate = rotate.get_inverse()
>>> inverse_rotate.transform(rotated_p)
(5.0, 10.0, 0.0)
>>> rotation.right
Traceback (most recent call last):
  File "<interactive>", line 1, in ?
NameError: name 'rotation' is not defined
>>> rotate.right
(1.0, 0.0, 0.0, 0.0)
>>> rotate.translate
(0.0, 0.0, 0.0, 1.0)
>>> rotate.translate = (10, 2, 5)
>>> print rotate
[ 1         0         0         0 ]
[ 0         0.707107  0.707107  0 ]
[ 0         -0.707107 0.707107  0 ]
[ 10        2         5         1 ]
</interactive>
This blog post was posted to It's All Geek to Me on Sunday May 20th, 2007 at 5:25PM
 

Leave a Comment

You can use bbcode in the comment: e.g. [b]This is bold[/b], [url]http://www.willmcgugan.com[/url], [code python]import this[/code]
Preview Posting...
Previewing comment, please wait a moment...

My Tweets

Will McGugan

My name is Will McGugan. I am an unabashed geek, an author, a hacker and a Python expert – amongst other things!

Search for Posts
Possibly related posts
Tags
Popular Tags
 
Archives
2010
 
Recent Comments
http://www.iclshoes.com/alexander-mcqueen-c-13.html [iclshoes.com] http://www.iclshoes.com/jimmy-choo-shoes-c-2.html [iclshoes.com] http://www.iclshoes.com/ [iclshoes.com] http://www.zentai-mart.com/Play-Costumes-c-5.html [zentai-mart.com] http://www.zentai-mart.com/Latex-Catsuits-Clothes-c-3.html [zentai-mart.com] http://www.zentai-mart.com/PVC-Catsuits-Clothes-c-6.html [zentai-mart.com] http://www.zentai-mart.com/ [zentai-mart.com] http://www.hereshoes.com/miu-miu-shoes-c-31.html [hereshoes.com] http://www.hereshoes.com/giuseppe-zanotti-c-43.html [hereshoes.com] http://www.hereshoes.com/lanvin-shoes-c-50.html [hereshoes.com] ...
- Christian Louboutin on Turning website favicons in to 3D
What are the charmings of?a href="http://www.iclshoes.com [iclshoes.com]cl shoes/a?They are quality,comfort and style.The a href=http://www.iclshoes.com/jimmy-choo-shoes-c-2.html [iclshoes.com]Jimmy Choo shoes/a are made from ...
- Christian Louboutin on Turning website favicons in to 3D
Jay, the reason Creationists, and their slightly more dishonest variant intelligent design, are bit of a worry, is their tendency ...
- Shayne O'Neill on Creationists in Oxford
Thanks a lot for that: I had first tried sudo aptitude purge adobe-flashplugin then sudo aptitude install flashplugin-nonfree but that ...
Andre, the name is derived from the class name (camel case converted to lower case with underscores). But, you can ...
 
© 2008 Will McGugan.

A technoblog blog, design by Will McGugan