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
613
votes
25 answers

How to use the PI constant in C++

I want to use the PI constant and trigonometric functions in some C++ program. I get the trigonometric functions with include . However, there doesn't seem to be a definition for PI in this header file. How can I get PI without defining it…
Etan
  • 17,014
  • 17
  • 89
  • 148
309
votes
22 answers

How does C compute sin() and other math functions?

I've been poring through .NET disassemblies and the GCC source code, but can't seem to find anywhere the actual implementation of sin() and other math functions... they always seem to be referencing something else. Can anyone help me find them? I…
Hank
  • 8,289
  • 12
  • 47
  • 57
264
votes
9 answers

How to calculate the angle between a line and the horizontal axis?

In a programming language (Python, C#, etc) I need to determine how to calculate the angle between a line and the horizontal axis? I think an image describes best what I want: Given (P1x,P1y) and (P2x,P2y) what is the best way to calculate this…
orlp
  • 112,504
  • 36
  • 218
  • 315
250
votes
6 answers

How do I calculate a point on a circle’s circumference?

How can the following function be implemented in various languages? Calculate the (x,y) point on the circumference of a circle, given input values of: Radius Angle Origin (optional parameter, if supported by the language)
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
176
votes
12 answers

What is the method for converting radians to degrees?

I run into this occasionally and always forget how to do it. One of those things that pop up ever so often. Also, what's the formula to convert angles expressed in radians to degrees and back again?
Hans Sjunnesson
  • 21,745
  • 17
  • 54
  • 63
114
votes
7 answers

How do Trigonometric functions work?

So in high school math, and probably college, we are taught how to use trig functions, what they do, and what kinds of problems they solve. But they have always been presented to me as a black box. If you need the Sine or Cosine of something, you…
Jurassic_C
  • 2,373
  • 3
  • 22
  • 19
104
votes
13 answers

Calculating the position of points in a circle

I'm having a bit of a mind blank on this at the moment. I've got a problem where I need to calculate the position of points around a central point, assuming they're all equidistant from the center and from each other. The number of points is…
JoeBrown
  • 1,051
  • 2
  • 8
  • 4
90
votes
12 answers

Endless sine generation in C

I am working on a project which incorporates computing a sine wave as input for a control loop. The sine wave has a frequency of 280 Hz, and the control loop runs every 30 µs and everything is written in C for an Arm Cortex-M7. At the moment we are…
energetic
  • 897
  • 1
  • 5
  • 7
76
votes
20 answers

Fastest implementation of sine, cosine and square root in C++ (doesn't need to be much accurate)

I am googling the question for past hour, but there are only points to Taylor Series or some sample code that is either too slow or does not compile at all. Well, most answer I've found over Google is "Google it, it's already asked", but sadly it's…
PiotrK
  • 4,210
  • 6
  • 45
  • 65
64
votes
6 answers

numpy.sin function in degrees?

I'm working on a problem that has to do with calculating angles of refraction and what not. However, it seems that I'm unable to use the numpy.sin() function in degrees. I have tried to use numpy.degrees() and…
Daniil Ukhorskiy
  • 653
  • 1
  • 5
  • 5
59
votes
5 answers

2D Euclidean vector rotations

I have a euclidean vector a sitting at the coordinates (0, 1). I want to rotate a by 90 degrees (clockwise) around the origin: (0, 0). If I have a proper understanding of how this should work, the resultant (x, y) coordinates after the rotation…
hiddensunset4
  • 5,825
  • 3
  • 39
  • 61
55
votes
2 answers

How can I generate random points on a circles circumference in javascript

I am trying to write a function that will randomly return an (x,y) co-ordinates around a given circumference so if I have a point that's at (0,0) (being the center of the div) how can I write a function that randomly places other entities that…
Mouseroot
  • 1,034
  • 2
  • 9
  • 13
55
votes
7 answers

Inverse Cosine in Python

Apologies if this is straight forward, but I have not found any help in the python manual or google. I am trying to find the inverse cosine for a value using python. i.e. cos⁻¹(x) Does anyone know how to do this? Thanks
Sheik Yerbouti
  • 1,054
  • 1
  • 8
  • 14
54
votes
5 answers

How to calculate rotation in 2D in Javascript

I am not so familiar trigonometry, but I have only two points to rotate in 2D: *nx, ny . - . - . angle - *cx,cy.................*x,y cx, cy = rotation center x,y = current…
Digerkam
  • 1,826
  • 4
  • 24
  • 39
53
votes
6 answers

How to convert x,y coordinates to an angle?

Microsoft provide an excellent SVG gradient maker so IE9 can also have "CSS3" gradients (click Custom). I currently utilise their logic for my Fireworks and Dreamweaver extensions to convert gradients to SVG, but I only know how to do it for…
Matt Stow
  • 6,053
  • 6
  • 24
  • 26
1
2 3
99 100