__init__.py :  » Game-2D-3D » Visual » visual-5.32_release » site-packages » visual » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Game 2D 3D » Visual 
Visual » visual 5.32_release » site packages » visual » __init__.py
version = ('5.32', 'release')

# Copyright David Scherer and others, see license.txt

import sys as _sys
visual = _sys.modules['visual']

# This is called (visual._fix_symbols()) from modules in the package
# that (unfortunately) must "from visual import *" because clients expect
# to be able to import them _instead_ of visual.  This prevents them from
# binding symbols to other _modules_, which may overwrite symbols imported
# directly from those modules.  (yuck!)
def _fix_symbols( modg ):
    for sym in ( 'controls','factorial','ui' ):
        if modg.has_key(sym):
            del modg[sym]
    all = set(modg.keys()) & set(globals().keys())
    return list(all)

# The following manipulations of math and numpy functions is a workaround
# for the problem that in going from Numeric to numpy, the return by numpy
# from e.g. sqrt is numpy.float64, not float, which is not recognized as
# matching float in the operator overloading machinery, including Boost.
# This means is that right multiplication scalar*vector is not caught
# and the result is returned as numpy.ndarray instead of vector, which
# can be a big performance hit in vector calculations.

# There is an advantage to this workaround: sqrt(scalar) is much faster
# this way than when using the numpy sqrt, and there is little penalty
# for the numpy sqrt(array).

import math as _math
import numpy as _numpy
# TODO: be selective instead of importing * from these:
from math import *
from numpy import *

for ufunc in ('ceil','cos','cosh','exp','fabs','floor','fmod','frexp',
              'ldexp','log','log10','modf','sin','sinh','sqrt',
              'tan','tanh'):
    def _uf(x,
            numpy = getattr(_numpy,ufunc),
            math = getattr(_math,ufunc),
            mathtypes = (float,int,long)):
        if type(x) in mathtypes: return math(x)
        return numpy(x)
    globals()[ufunc] = _uf

for ufunc in ('hypot',):
    def _uf(x,y,
            numpy = getattr(_numpy,ufunc),
            math = getattr(_math,ufunc),
            mathtypes = (float,int,long)):
        if type(x) in mathtypes and type(y) in mathtypes: return math(x,y)
        return numpy(x,y)
    globals()[ufunc] = _uf

import crayola as color
import cvisual
cvisual.init_numpy()
from cvisual import (vector,mag,mag2,norm,cross,rotate,comp,proj
                     diff_angle, rate)

# Fix the problem that numpy dot(vector,vector) returns numpy.float64 rather
# than an ordinary float, causing trouble with later vector calculations:
import cvisual as _cvisual
def _dot(x,y,mathtypes = (float,int,long)):
    numpy = getattr(_numpy,'dot')
    cvisual = getattr(_cvisual,'dot')
    if type(x) is vector and type(y) is vector: return cvisual(x,y)
    return numpy(x,y) # arrays rather than Visual vectors
globals()['dot'] = _dot

from visual.primitives import (arrow,cylinder,cone,sphere,box,ring,label
                               frame, pyramid, ellipsoid, curve, faces, convex, helix,
                               points, text, distant_light, local_light)
from visual.ui import display
import materials

# Undo side effect of from... import * that puts modules in package namespace
del ui, crayola, primitives

if 1:
    # Names defined for backward compatibility with Visual 3:
    import sys, time
    true = True
    false = False
    crayola = color
    from cvisual import vector_array,scalar_array

# Allow cvisual itself to load files from the visual package - used by GTK
#   driver to load glade data files
import os.path as _os_path
cvisual._set_dataroot( _os_path.split( __file__ )[0] + _os_path.sep)

# The following ensures that __waitclose will be run
# when we reach the end of the program,
# to permit viewing and navigating the scene.
import atexit as _atexit
_atexit.register(cvisual.waitclose)

import site_settings

# Construct the default display object.
scene = display()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.