Hi,
i’m using a script to generate these segments and position them in a theo jansen mechanism but something is really not working…
// worked fine, the "a" segment
var dx = a.x - g.getPin().x;
var dy = a.y - g.getPin().y;
a.rotation = Math.atan2(dx, dy) * 180 / Math.PI;
// didn't work, the "e" segment
dx = d.x - e.x;
dy = d.getPin().y - c.getPin().y;
e.rotation = Math.atan2(dx, dy) * 180 / Math.PI;
where getPin() method returns an object that contain the position of the “object´s pin”
an example
e.width = 77;
w.x = 100
trace(e.getPint().x) // outputs 177
I´m trying to get the correct angle of e segment in order to make it snap to the “d” lower pin
I tried many ways using these values, the difference, the inverse difference, and all failed
what i’m i doing wrong?