$\DeclareMathOperator{\arccosh}{arccosh} \DeclareMathOperator*{\argmin}{arg\,min} \DeclareMathOperator{\Exp}{Exp} \newcommand{\geo}[2]{\gamma_{\overset{\frown}{#1,#2}}} \newcommand{\geoS}{\gamma} \newcommand{\geoD}[2]{\gamma_} \newcommand{\geoL}[2]{\gamma(#2; #1)} \newcommand{\gradM}{\nabla_{\M}} \newcommand{\gradMComp}[1]{\nabla_{\M,#1}} \newcommand{\Grid}{\mathcal G} \DeclareMathOperator{\Log}{Log} \newcommand{\M}{\mathcal M} \newcommand{\N}{\mathcal N} \newcommand{\mat}[1]{\mathbf{#1}} \DeclareMathOperator{\prox}{prox} \newcommand{\PT}[3]{\mathrm{PT}_{#1\to#2}#3} \newcommand{\R}{\mathbb R} \newcommand{\SPD}[1]{\mathcal{P}(#1)} \DeclareMathOperator{\Tr}{Tr} \newcommand{\tT}{\mathrm{T}} \newcommand{\vect}[1]{\mathbf{#1}}$

# The distance on the sphere

The distance on the sphere $\mathbb S^n$ is defined for any $x,y\in\mathbb S^n$, $x$ as the length of a shorter segment connecting them of a great circle in a plane containing $x,y$, and the origin. This circle is unique (and so is the shorter segment) if the two points are not antipodal. If they are antipodal, i.e. $x=-y$ there are infinitely many great circles, for any of which both segments we have the length $\pi$. Hence the length and therefore the distance is always uniquely determined. The formula reads

### Matlab Documentation

1
2
3
4
5
6
7
8
9
10
11
% d = dist(p,q) distance between x,y on the manifold Sn.
%
% INPUT
%   x,y : a (column) vector from S2 (embd. in R3) or a set of
%   column vectors
%
% OUTPUT
%     d : resulting distances of each column pair of p,q.
% ---
% Manifold-Valued Image Restoration Toolbox 1.0
% R. Bergmann ~ 2014-10-19 | 2015-03-30