I'm measuring distance of 2 points on Google Map and then in my program converting them into ECEF using this formula. Then using Pythagorean theorem to calculate distance between those 2 points. Difference is about 100-200m, which is fairly big for what I am doing. In my program I use double for precision.
Big question will be what method Google is using in order to calculate distance between 2 points?
Update, example:
Lon/Lat : 44.50310895983847,40.16009701404741 and 44.50151117520584,40.15672510042466. Google Earth says it's 400m.
After converting to ECEF I get 3482269.0815067333, 2938590.6893090927 and 3482536.9833229352, 2938466.2491839984. I measure distance of 276.99011m
The Spherical Law of Cosines says $$ \begin{align} \cos\left(\frac{90^\circ}{10000\text{ km}}\text{dist}\right) &=\sin(\text{lat}_1)\sin(\text{lat}_2)+\cos(\text{lat}_1)\cos(\text{lat}_2)\cos(\Delta\text{lon})\\ &=\cos(\Delta\text{lat})-\cos(\text{lat}_1)\cos(\text{lat}_2)(1-\cos(\Delta\text{lon}))\tag{1} \end{align} $$ Using the approximation $\cos(x)=1-\frac12x^2$ when $x$ is small yields $$ \left(\frac{90^\circ}{10000\text{ km}}\text{dist}\right)^2 \stackrel.=\Delta\text{lat}^2+\cos^2(\text{lat})\Delta\text{lon}^2\tag{2} $$ for small values of $\Delta\text{lat}$ and $\Delta\text{lon}$.
We have $$ \begin{align} \Delta\text{lat}&=0.0033719136227^\circ\\ \Delta\text{lon}&=0.0015977846327^\circ\\ \cos(\text{lat})\Delta\text{lon}&=0.0012211298208^\circ \end{align} $$ With these values, I get $\text{dist}\stackrel.=398\text{ m}$.