Skip to content

Instantly share code, notes, and snippets.

@pauldotknopf
Created March 26, 2023 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pauldotknopf/67f444dabdbc60bb55132397d695dfe5 to your computer and use it in GitHub Desktop.
Save pauldotknopf/67f444dabdbc60bb55132397d695dfe5 to your computer and use it in GitHub Desktop.
C# .NET method function to plot the tide changes.
public static double PlotFromHighToLow(double highTide, double lowTide, double distance, double at)
{
var halfAmplitude = Math.Abs(highTide - lowTide) / 2;
var center = halfAmplitude + lowTide;
var y = halfAmplitude * Math.Sin(((Math.PI / (distance)) * (at + (distance / 2)))) + center;
return y;
}
public static double PlotFromLowToHide(double lowTide, double highTide, double distance, double at)
{
return PlotFromHighToLow(highTide, lowTide, distance, at + distance);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment