Inverse Tangent?!?

I’m trying to get an angle out of the X and the Y values of the mouse. If there is an inverse tangent, it would be someingthing like invtan(x,y).

i think you’re looking for Math.atan2()

be sure to use y first

Math.atan2(y,x)

Tried that and, according to the AS dictionary in MX,

The return value represents the angle opposite the opposite angle of a right triangle, where x is the adjacent side length and y is the opposite side length.

so wouldn’t i just take the Math.atan2(x,y), add 90, then subtract it from 180 to find the third angle?

Here is the code:
[AS]
onClipEvent(enterFrame){
mouseX = _root._xmouse;
mouseY = _root._ymouse;

invTan = Math.atan2(mouseY,mouseX);
theRotation = 180-(invTan+90);

_root.test.text = theRotation;
this._rotation = theRotation;
}
[/AS]

theRotation only returns a value from 89.0-91.0. Im more than likely overlooking something :h:

atan2 return value is in radians

onClipEvent(enterFrame){
	dx = _parent._xmouse - _x;
	dy = _parent._ymouse - _y;
	
	radians = Math.atan2(dy,dx);
	degrees = radians*180/Math.PI;
	
	_rotation = degrees;
}

And this assumes pointing right is 0 degrees so either start your clip pointing right or add (90 for example) from there to get it to face the mouse.

Awsome thanks, Senocular… i tried that but was missing the - _x, and the - _y when i was getting the x, y values of the mouse :m: