## Different signs of Cosine, Sine, and Tangent functions and radians

Posted by: Keith H in ActionScript 3, Games, tags: cartesian, coordinates, Cosine, quadrants, Sine, TangentThis post might seem of little importance to some but today I was thinking back to my high school days and (vaguely) remember the 4 quadrants of a Cartesian coordinate plane discussed in class. Depending on the positive or negative sign of a Point's X and Y value, that point in the Cartesian coordinate plane will be located in one of these 4 quadrants.

Quadrant 1 = (+,+)

Quadrant 2 = (-,+)

Quadrant 3 = (-,-)

Quadrant 4 = (-,+)

My interest in this post is about the positive or negative sign of what the Cosine, Sine, and Tangent functions return for the same angle...the angle from one Point to another Point. The sign of these 3 Math functions are different also whenever a Point is located in one of the 4 quadrants.

Quadrant 1 = +Sine,+Cosine,+Tangent

Quadrant 2 = +Sine,-Cosine,-Tangent

Quadrant 3 = -Sine,-Cosine,+Tangent

Quadrant 4 = -Sine,+Cosine,-Tangent

Personally I don't think the order or name of the quadrants are important, as long as you keep them consistent with the coordinate system. For my usage, I order my quadrants "1,2,3,4" clockwise since ActionScript's radians values go clockwise.

I feel this will become useful sometime in the future for me when dealing with angles of Points and determining their positions relative to each other.

In a future situation I might not be given X and Y information, but may only have angle data instead. Seeing the difference of signs from the Cosign, Sine, Tangent output of the angle value will be helpful clues.

So some things come back to haunt you, if they are the ghosts of my math teachers, I will surely pay attention in class this time .

Note in Flash/Actionscript, (0,0) is wherever you set your registration point of a MovieClip. In this example I centered the registration point in Flash,

so (0,0) of head's coordinate system will sit directly at the center of the head.

/*========================================================= Using "Math.atan2" to get the angle (in radians) between the "reddot" and "head". This radian is fed into the "getSign" function so we can see the difference of signs. ===========================================================*/ var radians=Math.atan2(reddot.y-head.y,reddot.x-head.x); var signs:Object=getSigns(radians); var output:String=""; output+="Sine:"+signs.sine; output+="\n"; output+="Cosine:"+signs.cosine; output+="\n"; output+="Tangent:"+signs.tangent; output+="\n"; output+="\n"; output+="Radians:"+radians; status.text=output;

/*============================================ Returns an object indicating the sign of the radian's Cosine, Sine and Tangent. ==============================================*/ function getSigns(rad:Number):Object { var o:Object=new Object(); if(Math.sin(rad) >= 0){ o.sine="+"; }else{ o.sine="-"; } if(Math.cos(rad) >= 0){ o.cosine="+"; }else{ o.cosine="-"; } if(Math.tan(rad) >= 0){ o.tangent="+"; }else{ o.tangent="-"; } return o; }

check your signs for quad four…

Be the Greatest,

Liam

It is always difficult to get knowledgeable people with this issue, nevertheless, you be understood as you understand exactly what you are posting about! Appreciate it.