Questions tagged [trigonometry]

Trigonometry is a branch of mathematics that studies triangles and the relationships between their sides and the angles between sides

Trigonometry is a branch of mathematics that studies triangles and the relationships between their sides and the angles between sides. Trigonometry defines the trigonometric functions, which describe those relationships and have applicability to cyclical phenomena, such as waves.

Trigonometry can be implemented into many programming languages, such as python. Trigonometry can be used to find an angle in a triangle using the side lengths etc.

References:

3369 questions
42
votes
6 answers

Calculating bounding box a certain distance away from a lat/long coordinate in Java

Given a coordinate (lat, long), I am trying to calculate a square bounding box that is a given distance (e.g. 50km) away from the coordinate. So as input I have lat, long and distance and as output I would like two coordinates; one being the…
Bryce Thomas
  • 10,479
  • 26
  • 77
  • 126
40
votes
4 answers

Vector Space Model: Cosine Similarity vs Euclidean Distance

I have corpora of classified text. From these I create vectors. Each vector corresponds to one document. Vector components are word weights in this document computed as TFIDF values. Next I build a model in which every class is presented by a single…
Anton Ashanin
  • 1,817
  • 5
  • 30
  • 43
40
votes
5 answers

Math.cos() gives wrong result

According to Wolfram Mathematica: cos(50) = 0.6427876096865394; But this code in Java: System.out.println(Math.cos(50)); gives 0.9649660284921133. What is wrong with java.lang.Math?
z3on
  • 411
  • 1
  • 4
  • 4
39
votes
4 answers

Inverse of Tan in python (tan-1)

I am trying to calculate the inverse of tan in python, but it does not give me the correct value, for example, if I were to do the inverse tan of 1.18, math.atan(1.18) >>>math.atan(1.18) 0.8677 However, the correct answer is 49.720136931. What is…
user1294592
  • 463
  • 2
  • 5
  • 6
38
votes
3 answers

sine result depends on C++ compiler used

I use the two following C++ compilers: cl.exe : Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86 g++ : g++ (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010 When using the built-in sine function, I get different results. This is not…
Nicolas
  • 1,812
  • 3
  • 19
  • 43
38
votes
2 answers

Finding Signed Angle Between Vectors

How would you find the signed angle theta from vector a to b? And yes, I know that theta = arccos((a.b)/(|a||b|)). However, this does not contain a sign (i.e. it doesn't distinguish between a clockwise or counterclockwise rotation). I need something…
Cerin
  • 60,957
  • 96
  • 316
  • 522
37
votes
7 answers

How do I calculate the cosine similarity of two vectors?

How do I find the cosine similarity between vectors? I need to find the similarity to measure the relatedness between two lines of text. For example, I have two sentences like: system for user interface user interface machine … and their…
shiva
35
votes
2 answers

swift trigonometric functions (cos, tan, arcsin, arcos, arctan)

hello I have to differenciate calculations in degrees and I have the following code but I doesn't return me the exact values. The only one right is the value of sin90 in degree = 1 //////***** DEGREES ******////// var sinus = sin(90.0 * M_PI /…
kepi
  • 377
  • 1
  • 3
  • 7
34
votes
2 answers

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

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…
jjNford
  • 5,170
  • 7
  • 40
  • 64
34
votes
8 answers

Calculating the angle between two lines without having to calculate the slope? (Java)

I have two Lines: L1 and L2. I want to calculate the angle between the two lines. L1 has points: {(x1, y1), (x2, y2)} and L2 has points: {(x3, y3), (x4, y4)}. How can I calculate the angle formed between these two lines, without having to calculate…
jNoob
  • 361
  • 1
  • 3
  • 4
31
votes
1 answer

Draw a line at a specific angle in Java

Let's say I have an (x,y) that is always the same for the start point of a line and an (x,y) that changes for the end point of that same line. The line is also always 40px long. At the start of the program the line originates in a vertical…
ubiquibacon
  • 10,451
  • 28
  • 109
  • 179
31
votes
3 answers

Finding the coordinates on the edge of a circle

Using C#: How do I get the (x, y) coordinates on the edge of a circle for any given degree, if I have the center coordinates and the radius? There is probably SIN, TAN, COSIN and other grade ten math involved... :)
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
30
votes
9 answers

Cheap algorithm to find measure of angle between vectors

Finding the angle between two vectors is not hard using the cosine rule. However, because I am programming for a platform with very limited resources, I would like to avoid calculations such as sqrt and arccos. Even simple divisions should be…
Jeroen
  • 803
  • 1
  • 7
  • 13
30
votes
5 answers

Getting angle back from a sin/cos conversion

I want to reverse a sin/cos operation to get back an angle, but I can't figure out what I should be doing. I have used sin and cos on an angle in radians to get the x/y vector as such: double angle = 90.0 * M_PI / 180.0; // 90 deg. to rad. double…
Eric Fortier
  • 760
  • 1
  • 7
  • 16
29
votes
4 answers

Calculate second point knowing the starting point and distance

using a Latitude and Longitude value (Point A), I am trying to calculate another Point B, X meters away bearing 0 radians from point A. Then display the point B Latitude and Longitude values. Example (Pseudo code): PointA_Lat = x.xxxx; PointA_Lng =…
pawelglow
  • 708
  • 1
  • 10
  • 20