Notifications
Clear all

[Closed] Mirror Node Across Axis

Hello,

I’ve looked around here and tried some things, and maybe it’s partially from lack of sleep, but I cannot figure this out…

I want to take a Node, and Mirror it in it’s Local Coordinates, along an Axis.
I found this code from DennisT I believe. But the node’s Rotation/Position are off.
That is the part I cannot understand how to fix right now.

I probably have to use the Object Offset or something to fix it?

$.transform = $.transform * (matrix3 [-1,0,0] [0,1,0] [0,0,1] [0,0,0])

Thank you!

32 Replies

If ALL you want to do is flip the node, then give this a try (hopefully this gives you what you’re looking for):

 
--Axis of Reflection: 
x = [-1,1,1]
y = [1,-1,1]
z = [1,1,-1]
 
axisReflectTM = scalematrix { x | y | z } --choose only the axis you want to flip 
--(e.g., axisReflectTM = scalematrix z)
flipTM = axisReflectTM * yourNode.transform
yourNode.transform = flipTM

5 Replies
(@denist)
Joined: 11 months ago

Posts: 0

there is a mistake in the formula. it must be yourNode.transform * axisReflectTM

(@archangel35757)
Joined: 11 months ago

Posts: 0

Does this not hold true???

Two n x n matrices A and B commute if AB=BA. This is only the case in special circumstances– and in this case, because it is a scale matrix (σ · Identity (I))…

{ where σij is some real value when i = j (i.e., along the main diagonal) }

[σ·I] commutes with any n x n matrix.

(@denist)
Joined: 11 months ago

Posts: 0

in general matrix multiplication is not commutative: AB != BA. An exception is that the identity matrix (or any constant multiple of it). In your case the matrix (scalematrix) is not identity.

(@kickflipkid687)
Joined: 11 months ago

Posts: 0

I tried that way, it didn’t work. Seemed to be right the way he said?
Also, I cannot see a difference between what I used and that method.

They both seem to rotate the Object when Mirroring, which might be ok for my case.
But it could be useful to not do that, if possible.

(@denist)
Joined: 11 months ago

Posts: 0

mirroring matrix in local coordinates is equivalent of flipping one axis (or the same – multiplying with negative scale).

can’t that be shortened to

mynode.transform  = prescale mynode.transform y

?

Mirror in max just scale the object with negative value. Create a teapot, mirror it on one or more axis and check, open Scale Transform Type In and check the Absolute Local values of X, Y and Z of the original and the mirrored object. You will see that the mirrored have values -100% for the mirrored axis.

I assumed Scale was the thing, but I didn’t look at the Absolute. Now I see.

It looks like this works. Thank you guys!

$.transform  = prescale $.transform [1,-1,1]

if you want to flip X axis of the matrix and don’t care about mirroring position and rotation it might work.

Thanks for the clarification Denis… but don’t you have to pre-multiply in this case… so that the node maintains its original transform position and is only flipped?

This is the function I often use when mirroring nodes. I have made this into a small UI where I can choose what axis i want to mirror across and which axis I want to flip in the case here we are mirroring across X and flipping the Y. (you can use a matrix 3 instead of creating a point helper )

fn mirrorNodeFn obj =
(
	tempPoint = point()
	offsetTm = obj.transform*inverse tempPoint.transform
	mirrorTm = offsetTm*(scaleMatrix [-1,1,1])
	finalTm = (scaleMatrix [1,-1,1])*mirrorTm*tempPoint.transform
	delete tempPoint
	return finalTm
)
$[2].transform = mirrorNodeFn $[1]

could you post a picture what you initially have and what you expect to get after mirror?

Basically what I was trying to do is Mirror as the Mirror tool does, in Local Space. Maybe I should have clarified better.

Page 1 / 3