~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to release/scripts/bpymodules/BPyMathutils.py

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: BPyMathutils.py,v 1.6 2006/12/14 14:53:32 campbellbarton Exp $
 
1
# $Id: BPyMathutils.py,v 1.7 2007/04/07 17:35:45 campbellbarton Exp $
2
2
#
3
3
# --------------------------------------------------------------------------
4
4
# helper functions to be used by other scripts
210
210
        mat.resize4x4()
211
211
        tmat= Blender.Mathutils.TranslationMatrix(cent)
212
212
        return mat * tmat
 
213
 
 
214
 
 
215
# Used for mesh_solidify.py and mesh_wire.py
 
216
 
 
217
# returns a length from an angle
 
218
# Imaging a 2d space.
 
219
# there is a hoz line at Y1 going to inf on both X ends, never moves (LINEA)
 
220
# down at Y0 is a unit length line point up at (angle) from X0,Y0 (LINEB)
 
221
# This function returns the length of LINEB at the point it would intersect LINEA
 
222
# - Use this for working out how long to make the vector - differencing it from surrounding faces,
 
223
# import math
 
224
from math import pi, sin, cos, sqrt
 
225
 
 
226
def angleToLength(angle):
 
227
        # Alredy accounted for
 
228
        if angle < 0.000001:
 
229
                return 1.0
 
230
        
 
231
        angle = 2*pi*angle/360
 
232
        x,y = cos(angle), sin(angle)
 
233
        # print "YX", x,y
 
234
        # 0 d is hoz to the right.
 
235
        # 90d is vert upward.
 
236
        fac=1/x
 
237
        x=x*fac
 
238
        y=y*fac
 
239
        return sqrt((x*x)+(y*y))