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
0
votes
1 answer

SFML atan2 function and deceleration

if(wIsPressed){ movement.x += sin((player.getRotation() * 3.141592654)/ 180) * .5; //accelerates ship at a rate of 0.5 ms^2 movement.y -= cos((player.getRotation() * 3.141592654)/ 180) * .5; //accelerates ship at a rate of 0.5 ms^2 } else…
user3500457
  • 1
  • 1
  • 1
  • 1
0
votes
1 answer

Determine the coordinates of a segment

How can I use atan2 to determine the coordinates where a segment ends, knowing the coordinates where it starts (x, y), the angle of the segment and the length of the segment? Can you tell me a solution it doesn't have to be only with atan2...
afsq
  • 3
  • 5
0
votes
2 answers

Precision of cos(atan2(y,x)) versus using complex , C++

I'm writing some coordinate transformations (more specifically the Joukoswky Transform, Wikipedia Joukowsky Transform), and I'm interested in performance, but of course precision. I'm trying to do the coordinate transformations in two ways: 1)…
Ivan
  • 19,560
  • 31
  • 97
  • 141
0
votes
1 answer

get angles using atan2 on circle for robot simulation

I am doing a simulation on a robot that makes circular motion with a center coordinate (x1, y1). The robot measures its position periodically and returns the information. Let's say the returned coordinate is (x3, y3). However, I'm not too sure about…
TonyW
  • 18,375
  • 42
  • 110
  • 183
0
votes
2 answers

Unwrapping everything in the same direction

I asked a similar question yesterday about how to avoid 'jumps' in data when using atan2d. The function operates on a scale of -180 to 180, like this: When a number crosses over 180, it goes directly to -180, making line plots very ugly and not…
0
votes
0 answers

Trouble using atan2 to get the angle of a collision in box2d

So I'm using box2d to handle physics and collisions in libGDX. I'm trying to figure out the angle of the collision so that I can apply certain effects at a given angle. Doing some research, I found that atan2 should be the math function I need to…
Scuba Steve
  • 1,541
  • 1
  • 19
  • 47
0
votes
1 answer

Get the point which in the line form atan2 and distance

have two point,I want to get the point in the line which these two point linked. I know the distance form one of these two point. just like this http://jsfiddle.net/icai/2pmk3/ var r = new Raphael(document.getElementById('canvas'), 500, 500), π…
Terry
  • 127
  • 1
  • 11
0
votes
0 answers

angle distance between two rotating objects

This may be well a trivial quesiton, but I can't find a solution I am pleased with. I'd like to calculate the distance (angle, radiants) between two rotating objects, whose x,y coordinates are given. Let's assume the objects rotate on the (xc=0.0,…
NoIdeaHowToFixThis
  • 4,484
  • 2
  • 34
  • 69
0
votes
1 answer

Angle and its inverse using Math.atan2

var vTheta = Math.atan2(v.vy,v.vx); var obsAngle = Math.atan2(-v.vy,-v.vx); This is the original code I used to find a vector angle and its inverse. They are used for some different calculations later in the code. I wanted to remove the second…
Shytor
  • 15
  • 3
0
votes
2 answers

atan2() in gcc strange behavior, w_atan2.c: No such file or directory

I have included in my code the math.h and also used -lm but when i use the gcc debugger when it comes to atan2() i get the following: 16 result = atan2(x,y) * val; (gdb) __atan2 (y=15, x=32) at w_atan2.c:31 31 w_atan2.c: No such file or…
user3143155
  • 49
  • 1
  • 6
0
votes
1 answer

Calculate Bearing with lat and long but do not have ATAN2 function

I've been searching the web trying to find a way to calculate bearing without using the ATAN2 function. I found the this code but I can't make it work. I trying to validate the equation before I use it in my PLC program but the numbers are not…
0
votes
3 answers

coverting an angle to a vector and back changes the angle?

So I have the following angle (rad): 3.45575213 Now I convert it via cos & sin to a vector (tDir is zero before): tDir.x += cos(target->direction); tDir.y += sin(target->direction); now I convert it back via: float newDir = Wrap2PI(atan2(tDir.y,…
pixartist
  • 1,137
  • 2
  • 18
  • 40
0
votes
2 answers

Android Java atan2() results is between -Pi, Pi or 0, 360 (two finger rotation related)?

I'm sorry for such basic question, but I'm trying to implements two finger rotation on Android and I found several post here on SO, trying to make sense of them I couldn't understand why sometimes the result of atan2 is considered between -Pi and Pi…
datamosh
  • 130
  • 3
  • 10
0
votes
2 answers

Point rectangle in direction of velocity (XNA)

I've tried Math.Atan2(futurePos.Y - pos.Y, futurePos.X - pos.X) as the rotation, but it only seems to work on the X axis. Whereas if I do Math.Atan2(mouse.Y - pos.Y, mouse.X - pos.X) it works just fine (although I have to manage if the velocity is a…
ShadowByte
  • 83
  • 10
0
votes
2 answers

Math.Atan2 or class instance problem in C#

Here is my problem (C#) : double Y = 0.0; double X = -21.0; double q1_Test = Math.Atan2(0.0, -21.0); // gives Math.Pi double q1_Test2 = Math.Atan2(( double)Y, (double)X); // gives Math.Pi double w1 =…
Rick2047
  • 1,565
  • 7
  • 24
  • 35