I am trying to determine angular velocity in degrees per second of an object.

I have only the heading of that object in degrees updated every 1/60th of a second (with 0 being North and 90 being East)

The specific issue I have is one of handling the wrap around when the object goes from say 355 degrees to 5 degrees passing over 0/360.

I'm currently thinking that perhaps I can average readings over time, excluding the outliers however that will add unnecessary lag to the system and reduce accuracy over that region.

Simple example code where degreesIn is the source and degreesPerSecondOut is the result

```
degreesPerSecondOut = (degreesIn or 0 - degreesInOld) * 60
degreesInOld = degreesIn

```

Expected results include a smooth and accurate transition whilst passing over 0 degrees

---

Additional Thought: The object I am calculating the angular velocity of should never exceed 1 revolution per second (or even per 1/60th of a second). Im not sure why but I feel this is useful.