Operations on 2d vectors using AdditiveArithmetic
AdditiveArithmetic
was first presented in Swift 5.
The protocol provides a basis for additive arithmetics on scalar values. From mathematical point of view it provides generic solution for Additive group.
The code below improves the code from my previous article using Additive arithmetics.
P.S. It took me an effort to add CG prefixes 🙃. Yet it gives a better intuition on possible code usage which is close to graphics.