Page 1 of 1

Status of numeric libraries?

Posted: Sat Oct 16, 2004 10:47 pm
by animats
The game engine's Python seems to include neither Numeric nor Numarray. What's the approved tool set for doing matrix arithmetic? There must be something in there. Thanks.

Posted: Sun Oct 17, 2004 11:20 pm
by Sutabi
Blender GE was never intended for the High lvl calculations, but you can still user that lib just install it into python and import.... not to hard, then add compiled lib to the binaries you release.

Posted: Mon Oct 18, 2004 7:11 am
by animats
just install it into python and import
This is for Win2K, unfortunately. Numarray has an installer that won't recognize GameBlender's Python. So does Numeric.

Is there some simple way to do this, or do I have to figure out how the Numarray installer works, how GameBlender's Python installation works, and hack them to work together?

Posted: Mon Oct 18, 2004 8:07 am
by animats
Blender GE was never intended for the High lvl
Many GameLogic functions use matrices. getOrientation and setOrientation use 3x3 rotation matrices, and there are camera functions such as getCameraToWorld which use full 4x4 transformation matrices. So clearly the API requires the availability of basic matrix math functions.

Numarray may be overkill, but a basic 2x2, 3x3, and 4x4 matrix library is essential.

basic matrix functions

Posted: Mon Oct 18, 2004 3:05 pm
by theserpentlord
Making a simple blender game, I use the matrix and vector math features all the time, but I have some game programming experience, so what does simple mean? :D Matrix math is especially confusing because they BARELY touched this at school 10 years ago - I end up doing it by trial and error!

Python already has a handy "math" library I can import:

math.atan2 (to convert x and y deltas to angles - for example to convert mouse coordinates to angles)
math.sin (to convert angle to y coordinate)
math.cos (to convert angle to x coordinate)
math.pi (degrees/radians == 180/math.pi)
math.sqrt(x*x+y*y+z*z) (for normalizing vectors)

It would be nice to have helper functions for:

normalize vector or matrix
convert matrix, quarternion or vector to angle:
yaw/compass angle = angle from top view (math.atan2(x,-y))
pitch/elevation angle = math.sin (z/math.sqrt(x*x+y*y+z*z))
convert angle to matrix
invert matrices
concatenate matrices
apply transformation matrix to vector/point

The last three should work with both 3x3 (orientation) and 4x4 (projection) matrices.

Posted: Mon Oct 18, 2004 9:02 pm
by animats
If we can figure out how to get "numarray" loaded, we'll have most of that. But "numarray" is about 50 files with an installer, and it's not obvious how to get it into Blender's Python without messing something up. The installer won't run because it's looking for a full installation of Python.

Posted: Tue Oct 19, 2004 8:06 am
by Sutabi
unless your using Blender 2.25, then there shouldn't be a sand box, meaning you can import anything with the current Blender

Posted: Tue Oct 19, 2004 2:28 pm
by an-toni
the embedded Blender Python must only know the path to the module, and (especially in case of compiled modules) it must be for the right version of Python (i.e. the one in the Blender you're using). and this is what the well-documented (e.g. Elysiun threads) PYTHONPATH env. variable does.

if you have trouble installing numarray or some other module in ms-win because of not having Python installed, why don't you just install Python first? and then set PYTHONPATH accordingly so that Blender too finds the modules installed for the regular Python.

~Toni