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
0 answers

How do i rotate a sprite towards the mouse in p5.play?

i'm makig a top-down shooter game using the p5.play(p5) libraries. I want to rotate the player sprite towards the mouse. with the Atan2 function(https://p5js.org/reference/#/p5/atan2). i managed to rotate an image using this. but when i try to…
PineInDisguise
  • 103
  • 1
  • 7
1
vote
1 answer

Using atan2 to rotate an image when dragged with the mouse

I'm working on a skeletal animation editor. Right now, each bone has a start and end point, when the mouse is under a point,subsequent dragging will cause the bone to rotate based on where the mouse is. To do this, I call atan2 and transform the…
jmasterx
  • 52,639
  • 96
  • 311
  • 557
1
vote
4 answers

How to calculate third point on line using atan2?

I'm trying to animate some bitmaps out in relation to a center point. They don't all start at that center point, but I want them to fly out as though a force from that center point slammed into them and pushed them outwards radially, such that they…
David
  • 703
  • 1
  • 15
  • 31
1
vote
2 answers

Object does not rotate in the correct direction from Atan2 to Quaternion

I am trying to rotate an object on its z axis, given a point I calculated at an angle with Atan2 function. Then I create a Quaternion to enter it in the rotation of the object. However, it does not rotate in the supposedly correct direction. If I…
1
vote
2 answers

atan2 - find angle between two points (360deg)

I have a game where there is a Player and some enemies. These enemies, just as the player itself, can shoot bullets. But the angle of bullets don't change as it is supposed to; The newly created bullet is supposed to find the angle between itself…
Feelsbadman
  • 1,163
  • 4
  • 17
  • 37
1
vote
0 answers

Heading angle calculation using current lat/long from the GPS

The aim of my work is given in the algorithm below. Initialize the H/W; wait until GPS module has a valid fix and then start the motor. Get actual position from the GPS. Calculate the distance and heading information to the next waypoint. Compare…
1
vote
1 answer

tan inverse in matlab not giving correct values

As a part of a longer code, I get a quantity phi1 and phi2 (matrices of size 128x128) which are the arguments of a complex quantity. Now I define the following quantities in…
A Khan
  • 85
  • 8
1
vote
0 answers

Arctan function is discontinuous

I had a lot of issues trying to solve the problem with my plot of omega vs time, since the angle returned from the arctan function jumps up to a positive value. I tried adding 2*pi so that it returns to the first quadrant, but to no avail (from the…
Daniel George
  • 23
  • 1
  • 9
1
vote
2 answers

algorithm of calculating the slope between line relatively to center coordinate

Please help with the algorithm of calculating the slope So we have a Cartesian coordinate system. X right at Y the top. There is a line which passes through the center of coordinates. Needed to determine the angle relatively to the axis OX. So…
yozhik
  • 4,644
  • 14
  • 65
  • 98
1
vote
2 answers

get angle between two 3d points

I made a get_angle function inside my Vector3 class but I have a problem with it. The Y angle is perfectly fine. The pitch angle (X) it returns is slightly over my destination position when the base vector is over it (and when under the opposite is…
Not Szwagi
  • 81
  • 2
  • 10
1
vote
1 answer

how do i rotate a rectangle to point towards mouse

I need help rotating a rectangle to point towards the mouse on the screen every time the mouse moves. ive been trying to do so using the onmousemove event and calculating degrees/angle, then converting to radians, but for some reason when i place…
1
vote
2 answers

Angle of a vector pointing from A to B

I'm not the best in Maths, but for what I am doing now I need to calculate the angle of the vector which is shown as arrow in the picture below: I have a point A and a point B in a 2D plane. I need to calculate the following: The angle in which…
lamas
  • 4,528
  • 7
  • 38
  • 43
1
vote
1 answer

Applying diff on selected rows for comparing angles from math.atan2

I have a data frame like this that want to apply diff function on: test = pd.DataFrame({ 'Observation' : ['0','1','2', '3','4','5', '6','7','8'], 'Value' :…
ahoosh
  • 1,340
  • 3
  • 17
  • 31
1
vote
2 answers

Angle between two line start at the same point

Lets say I am any two points on 2d plane (p1(x1,y1), p2(x2,y1)) and both points forms a line with the center(c(c1,c2)). Therefore I am two lines end at same point. I want to know how can I calculate angle between those two lines. I want to be able…
Jack
  • 11
  • 1
  • 2
1
vote
2 answers

Is there a Math.atan2 substitute for j2ME? Blackberry development

I have a wide variety of locations stored in my persistent object that contain latitudes and longitudes in double(43.7389, 7.42577) format. I need to be able to grab the user's latitude and longitude and select all items within, say 1 mile. Walking…
Kai
  • 160
  • 1
  • 12