I'm using google calculator for an equation. The number sixty is a degree.
If I put it in like this, I get:
80 * cos(60) = -76.1930384
But if I put the word 'degrees' I get this:
80 * cos(60degrees) = 40
Which one is the right answer?
If you do not specify it to be actual degrees, it will assume it is in PI. Once around the sphere equals 2* PI, which means that your 60 equals 19.09 PI, meaning you got the cosinus for 1.09 PI, or 196 degrees.
Both answers are correct - first one calculates cosinus of 60 radians and the second of 60 degrees.
By default the 60 alone will be considered 60 radians, so that's why you get a different result
80 * cos(60) uses Radians
80 * cos(60degrees) uses Degrees
Since your value (60) is in Degrees, add the keyword 'degrees'
The first calculation is in Radians, the second is (obviously) in Degrees.
Related
Who is a math wiz and wants to check my math?
I'm trying to find the placement of a point(x,y) on the circumference of a circle in degrees. If I use x=radius*cos(Q)+xOrigin, I end up with arccos((x/2)-xOrigin) = Q which gives me the angle in radians. Then I go D = Q(180/Pi) to get degrees, but I keep coming up about 3-5 degrees off of target.
What's up with that?
Your formula for Q should be
Q = acos((x-xOrigin)/radius)
Note that acos returns an angle between 0 and pi; if the angle is in the third or fourth quadrant you'll need to subtract the angle from 2 * pi.
Without knowing the actual values that are coming up wrong, it's hard to tell if that's the only problem. Your conversion from radians to degrees is correct.
Most modern programming languages have atan2() somewhere, which takes a rise and a run and spits out the angle in radians in all four quadrants.
I am trying to understand trigonometry and the short answer is that I do not.
I drew a little triangle to mess around with and I asked myself the question, "If I know the length of the hypotenuse and the angle, how do I find the length of the other edges?".
Then I started reading. Apparently, the sine of angle A is supposed to equal the length of the opposite side divided by the length of the hypotenuse. So I figured that, using a right triangle, multiplying the length of the hypotenuse by the sine of the angle would yield the length of the opposing side.
1.414 / 1 = .707blahblah * 1.414 = 1 on my calculator.
But in every programming language I try sin(45.0) equals .8somethingsomething. I tried c++, c#, java, php, and lua.
Is the input not being interpreted as degrees? What unit is being used and how do I convert it? I've been seeing the word Radians, it would be helpful if someone could explain what a Radian is.
Radians are units of angular measure, like degrees, except that while there are 360 degrees in a circle, there are 2*pi (about 6.28) radians in a circle. You can convert degrees to radians by multiplying by pi (3.14159) and dividing by 180.
The formula works if the triangle is a right triangle, and yes, most programming languages expect radians rather than degrees as arguments to functions like sin() and cos().
Regarding the argument in the comments below: if you fix angle <BAC, side AB, and side BC, you can see that there are two possible positions for point C which preserve the the length D2 for side BC. Therefore <BAC, D1, and D2 do not fully determine a triangle.
The input to sin functions generally is expected in radians, not degrees. For example, in the Java documentation for sin it's stated that:
Parameters:
a - an angle, in radians.
Convert the angle in degrees to radians first, by multiplying it by pi/180
A radian is the distance of the radius of a circle along its circumference. Since a circle's circumference is 2 times pi times its radius, there are 2 times pi radians in one complete circle.
Yes, you are correct. Those functions all take their input in radians, not degrees.
You can convert degrees to radians by multiplying the degrees by π/180.
Convert to radians: Radian = degree/180*Pi
In order to convert from degrees to radians, divide the number in degrees by 180 and multiply by pi.
This is basically just a math question.
Heres what I am having troubles with... I am having a difficult time coming up with how to phrase the question, so bear with me. Basically I think I need to use some advanced math to accomplish this, but I do not know what I need.
I will use some illustrations to make this clear. Spam prevention doesn't let me post pictures... Here's a simple concept image though: http://radleygh.com/images/gimp-2_2011-057-00-57-26-40.bmp
Objective: Determine if several objects lie within a cone on a 2D plane
Cone Properties:
Position (x, y)
Angle (0-359)
Spread (0-359, aka Width)
Distance (0++)
I can decide the brownish lines using a simple bit of math:
Angle_A = Angle + (Spread / 2)
Angle_B = Angle - (Spread / 2)
Angle_Target = Point_Direction(origin, object_position)
Now I thought of comparing these with the position of each object with a simple if/then statement:
If (Angle_A > Angle_Target) && (Angle_B < Angle_Target) Then Angle_Target is between A and B
This works... untill Angle_A or Angle_B pass the 0-360 threshold. 0* is between 45* and 315*... but the above if statement wouldn't work. We can then determine which direction to check based on the size of the cone...
And what if the cone effect is larger than a 180* cone?
I'm not sure of the answer. I'm pretty sure I should be using Radians... But I do not understand the concept of Radians. if someone can point me in the right direction, perhaps show me an example somewhere, that would be wonderful!
I will continue to do my own research in the mean time.
You may consider a simple transformation which sets your coordinate system such that Angle_B is zero. In other words, instead of testing
Angle_B < Angle_Target < Angle_A
you may also use
0 < Angle_Target - Angle_B < Angle_A - Angle_B
If you apply a modulo 360° to all terms you're logic should work:
0 < (Angle_Target - Angle_B) % 360 < (Angle_A - Angle_B) % 360
One radian is the angle made by tracing a circle's circumference by a length equal to that circle's radius. Hence there are exactly 2*PI radians in a circle.
So 2*PI radians = 360 degrees
So to convert degrees to radians, multiply by 2 * PI, then divide by 360. (Or of course, multiply by PI, divide by 180).
However, whether you work in radians or degrees should only be dictated by the library you are using. Even then, you could write wrappers which do the above calculations.
But to the main part of your question. Consider that:
sin (theta) = sin (360 + theta).
cos (theta) = cos (360 + theta).
etc.
So if you come across your cone that goes through 0 degrees, simply add 360 to both angles of the cone.
e.g. if your cone goes from -10 to +20, simply use 350 to 380 instead.
And of course, when you test an angle, make sure you also add 360 to that and test both the original and added angles.
e.g. testing +5 (which is in your cone), you would test 5 (which fails) then 365 (which passes).
Good luck!
I noticed that translating radians to degrees and vice versa is like translating a percentage to a whole number and vice versa. For example, to get 60 percent of 345 you do the following
60 * 345/100
to convert 60 degrees to radians you do
60 * 3.14/180
There is a pattern there BUT... we use 100 to compare percentages to a number. So, why do we use 180 degrees instead of 360 degrees to compare degrees to radians?
%100 percent = a whole number
360 degrees represents a whole circle
using 180 degrees is like using 50% instead of 100%
I hope I am making some sense. Can anyone answer? Thanks
The reason you use 180 degrees instead of 360 is that there are 2*pi radians in a circle, not pi. Thus you divide both 360 and 2*pi by 2 and get pi and 180.
In Mathematica, I use the handy predefined Degree constant for conversions, which is defined as Pi/180 or 2 * Pi/360.
The reason there are 2 * Pi radians in a circle is that the size of an angle in radians is the length of the arc of a circle with radius 1 that subtends it. The circumference of a circle with radius 1 is 2 * Pi. In addition to providing a clear geometrical interpretation, using radians also makes a number of other relations much more convenient; cosine is the derivative of sine, and as a result the Maclaurin series for sines and cosines are much simpler than they would be for angles expressed in degrees.
360 degrees = 2 * Pi radians
1 degree = Pi / 180 radians
I guess your question is, why there 360 degrees in a circle (or 180 in a semicircle), and why not some other more tenable number like 100.
The answer to that is the origin of degree. If you'd like to use a round figure, check out the gradian unit of angles.
PS: SO is for programming questions only. This is not programming related.
I ask this question because my lack of paying attention in school. Programming actually is the reason I ask this question because it is now that I am actually paying attention. Every programming formula uses 180 and PI to translate back and forth instead of 360. Since I haven't came across any examples, I assumed that there was only one way. Of course if I was reading a regular math book, I would of known differently.
But I understand now. Actionscript uses 180 degrees for clock wise rotation. once 180 is reached, it uses -180 back down to 0 for a full rotation. Which makes alot more sense if you want your answer to fall in the 180 degree range. and depending on if its negative or positive determines whether or not it is traveling up on the x axis or down and y axis as well. As much as I appreciate the responses, I believe this is absolutely a suitable programming question. For programmers calculating in degrees is different from your average surveyor.
Given a real life scenario, measuring a distance is always considered a absolute value, where programming this is false. which also rationalizes why we use -180 degrees.
Math escapes me today.
How do I find the X speed and the Y speed of an object if it is going at a defined speed (say, 5 pixels/second) at a 45 degree angle?
So always 5 pixels/sec and always 45 degrees?
The general case is
velx=cos(a)*vel;
vely=sin(a)*vel;
a is angle, usually in radians, so convert from degrees, and the signs (positive/negative) will depend on your coordinate system.
Crazy fact from the 1980s: In the old days, we used lookup tables for sin and cos!
Edited: Made my axes more conventional thanks to comment below. x is positive to your right. y is positive up. 45 degrees is to the northeast. If you have something else, let me know.
It will be
Vx=VCos#
Vy=Vsin#
So in your case it will be Vx=5*cos45 and Vy=5*sin45
At 45 angle value of Cos & Sin is same i.e 1/root 2.
Note: If you are doing any math stuff in programming then have a look at Vecmath lib.
At a 45 degree angle, an object is going sqrt(2)/2 of the speed along each axis. Generally, you can do it with sin and cosine, but for specific angles like this you can do it just by knowing pythagorean triangles.
In a right triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides. You know the hypotenuse is V. You also know that the other two sides equal each other. That means that V^2 = Vx^2 * 2. This means that Vx = sqrt(V^2/2), which equals V * sqrt(1/2).