Skip to main content
Participating Frequently
November 5, 2012
Question

transform with rotate and translate

  • November 5, 2012
  • 2 replies
  • 1424 views

I want to get similar transforms with rotate and translate as I get it with the Transfommation Effect on multiple copies. But somehow the rotation of the Filter puts a different transform than doing it with rotation in js. With js the copies get rotated around a center, that is on the same level for all objects. With the filter the translations seem to have an different origin/direction. I dont get the logic how to get the same output with js.

This topic has been closed for replies.

2 replies

Inspiring
November 5, 2012

Post pictures of your problem…

RisplerAuthor
Participating Frequently
November 6, 2012

Ok, this shows my problem. First: Filter, second: js. Below window of the filter and the relevant part of the script.

for (i = 0; i < dupItems; i++) {

    dupObj = selectedObject.duplicate();

    dupObj.translate(displacement_x, displacement_y);

    dupObj.rotate(myRotation

                    ,true

                    ,false

                    ,false

                    ,false

                    ,Transformation.CENTER);

    selectedObject = dupObj;

}

Jongware
Community Expert
Community Expert
November 6, 2012

You rotate and transform the new (translated and rotated) copy of the original object. Since the x translation is the same, your objects appear spaced out at 47 pt horizontally; the y translation stays the same, so the object does not move vertically.

The rotation, on the other hand, gets applied incrementally -- the first copy is rotated by 20°, the second by 40°.

The Transform Filter also rotates both the x and y translations by the same angle, so the original object moves 'up, up and away'.

I ran into some problems trying the same with each next duplicate, so instead I do each translation-and-rotation on the original object (I'm sure it's just a question of maths to get that right, but in this case it's virtually of no importance since the end result is the same). I increase the angle of rotation and concatenate the Verschiebung with its previous value. Voila: the same result.

(A difference is that I tested with CS4, and in that the Transform effect dialog still has the nine-point rotation origin proxy. In your version -- CS6 -- it's strangely missing.)

dupItems = 3;

selectedObject = app.selection[0];

displacement_x = 47;

displacement_y = 0;

myRotation = 20;

for (i = 0; i < dupItems; i++)

{

dupObj = selectedObject.duplicate();

dupObj.translate(displacement_x, displacement_y);

dupObj.rotate(myRotation

  ,true

  ,false

  ,false

  ,false

  ,Transformation.CENTER);

// selectedObject = dupObj;

displacement_x += 47*Math.cos(myRotation*Math.PI/180);

displacement_y += 47*Math.sin(myRotation*Math.PI/180);

myRotation += 20;

}

Inspiring
November 5, 2012

Welcome to the Forum!

If I am interpreting your question correctly look into "Transformation" (ie: rotate -> rotateAbout, transform -> transformAbout, etc...) in the JS Scripting Reference.

Transformation: The point to use as the anchor point about which an object is rotated, resized, or transformed

Transformation.DOCUMENTORIGIN

Transformation.LEFT

Transformation.CENTER

Transformation.RIGHT

Transformation.BOTTOMLEFT

Transformation.BOTTOM

Transformation.BOTTOMRIGHT

Transformation.TOPLEFT

Transformation.TOP

Transformation.TOPRIGHT