Loading...
Searching...
No Matches
tide.c File Reference

The rise and fall of a semidiurnal tide, from a plain running minute count. More...

#include "clock/tide.h"

Macros

#define TIDE_PERIOD_CUBE   ((int64_t)TIDE_PERIOD_MIN * TIDE_PERIOD_MIN * TIDE_PERIOD_MIN)
 The cycle's length cubed, which the smoothstep divides by.

Functions

static int32_t phase (int32_t minutes)
 Where in the cycle a minute count lands.
int tide_level (int32_t minutes)
 How far in the tide is, from 0 at dead low to 100 at high water.
bool tide_rising (int32_t minutes)
 Whether the tide is on its way in.

Detailed Description

The rise and fall of a semidiurnal tide, from a plain running minute count.

Function Documentation

◆ phase()

int32_t phase ( int32_t minutes)
static

Where in the cycle a minute count lands.

C truncates a negative division towards zero, which leaves a negative remainder, so this pulls it back up by hand.

Parameters
minutesA running minute count, on the same base as tide_level.
Returns
The phase within the cycle, 0 to TIDE_PERIOD_MIN - 1.