```
var angle = CoordinatesDistanceExtensions.CalculateAngle(posicionGisReversed[i].X, posicionGisReversed[i].Y, posicionGisReversed[i + 1].X, posicionGisReversed[i + 1].Y);
var rectangle = CoordinatesDistanceExtensions.CalculateRect(mapPointLeftCopy.X, mapPointLeftCopy.Y, mapPoint.X, mapPoint.Y, angle);
public static double CalculateAngle(double baseX, double baseY, double targetX, double targetY)
{
var hipotenus = CoordinatesDistanceExtensions.DistanceTo(baseX, baseY, targetX, targetY, UnitOfLength.Kilometers);
var catetA = CoordinatesDistanceExtensions.DistanceTo(targetX, baseY, targetX, targetY, UnitOfLength.Kilometers);
var catetAPow = Math.Pow(catetA, 2);
var hipotenusPow = Math.Pow(hipotenus, 2);
var catetB = Math.Sqrt(hipotenusPow - catetAPow);
var sin2 = Math.Sin((catetB / hipotenus));
return sin2;
}
public static double DistanceTo(double baseX, double baseY, double targetX, double targetY, UnitOfLength unitOfLength)
{
var baseRad = Math.PI * baseX / 180;
var targetRad = Math.PI * targetX / 180;
var theta = baseY - targetY;
var thetaRad = Math.PI * theta / 180;
double dist =
Math.Sin((double)baseRad) * Math.Sin((double)targetRad) + Math.Cos((double)baseRad) *
Math.Cos((double)targetRad) * Math.Cos((double)thetaRad);
dist = Math.Acos(dist);
dist = dist * 180 / Math.PI;
dist = dist * 60 * 1.1515;
return unitOfLength.ConvertFromMiles(dist);
}
public static RectanglePoint CalculateRect(double baseX, double baseY, double targetX, double targetY,double angle)
{
var hipotenus = CoordinatesDistanceExtensions.DistanceTo(baseX, baseY, targetX, targetY, UnitOfLength.Kilometers);
var catetA = CoordinatesDistanceExtensions.DistanceTo(targetX, baseY, targetX, targetY, UnitOfLength.Kilometers);
var catetAPow = Math.Pow(catetA, 2);
var hipotenusPow = Math.Pow(hipotenus, 2);
var catetB = Math.Sqrt(hipotenusPow - catetAPow);
var asin1 = Math.Asin(angle);
var degree =RadianToDegree(asin1)+25;
var radian =DegreeToRadian(degree);
var arcsin = Math.Sin(radian);
var hipotenus90 = hipotenus-((hipotenus * 90) / 100);
var CatetOposat90 = arcsin * hipotenus90;
var catet90Pow=Math.Pow(CatetOposat90, 2);
var hipote90Pow=Math.Pow(hipotenus90, 2);
var catetAdjacent90 = Math.Sqrt((hipotenus90 - catet90Pow));
RectanglePoint rectangle = new RectanglePoint()
{
cad = catetAdjacent90,
cop = CatetOposat90,
hip=hipotenus90
};
return rectangle;
}
This is what its left to develop!!!
I dont know a lot about trigonometry so I'm not sure what to do with the angle
public static MapPoint CalculateMapPoint(double distance, double baseX, double baseY,double angle)
{
var baseRad = Math.PI * baseX / 180;
//targetx unknown
//targety unknown
var targetRad = Math.PI * targetX / 180;
var theta = baseY - targetY;
var thetaRad = Math.PI * theta / 180;
distance =
Math.Sin((double)baseRad) * Math.Sin((double)targetRad) + Math.Cos((double)baseRad) *
Math.Cos((double)targetRad) * Math.Cos((double)thetaRad);
distance = Math.Acos(distance);
distance = distance * 180 / Math.PI;
distance = distance * 60 * 1.1515;
new MapPoint(targetx, targety)
return null;
return null;
}
The value Rectangle.hipotenus would equal to the distance
```