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
1
vote
2 answers

How to compute directional angle between two 2D vectors in MatLab?

I am trying to implement a script to analyze some of my data. I have position information for three points (p1,p2,p3). I would like to find the angular displacement of point p3 from the vector p1p2, as in this picture: p3a, p3b, p3c, p3d show…
1
vote
1 answer

Rotating UIView (Again)

I'm encountering some problems with rotating a uiview again. This time, im trying to rotate a uiview 1/12 the speed of another uiview I'm rotating at normal speed. However, when I try to accomplish this task, the uiview I'm trying to move slower…
Alexyuiop
  • 813
  • 2
  • 10
  • 25
1
vote
3 answers

How to detect area while tapping inside circle in ios

I want to find the area while tapping inside the circle. Actually I have done one calculation, but that was not accurate. Check the code snippet I wrote, in order to find the position of the tab in my cycle view. - (void)touchesBegan:(NSSet…
iPC
  • 5,916
  • 3
  • 26
  • 38
1
vote
1 answer

How can i map both angles (theta and phi) of the spherical coordinates to 360 degrees

to get the spherical coordinates (theta, phi and alpha) i use this code: double phi_rad = atan2f(z,sqrt((x*x)+(y*y))); double theta_rad = atan2f(y, x); double r = sqrt((x*x)+(y*y)+(z*z)); And to map theta to 0-360 degrees i use this code: double…
Schulle
  • 162
  • 1
  • 8
1
vote
6 answers

Draw a polygon in C

i need to draw a polygon of "n" sides given 2 points (the center and 1 of his vertex) just that i suck in math. I have been reading a lot and all this is what i have been able to figure it (i dont know if it is correct): Ok, i take the distance…
ezgar
  • 1,760
  • 3
  • 12
  • 11
0
votes
1 answer

Rotate a sprite in the direction of it's movement vector

I've got an XNA Windows Phone Game and you move a sprite with the accelerometer My problem is that I can't figure out how to make the sprite face the direction it is moving. So far this is my code: arrowPos.Y += -accelState.X*10; …
ChappieZ
  • 15
  • 1
  • 5
0
votes
2 answers

image rotation in OpenGL atan2?

Any help with this I'm using OpenGL with C#. I cant use any other libraries other than: using System; using OpenGL; using System.Windows.Forms; using System.Collections.Generic; using System.Drawing; I cant seem to rotate my image so it faces the…
rx432
  • 93
  • 1
  • 3
  • 10
0
votes
3 answers

blackfin gcc-toolchain linking error math function like atan2 :undefined reference to ... within watan2.o

I've a problem with the classic math function linking of my bare metal program with blackfin tool chain linker. I tried many things but I cannot see why the libm.a does't provide the definitions for the function it use. Do I need to add an extra…
william pagnon
  • 335
  • 3
  • 16
0
votes
1 answer

Why Math.atan() and Math.atan2() are returning different results?

I have the below function returning me angles in radians from three points coded as below: function pointsToAngles(x1, y1, x2, y2, cpx, cpy) { const r1 = Math.atan((y1 - cpy)/(x1 - cpx)); const r2 = Math.atan((y2 - cpy)/(x2 - cpx)); …
Igor Shmukler
  • 1,742
  • 3
  • 15
  • 48
0
votes
1 answer

How to determine the angle of rotation of the Kinematic body to the other Kinematic body in godot engine?

There are 2 airplanes, I need the plane controlled by the AI to understand what angle to turn to fly in the direction of the plane, which is controlled by the player. I didn't find any youtube videos on this subject. Here is the code that I…
0
votes
0 answers

From rotation matrix to yaw angle and vice-versa: +/- 180deg offset?

I have a general 3D rotation matrix like this: |R11 R12 R13| |R21 R22 R23| |R31 R32 R33| From this rotation matrix, I know I can get the yaw Tait-Bryan Euler angle with this: yaw = atan2(R21, R11) In my system I have: R21 = Asin(r) + Bcos(r) R11 =…
Gilles jr Bisson
  • 449
  • 4
  • 11
0
votes
1 answer

Filling an area of piece of circle in square grid

I am trying to fill some particular circle areas on a square grid in Proceesing. However, I am facing some weird filling after I run my code. I used the "atan2" function to get the angle of points in the grid and apply some if conditions to limit…
0
votes
1 answer

JavaScript: Math.atan2 issue

Let's say I have an arbitrary polar coordinate: let pc = {theta: 3.1544967, radius: 0.8339594}; Need to do some Cartesian math with that and transform it back to polar one. However, I have noticed that if I just do this code: const pc = {theta:…
0
votes
1 answer

How to expand atan2 to plus/minus 3pi

I want to estimate the phase of harmonic distorted tones when having input tones with random initial phase within [-pi;pi]. I used atan2, build-in function of Matlab, however the phase jump at -pi or pi makes my calculation of phase difference…
0
votes
1 answer

p5.js rotate towards mouse using atan2() has innacurate rotation

I have recently started a new project using p5.js and am running into issues with rotation, which you can view in the code snippet below. The rectangle rotating around the player is slightly incorrect in its rotation amount as you can see when you…
thesimg
  • 328
  • 1
  • 12