atan2

How to map atan2() to degrees 0-360

atan2(y,x) has that discontinuity at 180° where it switches to -180°..0° going clockwise. How do I map the range of values to 0°..360°? here is my code: CGSize deltaPoint = CGSizeMake(endPoint.x - startPoint.x, endPoint.y - startPoint.y); float swipeBearing = atan2f(deltaPoint.height, deltaPoint.width); I'm calculating the direction...

Draw a polygon in C

Hi, 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 between the 2 points (radius) with the theorem of Pythagoras: sqrt(pow(abs(x - xc), 2) +...

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 = <SomeclassInstanceGlobalHere>.getW1(); // This is a class which updates a variable double w2 = <SomeclassInstanceGlo...

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

Hi all, 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) Calculating the real and complex parts in separate, using double precision, as below:...

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 distance. I have done this in PHP so I snagged my PHP code and transferred it to Java, whe...

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 to show angle range from 0-2pi. Also 0-(-2pi) which let the line form by p1 and c to be lin...

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 the arrow must be rotated in order to point to B ...