Questions tagged [atan2]

A function in many programming languages for computing the arctangent with two arguments

A function in many programming languages for computing the arctangent with two arguments

152 questions
6
votes
4 answers

Calculate average of wind direction in MySQL

I have a table with the wind direction (among other weather values) every 10 seconds on a new row. The direction is stored as degrees: 0 - 360. Purpose What is the meaning of this average? The database stores every 10 seconds a row with…
stUrb
  • 6,612
  • 8
  • 43
  • 71
5
votes
5 answers

Calculate angle based on x, y position

I am trying to calculate the angle for an arrow on a ball, based on the position where it is going to. The arrow moves, but in a total unexplainable direction, can anybody give some pointers? Codepen available: Codepen I added the full code on here…
Barry
  • 75
  • 5
5
votes
1 answer

what will be atan2 output for both x and y as 0

theta=atan2(0,0); The output of this statement is 0, but it is a 0/0 form , so how its output can be 0, even wikipedia says that it should be undefined , please explain why compiler gives 0 as output for this statement.
LocalHost
  • 910
  • 3
  • 8
  • 24
5
votes
1 answer

ParaView Calculator atan2

I'm currently trying to convert given Cartesian coordinates (x,y,z) to spherical coordinates (r, theta, phi) using the ParaView Calculator-Filter, where theta is the polar angle and phi the azimuthal angle. This I want to do over a domain of a…
ncim
  • 63
  • 1
  • 6
5
votes
1 answer

How do I perform the atan2 function in T-SQL?

I need to execute the ATAN2 function in MS SQL Server. How do I do this? T-SQL appears to have all the usual math functions like cos, sin, radians etc, just not ATAN2. What is the function for this? Knowing how to do this in MySQL would be very…
Matt W
  • 11,753
  • 25
  • 118
  • 215
4
votes
2 answers

atan2 for two sinusoids of arbitrary phase shift?

I'm trying to implement an atan2-like function to map two input sinusoidal signals of arbitrary relative phase shift to a single output signal that linearly goes from 0 to 2π. atan2 normally assumes two signals with a 90 deg phase shift. Given…
tarabyte
  • 17,837
  • 15
  • 76
  • 117
4
votes
2 answers

Is it safe to assume that atan2(0,0) returns 0?

It seems thatatan2(0,0) in C is defined this way. Python just delegates the common trigonometric functions to the underlying C implementation, right?
Emanuel Landeholm
  • 1,396
  • 1
  • 15
  • 21
4
votes
1 answer

Fast, crude version of atan2() for C/Objective-C/Swift?

I'm working on some graphics code that does live drawing of smooth, continuous curves. I want to add support for feathered brushes. For that, I need to be able to calculate "normals", or lines perpendicular to, the line segments that make up my…
Duncan C
  • 128,072
  • 22
  • 173
  • 272
4
votes
3 answers

Find clockwise angle between two points with respect to an arbitrary origin

I have two points A(X,Y) and B(P,Q) in the first quadrant. There's another point C(L,M). How do I find angle between CA and CB in clockwise direction? I searched a lot and all the solution used atan2() but it finds the angle from origin with…
Saurabh Shrivastava
  • 1,055
  • 1
  • 12
  • 26
4
votes
0 answers

What's the difference between atan and atan2

I have a question. What's the difference between atan and atan2 in JavaScript? I want to figure out the angle between the vector V (-1, 0) and the axis. When I called the method atan(0 / -1), the answer was -0 rad. When I called the method atan2(0,…
Tirafesi
  • 1,297
  • 2
  • 18
  • 36
4
votes
1 answer

Plotting an intuitive graph of angles

I'm trying to plot the heading of an object. I have four vectors of points - let's call them mdex mdey (aka x1,y1), thpx thpy (aka x2,y2). I am finding the change in y and the change in x (dy and dx) and then entering that into the atan2d…
4
votes
1 answer

SIMD vectorize atan2 using ARM NEON assembly

I want to calculate the magnitude and the angle of 4 points using neon instructions SIMD and arm assembly. There is a built in library in most languages, C++ in my case, which calculates the angle (atan2) but for only one pair of floating point…
Ammar
  • 71
  • 1
  • 3
4
votes
6 answers

Trying To Calculate the Difference between two angles (atan2)

Atan2(y,x) will return a float between -pi and pi. I want to calculate the distance between two angles, but the non-continuity is throwing me off. See this for better understanding. I want to be able to calculate the distance between Angle 1 and…
ATD
  • 824
  • 1
  • 9
  • 14
3
votes
0 answers

Get two vector rotations to obtain one vector direction

I do not know how to approach this math problem. Any hint would be much appreciated. Before I could solve such problem using Atan2 method to get two vector angles, when axes c and a are orthogonal. Problem: there are two non orthogonal to each other…
3
votes
4 answers

matlab variance of angles

I have a matrix containing angles and I need to compute the mean and the variance. for the mean I procede in this way: for each angles compute sin and cos and sum all sin and all cos the mean is given by the atan2(sin, cos) and it works my question…
andrea
  • 1,326
  • 7
  • 31
  • 60
1
2
3
10 11