[Bf-python] New Mathutils and old Math - Letter rip.

Tom M letterrip at gmail.com
Wed Sep 28 11:06:47 CEST 2005


Possibly related - the value returned by my function

getScaleFactor gives different results for the x dimension, so
possibly whatever functions getBoundBox() relies on has changed.

Here is the value printed in 2.37a
[2.0000009536743164, 2.0000009536743164, 2.0]

vs

the value printed in current CVS
[2.0000008344650269, 2.0000009536743164, 2.0]

Function is below, very simple...

LetterRip

def getScaleFactor():
	global myObject
	global baseSize
	boundingBox = myObject.getBoundBox()
	tempVert = boundingBox[0]
	boundx_min = boundx_max = tempVert[0]
	boundy_min = boundy_max = tempVert[1]
	boundz_min = boundz_max = tempVert[2]
	for v in boundingBox:
		if v[0] <= boundx_min:
			boundx_min = v[0]
		if v[0] >= boundx_max:
			boundx_max = v[0]
		if v[1] <= boundy_min:
			boundy_min = v[1]
		if v[1] >= boundy_max:
			boundy_max = v[1]
		if v[2] <= boundz_min:
			boundz_min = v[2]
		if v[2] >= boundz_max:
			boundz_max = v[2]

	avg_x = boundx_max-boundx_min
	avg_y = boundy_max-boundy_min
	avg_z = boundz_max-boundz_min

	#now we find the most representative value of the three and use that
as our scale factor

	thisList = [avg_x,avg_y,avg_z]
	print thisList
	thisList.sort()
	print thisList
	return thisList[1]/baseSize



More information about the Bf-python mailing list