Hello!

I am trying to figure out how to find the “center” coordinates of a rectangle TOP that I am rotating in real time by plus-minus 30 degrees. My solution gets pretty close to result that I want to achieve, but it is not perfect. You can see an example of this problem in the attachments.

Here a brief explanation:

The rotation angle is calculated using the expression math.sin(absTime.seconds*3)*30 in the rotate parameter of the Transform TOP applied to the Rectangle TOP. The rotation is pivoted at px=0.5 and py=0 and the dimensions of the rectangle are width=0.01 and height=1.

Now: since I can’t find an operator that helps me to calculate the Rectangle’s center position I am using some basic trigonometry:

```
deg_offset = changeOp.par.rotate+90 # +90 is needed because the rectangle is oscillating around the y axis
deg = math.radians(deg_offset)
x = math.cos(deg)
y = math.sin(deg)
# op('center') is a Constant CHOP
op("center").par.value0 = (x/2)*(9/16) # (9/16) scaling factor due to a 16:9 resolution
op("center").par.value1 = (y/2)-0.5 # -0.5 because the TD's coordinates goes from -0.5 to 0.5
```

this function is used in a OP Execute (the monitor OP is the Transform TOP which makes the Rectangle TOP rotate) inside the `onPostCook`

callback. If I export the resulting x and y values from the Constant CHOP to set the center coordinates of a Circle TOP so that it moves together with the Rectangle, I should see the circle moving exactly at the center of the Rectangle, but somehow it is not…

Is there a better way to achieve this? Is there something that I am not considering?

Thank you very much!

example.toe (4.3 KB)