tags:

views:

861

answers:

14

Is there any use of Sin(720)or Cos(1440) (angles in degrees)? Whether in computer programming or in any other situation? In general, is there any use of Sin/Cosine/Tan of any angle greater than 360?

In Physics we do use dot products and cross products a lot, but even they require angles less than 180 degrees always.

Hi All, I know how to compute them.... I want to know, if they are ever useful???? When will I ever encounter a situation, when I need to compute Sin(440) for example???

A: 

There definitely can be times when you might end up with an angle measure > 360 degrees because of some kind of calculation...but it would be identical to an infinite number of other angle measures, exactly one of which will be between 0 and 360. However, if you are coding a function, you should be able to handle this calculation yourself...not rely on the user to do the mod for you.

ie While it is true that sin(370) == sin(10), and the user could do this translation themselves, they may not want to for one reason or another (see the "bolt" example in the comments for the top rated answer), and so the function should be able to handle any value.

Beska
Please see my last edit.
dta
Got a downvote...? Not clear why.
Beska
+10  A: 

Both in math and programming:

Sin(x) = Sin(x % 360)

As another answer pointed out, angles greater than 360 represent one or more full rotations over a circle plus the modulo part. This could have a physical meaning in some circumstances.

Also, when doing trigonometric calculations, you should take this fact into consideration. For example:

sin(a)*cos(a) = (1/2)*sin(2a)

For a>180 you will get the sin of an angle greater than 360.

By the way, have a look here.

kgiannakakis
I want to know, what's its use?I know how to compute it....
dta
As a purely synthetic example, take a screw or a bolt. Rotations of more than 360° have a very specific and important meaning. The direction the head is facing would still be calculated modulo 360, but important information would be lost if its rotation were stored that way.
Ben Blank
+2  A: 

One rotation around a circle is 360 degrees or 2pi radians.

Trigonometric functions such as sine and cosine will "wrap around" when they reach 360 degrees and act the same way as being at 0 degrees. Basically, the following occurs:

angle_in_unit_circle = angle mod 360

Also, some trigonometric functions such as tangent are not defined at certain angles, such as 90 and 270 degrees, where tangent of an angle will return a positive or negative infinity.

This "wrapping" around can be seen by representing the sine, cosine, tangent functions using an right triangle inscribed in an unit circle, and this behavior makes those functions periodic because they will repeat their patterns over and over again.

Wikipedia has an extensive article on Trigonometric functions, so that might be worth taking a look at.

Usage

In terms of use, I can't quite think of a good example off the top of my head, except, maybe perhaps to represent a location of a particle at a certain time in a polar coordinate system, where the angle θ is dependent on time t:

r(θ(t)) = t    where θ(t) = t

for values of t from 0 to 720, which could then be represented in a Cartesian coordinate system as:

x(t) = r sin(θ(t)) == t sin(t)
y(t) = r cos(θ(t)) == t cos(t)

The particle will be moving in a spiral type movement, dependent on the time t. In this case, the sine and cosine of angles beyond 360 will be calculated.

(And my math is rusty, so if there are any errors in the equations above, please let me know!)

coobird
I want to know, if it will ever be needed to compute Sin(720)???I know how to compute it..
dta
A: 

Because sin(x) = sin(x mod 360°) and cos(x) = cos(x mod 360°) you can use every value in calculation, but you could also normalize to the range [0°,360°) or any other range of 360°. It just depends on the usage if large angles have a well defined meaning or not.

Processors will likley normalize the calculation to just a range of 90° or even less, and derive all other values from this small range.

When will arguments greater than 360° occur?

They naturaly occur in simulations of periodic time or space dependent functions.

Daniel Brückner
Please see my last edit.
dta
+1  A: 

On a sine curve, Sin(720) == Sin(0) (etc), so I'd expect any decent implementations of those functions to handle degrees "greater than" 360. There's any number of reasons for arriving at an angle greater than 360 or less than 0.

AndrewS
Addition, subtraction and multiplication being three of them.
aib
+4  A: 

I have seen such things come up when doing angle arithmetic:

float angleOne = 150;
float angleTwo = 250;

//...

float result = Sin(angleOne + angleTwo); // Sin(400)
float result = Sin(angleOne - angleTwo); // Sin(-100)

In this (contrived) example, it seems obvious, but when you are computing an angle based on arbitrary rotations of several objects, you can't always know what kind of numbers you would be getting. Imagine calculating the poisition of the player in a 3D game while he is standing on top of a spinning platform, for example.

e.James
+1  A: 
Jason S
A: 

Your question does not make much sense seeing as you seem to know the difference here:

No - you will never have to "compute" Sin(720), anymore than you will have a need to "compute" Sin(0). You need to look at the definition of the Sinus function to fully understand what goes on under the covers - and when that is understood it makes total sense for anyone as to why Sin(0) = Sin(720) - there's nothing magical going on, there's (logically) no Angle = FullAngle % 360 going on, it's all in the definition of what the function is supposed to do.

See wikipedia

kastermester
+3  A: 

Any time you're dealing with a user interaction technique, it's entirely possible that they'll push you past 0 degrees or 360 degrees. Imagine that you're making a game with a gun turrent. It's currently pointed at 359 degrees and the user yanks the joystick to the right: now it's pointed at 361 degrees. If you implement the angular representation wrong, all of a sudden, the gun with rapidly traverse nearly 360 degrees to the left.

I predict that the users will be ... disappointed with that bug.

There are all sorts of issues that come up with Euler angle representations of the frame of reference that are important in games, simulations and real device control. Gimbal lock is a serious problem in actual rotating device control (it was a problem with camera pan / tilt devices in my life). The "rapid rotation" bug was a very nasty issue in a small boat autopilot system once upon a time - imagine wrapping a steel cable very tightly around the wheel house (i.e., you don't want to be standing there).

Bob Cross
Thank you for the reference to gimbal lock. I learned something today :)
e.James
A: 

@dta, I think folks are a little confused. You ask if it's ever "useful." I'd say "It doesn't matter, because you just shift the angle to the proper range when performing the calculation." There are certainly cases where you need to know how far from 0 degrees an object has rotated, accounting for multiple rotations. But aside from those cases, it's more convenient to interpret angles in the normal 0-360 range. Most people build up an intuitive feel for which direction corresponds to angles in that normal range. What direction does 170,234 degrees point? The same as 314 degrees.

Scottie T
+3  A: 

There have been times where the normal math means you end up "traversing the circle" one or more times, and if you keep the math simple your angles might be greater than 360. Personally I like to normalize the angles to be 0 to 360 or -180 to 180 after such operations, but it's doesn't really matter much.

Sometimes the greater number might really represent something. To take a trivial example, imagine instructions to open a classic dial combination safe. You need to spin the dial around a couple of times, so the instructions could be:

   turn(800);  // Twice around plus another 20 degrees
   turn(-500); // Once around the other direction plus 140 degrees
   turn(40);   // Dial in the last digit

In that context, taking the sin or cos would tell you something about the ultimate position of the dial, but you would lose the information about how many turns were involved.

Chris Arguin
A: 

As @Chris Arguin and others said, whether sin of an angle greater than 360° (or for that matter less than -360°) is useful to you depends on whether you need the information about rotations (or fractions thereof) that is represented by the difference between angle and angle%360°.

Also, since you get the same answer, you'll save a little processing time if you call sin(angle) instead of sin(angle%360), especially if you are doing many computations in a loop.

OTOH, @Scottie T makes a good point that if it is important for someone to know where around a circle your angle points, people can generally intuit position of an angle with an absolute value of 360 or less easier than they can for larger angles.

JeffH
A: 

There are many circumstances where angles outside of [0,360] are needed. I like the idea of a combination lock. Here one will often see both positive and negative angles outside of the simple [0,360] degree range.

Multiple angle formulas are often important in mathematics. Trig functions are used in places other than just triangles. They appear in a variety of places, Fourier series for example, or image compression schemes, or the solution of differential equations. Computationally, it is true that you can always use mod to reduce the range for a trig function to the default. But it is rarely true that angles will always be provided in that nominal range.

woodchips
+1  A: 

Hello, I'm fifteen and play a PC game called Garry's Mod, and there are moments in the game where, when programming, I want a simple solution to keep an object constantly moving in a constant circle. To do this I use the sine and cosine of a forever increasing timer, measuring the amount of time since the game launched.

The sine of T (time) is equal to the orbit paths X value, while the cosine of T is equal to the orbit paths Y value(X and Y being on a 3 dimensional coordinate plane with Z not being used at the moment.)

Example:

T=1000 ticks X=sin(T) Y=cos(T)

So X is 0.8268795405320025 during that moment in time and Y is 0.15466840618074712.

Now let's say the amount of time grows to 1500. X would be -0.9939019569066535 and Y = -0.11026740251372914.

In a nutshell, it would constantly fluctuate from 1 to -1, leaving me the opportunity to multiply that value by say 100, and making the coordinate plane local to my characters position, then I can tell the programmed expression to move an object based on those coordinates and it would move in a constant circular path around me.

Tada. Who says you can't learn from video games?

Bren