Why do trigonometric functions give a seemingly incorrect result? [duplicate]

Why is this happening? Trigonometric functions generally expect units in radians, while 90 is in degrees. This also applies for other functions such as cosine and tangent, not just the sine function. Most programming languages require trigonometric functions to provide their arguments in radians. This simplifies many things, especially on the implementation side as code … Read more

Is the Haversine Formula or the Vincenty’s Formula better for calculating distance?

Haversine and Vincenty are two algorithms for solving different problems. Haversine computes the great circle distance on a sphere while Vincenty computes the shortest (geodesic) distance on the surface of an ellipsoid of revolution. So the answer to your question can be broken into 2 parts: Do you want to compute the distance on a … Read more

Calculating the angle between two lines without having to calculate the slope? (Java)

The atan2 function eases the pain of dealing with atan. It is declared as double atan2(double y, double x) and converts rectangular coordinates (x,y) to the angle theta from the polar coordinates (r,theta) So I’d rewrite your code as public static double angleBetween2Lines(Line2D line1, Line2D line2) { double angle1 = Math.atan2(line1.getY1() – line1.getY2(), line1.getX1() – … Read more

swift trigonometric functions (cos, tan, arcsin, arcos, arctan)

This is more a math problem than a Swift problem: let sinus = sin(90.0 * Double.pi / 180) print(“Sinus \(sinus)”) let cosinus = cos(90 * Double.pi / 180) print(“Cosinus \(cosinus)”) let tangent = tan(90 * Double.pi / 180) print(“Tangent \(tangent)”) prints Sinus 1.0 Cosinus 6.12323399573677e-17 Tangent 1.63312393531954e+16 Sinus of 90 degrees is 1 (correct) Cosinus … Read more

sine result depends on C++ compiler used

You have a 19-digit literal, but double usually has 15-17 digit precision. As a result, you can get a small relative error (when converting to double), but big enough (in the context of sine calculation) absolute error. Actually, different implementations of the standard library have differences in treating such large numbers. For example, in my … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)