Unify use of Vector2d class. Tests for downsampling.