public static double GetPositiveWindWorkPercentage(GoogleMapsAPI googleMapsAPI, double forecastWindVectorDirection) { int positiveWorkLength = 0; int negativeWorkLength = 0; foreach (Step step in googleMapsAPI.GetSteps()) { double windStepAngleDifference = TrigonometryUtility.GetDegreeBetweenVectors(googleMapsAPI.GetStepDirection(step), forecastWindVectorDirection); if (Math.Cos(TrigonometryUtility.ToRadians(windStepAngleDifference)) > 0) { positiveWorkLength += step.distance; } else { negativeWorkLength += step.distance; } } return((double)positiveWorkLength / (positiveWorkLength + negativeWorkLength)); }
public static double DotProductWithUnitVector(double magnitude, double vectorAngle) { return(magnitude * Math.Cos(TrigonometryUtility.ToRadians(vectorAngle))); }