# Track a point with off-centre rotation (SOLVED)

7 posts

 678 posts I have a point in a movieclip that is set to (22,5), so if the movieclip rotated around its centre 90 degrees, the point would then be at (-5,22). During the game; the movieclip rotates around to the position of the mouse, and I need to know the exact location of that point at all times. Of course tracing its coordinates gives me (22,5) every time, no matter how the parent movieclip is rotated. I know the trigonemtry I could use: xOffset = Math.sin(rotation*(Math.PI/180))*distance; yOffset = Math.cos(rotation*(Math.PI/180))*distance; But from what I understand, that would only work if the point was aligned to an axis along the centre of rotation, like (22,0) or (0,5). Can anyone help me? 6261 posts distance = Math.sqrt(22*22+5*5); offsetAngle = Math.atan2(22, 5); pointX = Math.sin(offsetAngle + rotation * Math.PI / 180) * distance; pointY = Math.cos(offsetAngle + rotation * Math.PI / 180) * distance; 678 posts Haha I can’t believe it’s that simple! Thanks again skyboy! :) 468 posts You could also use localToGlobal I think. I don’t know if it accounts for rotation. 6261 posts Originally posted by BigJM:You could also use localToGlobal I think. I don’t know if it accounts for rotation. it accounts for everything, but it’s far slower than straight trig 468 posts I guess it would just transform the point using the object’s matrix. 521 posts Vector Math. Can occasionally be useful.