Skip to content

Instantly share code, notes, and snippets.

View maqadeersaeed's full-sized avatar

Muhammad Qadeer Saeed maqadeersaeed

View GitHub Profile
@maqadeersaeed
maqadeersaeed / CalcAngleofLineBetweenTwoPoints
Created June 20, 2023 21:14 — forked from darzo27/CalcAngleofLineBetweenTwoPoints
Calculate Angle of Line between two points - Java, C#, Python
==== J A V A ==================================
/**
* Determines the angle of a straight line drawn between point one and two. The number returned, which is a double in degrees, tells us how much we have to rotate a horizontal line clockwise for it to match the line between the two points.
* If you prefer to deal with angles using radians instead of degrees, just change the last line to: "return Math.atan2(yDiff, xDiff);"
*/
public static double GetAngleOfLineBetweenTwoPoints(Point.Double p1, Point.Double p2)
{
double xDiff = p2.x - p1.x;
double yDiff = p2.y - p1.y;
return Math.toDegrees(Math.atan2(yDiff, xDiff));
// Requires:
// Leaflet: http://leafletjs.com/
// Leaflet.curve: https://github.com/elfalem/Leaflet.curve
//
// Assumes:
// var map is a Leaflet map and already set up.
var latlngs = [];
var latlng1 = [LATITUDE, LONGTITUDE],