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

Normalising angle between negative y-axis and vector

From picture: I have to calculate alpha, defined as the angle between the lines that connects two points and the y-axis, with a range 0 to 180 in the direction that can be seen in the image, and with a range of 0 to -180 in the opposite (arrow…
Garu94
  • 103
  • 2
  • 9
0
votes
2 answers

Atan2 is giving the false angle when object's y or z change in Unity

I wrote a algorithm. Its normally working. Just i can not get right angle of x when y or z changes float x = Mathf.Atan2(transform.forward.y, transform.forward.z) * Mathf.Rad2Deg This code is giving the right angle when my object angles are…
0
votes
2 answers

Make players look direction relative to camera unity

I'm making a third person character controller in unity, I have the Player Moving with a direction and an animation. My question is: how do I make the movement rotation relative to the camera rotation NOTE: I am Not using transform.translate or any…
0
votes
2 answers

Reverse of Atan2 with det and dot product of two vectors as input

I have a piece of code that returns the angle between two vectors in the range of [0,360]. For this I used this question: Direct way of computing clockwise angle between 2 vectors. Now I need to create a function that takes a vector and an angle as…
0
votes
1 answer

Making a vector library in python, but my heading() function has a problem with the atan2 function

I'm making a vector library for python (I'm pretty new to python) and I'm making a function to find the heading of the vector. Here's the code for it. (I'm using radians for all of this, btw). def heading(self): return math.atan2(self.x,…
pythag0ras_
  • 122
  • 11
0
votes
0 answers

Issue with plotting a contourplot using atan2

I am trying to plot a multiplication of Gaussians in polar coordinates, but I have an issue with the atan2 function of Python. This is my code: import matplotlib.pyplot as plt import numpy as np xmin = -400 xmax = 400 ymin = -400 ymax =…
Margot
  • 1
  • 1
0
votes
1 answer

Find the points between two points on a circle in the smaller angle

So the idea is that I want to get 20 points in X,Y coordinates between two clicks on a cirlce. The only criteria is that the points always have to be between the smaller angle between the 2 clicks. Lets say the midpoint of the circle is c.x,c.y,…
Gabor
  • 5
  • 2
0
votes
1 answer

How to limit the return angle from atan2() to [-pi/4,pi/4]?

I am using atan2() to find the angle between x,y values. I understand atan2 method returns a numeric value between –pi and pi. How do I map that value to [-pi/4, pi/4]. The question is related to this Limiting atan2 to specific angle ranges but I…
user4024419
0
votes
0 answers

Conversion from cartesian to spherical coordinates and floating-point imprecision

I need to convert cartesian to spherical coordinates, but my implementation is suffering from floating-point imprecision. Here's what I'm doing until now: template Point3 cartesian_to_spherical(Point3 const&…
0xbadf00d
  • 17,405
  • 15
  • 67
  • 107
0
votes
4 answers

how to calculate the angle in degrees using Atan2()

i need your help with this code i have here: Console.WriteLine(); Console.WriteLine("Enter first X value: "); float point1X = float.Parse(Console.ReadLine()); Console.WriteLine("Enter first Y value: "); float point1Y =…
0
votes
0 answers

How do I move a picturebox from a point to my cursor gradually in C#?

I'm currently working on making a game in C# for a school project. What I want to be able to do in the program is to be able to shoot a picturebox out of my character sprite and to get that picturebox to travel toward the cursor gradually. I've…
jallebuS
  • 1
  • 1
0
votes
1 answer

Result of atan2 is not smooth

I am using atan2 (in MATLAB) to calculate angles, and then I take the gradient of the angle. I can see that the angle is not smooth at places like pi and pi/2, but that is not visible in the plot. Then, plotting the gradient of the angle shows big…
Tom Ligon
  • 31
  • 3
0
votes
1 answer

Odeint function from scipy.integrate gives wrong result

I use odeint function to solve a coupled differential equations system and plot one of the variables (theta_i) after the system is solved. My variable (theta_i) comes from the equation: theta_i = np.arctan2(g1,g2) where g1 ang g2 are variables…
Meanmachine
  • 97
  • 12
0
votes
1 answer

output of function doesn't store correctly

I have a function solving a differential equation system. I want to plot one of the result variables (theta_i) after the system is solved. This variable comes from the equation: np.arctan2(g1,g2) so its values suppose to be between -pi and pi. If I…
Meanmachine
  • 97
  • 12