trigonometry

Why do sin(45) and cos(45) give different results? [duplicate]

不问归期 提交于 2019-12-18 07:12:29
问题 This question already has answers here : Is floating point math broken? (31 answers) Closed 4 years ago . This is something I wasn't expecting. I know these numbers are not 100% exact, but I wasn't expecting complementary angles giving different results of sin and cos : This following function returns 0.70710678118654746000000... sin(45 * PI / 180.0); while this follwing function returns 0.70710678118654757000000... cos(45 * PI / 180.0); so, it's: 0.707106781186547**46**000000... vs 0

Why do sin(45) and cos(45) give different results? [duplicate]

元气小坏坏 提交于 2019-12-18 07:12:26
问题 This question already has answers here : Is floating point math broken? (31 answers) Closed 4 years ago . This is something I wasn't expecting. I know these numbers are not 100% exact, but I wasn't expecting complementary angles giving different results of sin and cos : This following function returns 0.70710678118654746000000... sin(45 * PI / 180.0); while this follwing function returns 0.70710678118654757000000... cos(45 * PI / 180.0); so, it's: 0.707106781186547**46**000000... vs 0

OpenGL - Rotate a 'Curve' About the Y-Axis

跟風遠走 提交于 2019-12-18 06:49:58
问题 As per my question on Math Stackexchange: I am working on a project for my 3D Graphics class. The project is built with C++ and OpenGL / Glut. Basically, I create a horizontal rectangle window, subdivided into two squares. On the left, I have a two dimensional coordinate plane, which allows the users to point and click and define a profile 'curve'. I then need to wrap this curve around the Y-axis n number of times. So, would anyone be able to guide me as to how I would use Trigonometry to

Cosine Similarity

試著忘記壹切 提交于 2019-12-17 21:57:29
问题 I calculated tf/idf values of two documents. The following are the tf/idf values: 1.txt 0.0 0.5 2.txt 0.0 0.5 The documents are like: 1.txt = > dog cat 2.txt = > cat elephant How can I use these values to calculate cosine similarity? I know that I should calculate the dot product, then find distance and divide dot product by it. How can I calculate this using my values? One more question: Is it important that both documents should have same number of words? 回答1: a * b sim(a,b) =-------- |a|*

Is the Haversine Formula or the Vincenty's Formula better for calculating distance?

自闭症网瘾萝莉.ら 提交于 2019-12-17 21:57:00
问题 Which is better for calculating the distance between two latitude/longitude points, The Haversine Formula or The Vincenty's Formula? Why? The distance is obviously being calculated on Earth. Does WGS84 vs GCJ02 coordinates impact the calculation or distance (The Vincenty's formula takes the WGS84 axis into consideration)? For example, in Android, the Haversine Formula is used in Google Map Utils, but the Vincenty Formula is used by the android.Location object ( Location.distanceBetween() ).

Write code to make CPU usage display a sine wave

寵の児 提交于 2019-12-17 21:48:28
问题 Write code in your favorite language and let Windows Task Manager represent a sine wave in CPU Usage History. This is a technical interview quiz from Microsoft China. I think it's a good question. Especially it's worth knowing how candidate understand and figure out the solution. Edit : It's a good point if may involve multi-core(cpu) cases. 回答1: A thread time slice in Windows is 40ms, iirc, so that might be a good number to use as the 100% mark. unsigned const TIME_SLICE = 40; float const PI

Python cos(90) and cos(270) not 0

蹲街弑〆低调 提交于 2019-12-17 20:37:11
问题 What is going on?? Testing out sin and cos functions to find out why I get so beautiful positioning on the wrong places when outputting my coordinates into a SVG file. So I made this test code, which I can predict what the answer is to find out why. Oddly nothing that effects the calculation it self adds this behavior but simply the position of where I'm about to stay. If the position is 0 and will become 0 after the calculation it won't work, but if position is 1 and will become 1 after the

Unusual Math with incorrect results? [duplicate]

十年热恋 提交于 2019-12-17 16:53:11
问题 This question already has answers here : math.sin incorrect result (2 answers) Closed 4 years ago . My python interpreter is acting funky when I use the math.cos() and math.sin() function. For example, if I do this on my calculator: cos(35)*15+9 = 21.28728066 sin(35)*15+9 = 17.60364655 But when I do this on python (both 3.2 and 2.7) >>> import math >>> math.cos(35)*15+9 -4.5553830763726015 >>> import math >>> math.sin(35)*15+9 2.577259957557734 Why does this happen? EDIT: How do you change

Simple circle rotation (simulate motion)

不羁岁月 提交于 2019-12-17 14:27:22
问题 I have a simple animation in Java that consists of a wheel moving across a window. It is just a plain circle that starts off of the screen from the left, enters and continues to the right until it goes off of the screen. Then it loops and repeats this process. X is a variable that contains the position of the wheel. It can be between -(wheel width) and the window size + the wheel width. I would like to simulate rotation by drawing a circle within this wheel, that rotates around the circle as

Game object rotation making an eliptical partern instead of circular

五迷三道 提交于 2019-12-14 04:19:57
问题 I have a simple game animation made in java. It is of three planets rotating around an axis. Each planet is an instance of the class Planet and they have an update method which, every time it is run, the orbit's rotation angle increases and the position is updated acording to the angle and a few predetermined variables like distance from the "sun". From here, you can determine the position of the planet with simple trigonometry. In this case: Sin(angle) = op/hyp = y/distance therefore Sin