# ICE Deform: Rotate polygons

188 views

### Christian Gotzinger

Aug 28, 2012, 3:09:40 AM8/28/12
to soft...@listproc.autodesk.com
Hi list,

I want to animate a road building itself by scaling its polygons from 0 to 1. I've already got this done. But I also want to rotate the polygons 180 degrees around their local axes. Can someone explain the math behind this? Thank you!

### Simon Anderson

Aug 28, 2012, 3:26:32 AM8/28/12
to soft...@listproc.autodesk.com
hey,

you will have to look into Matrix's, global Matrix's to be exact and then do a Invert to and multiply, to get one matrix into its parents space. Its not as insane as it sounds.

i would suggest creating two nulls, get there globla kinematics(Matrix) then do a invert on the one matrix(A) and multiply it by the other Matrix(B), and pipe that back into the global kinematics.
That would give you a better understanding or matrix's and there space, and then you can mess around with the rotations of the local matrix.

Hope that helps, also im not 100% sure what kind of rotation effect your trying to achieve?

On Tue, Aug 28, 2012 at 5:09 PM, Christian Gotzinger wrote:
Hi list,

I want to animate a road building itself by scaling its polygons from 0 to 1. I've already got this done. But I also want to rotate the polygons 180 degrees around their local axes. Can someone explain the math behind this? Thank you!

--
-------------------
Simon Ben Anderson
blog: http://vinyldevelopment.wordpress.com/

### Christian Gotzinger

Aug 28, 2012, 3:37:48 AM8/28/12
to soft...@listproc.autodesk.com
I have a road whose polygons are upside down. One by one, I want the polygons to rotate 180 degrees so that the polygon normals point upwards. This is part of an animation, so the rotation must be gradual. And I can't just rotate around some global axis because the road has curves and turns.

### Simon Anderson

Aug 28, 2012, 3:52:04 AM8/28/12
to soft...@listproc.autodesk.com
have you tried retrieving the global position of the polygons you are rotating?

Think i would try retrieve those and then have an addition on the rotate setup to only evaluate when the scale is greater then a specific amount.and rotation less then 180 that should get you the effect I think you are looking for, in theory, havent messed around with polygons in ICE other then deforming with objects and weightmaps.

### Ciaran Moloney

Aug 28, 2012, 3:52:42 AM8/28/12
to soft...@listproc.autodesk.com
Hi,
the easiest way to deal with this type of thing is indeed using matrices, but you need a local matrix per polygon. You can get a 3x3 matrix using Self.polygonreferenceframe. You're going to want to zero-out this matrix (it just describes the local axis of the polygon), but matrix multiplying the pointpositions by the inverted poly reference frame. Now you can do your rotations (rotate vector) in the familiar local space of the object since the polygon is now aligned to local space. When you're done rotating the points, simply re-multiply them by the polygon reference frame, to put them back into the correct space of the polygon.

--
- Ciaran

### Christian Gotzinger

Aug 28, 2012, 4:15:56 AM8/28/12
to soft...@listproc.autodesk.com
Thank you for the explanation Ciaran, this seems to work great! There's only one problem now: The rotation happens around the scene origin while I want the points to rotate around their polygon centers.

Aug 28, 2012, 4:17:18 AM8/28/12
to soft...@listproc.autodesk.com
here is a screenshot of how to do it:

On Tue, Aug 28, 2012 at 9:52 AM, Ciaran Moloney wrote:

--
---------------------------------------
Technical Direction

Elefant Studios AG
Lessingstrasse 15
CH-8002 Zürich

+41 44 500 48 20

www.elefantstudios.ch
---------------------------------------
rotatePolygons.jpg