[Bf-python] Coordinatesystem problem

wim van hoydonck wim.van.hoydonck at gmail.com
Wed Jan 12 22:30:38 CET 2005


Hi,

The following definitions should do what you want to achieve.
I copied them from the knife scripts that is included with the bundled scripts.

If you want to know where a point of a cube (after being rotated) is
in the global coordinate system, you should use "GlobalPosition" (I
think).

Hope this helps,

Wim
---------------------------------------------------------------------------------

# matrix(4x3) vector multiplication
def mulmatvec4x3(a, b):
	# a is vector, b is matrix
	r = [0, 0, 0]
	r[0] = a[0]*b[0][0] + a[1]*b[1][0] + a[2]*b[2][0] + b[3][0]
	r[1] = a[0]*b[0][1] + a[1]*b[1][1] + a[2]*b[2][1] + b[3][1]
	r[2] = a[0]*b[0][2] + a[1]*b[1][2] + a[2]*b[2][2] + b[3][2]
	return r
#===========================#
# Coordinatetransformations #
#===========================#

def GlobalPosition(P, Obj):

	if (BL_VERSION<=223):
		m = Obj.matrix
	else:
		m = Obj.getMatrix()

	return mulmatvec4x3(P, m)

def LocalPosition(P, Obj):

	if (BL_VERSION<=223):
		m = Blender210.getObject(Obj.name).inverseMatrix
	else:
		m = Obj.getInverseMatrix()

	return mulmatvec4x3(P, m)
------------------------------------------------------------------------------------------


On Wed, 12 Jan 2005 21:41:38 +0200, Thomas Buschhardt
<thomas at buschhardt.de> wrote:
> Hallo, I've a geometrical problem and I hope you can help me out. There
> is a way to translate the world-coordinatesystem to a local-coordinate
> system. In my case: I want to find out where is a simple point (vertex)
> from a standard cube after I rotate the cube in all 3 directions
> (X,Y,Z). Is there a "simple" Blender.Object-function like
> "getLocalTransform...." or did you know a formula to do this ?
> 
> Bye Thomas
> 
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
> 


-- 
Avoid hangovers - stay drunk!



More information about the Bf-python mailing list