Jump to content
Sign in to follow this  
FruehBird

[Solved] How does the pivot work in the Make Transform node

Recommended Posts

How does the pivot work when using the make transform Vop node?

I am trying break down and figure out the function of the Make Transform node using python (Outside of any 3d software).

The Translate is pretty basic as I can just place them into a matrix as they are x = m[3][0], y = m[3][1] and z = m[3][2].

For rotation I am using the following:

def EulerToMatrix(Rotation):
	x, y, z = Rotation
	XM = M3([[	1, 	0, 	0],
			[0, math.cos(x), -math.sin(x)],
			[0, math.sin(x), math.cos(x)]])
	YM = M3([[math.cos(y), 0, math.sin(y)],
			[0,	1,	0],
			[-math.sin(y), 0, math.cos(y)]])		
	ZM = M3([[math.cos(z), -math.sin(z), 0],
			[math.sin(z), math.cos(z), 0],
			[0,	0,	1]])
	return (ZM * YM * XM)

I can then just pipe this information into the Matrix4.

The problem I have now is that I cannot find any information that I can understand on how to apply the pivot to the matrix4. It's not as simple as just adding.

I have attached a file that has the make transform that I am using to test against. The pivot seems to be linked to the rotation and so I am guessing it is related to the scale as well. Is there any way to break down how this pivot transforming works?

MakeTransPiv.hip

Edited by FruehBird

Share this post


Link to post
Share on other sites

I got closer with setting the pivot as the transform of a second matrix and multiplying the two but something is still off. 

With the pivot the position becomes (0.42052, 11.0109, 7.3853)

With the multiplying it becomes  (0.54003, 11.050306, 7.68421)

ApplyTransPiv.hip

Edited by FruehBird

Share this post


Link to post
Share on other sites

I got it working! In order to apply a pivot to a matrix you need to invert the original matrix before multiplying it by the pivot. After that you will need to invert it again and add the pivot xyz to the position on the matrix. 

 

 

ApplyTransPivWorking.hip

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×