/
plot_geodesics_so3.py
40 lines (30 loc) · 1.04 KB
/
plot_geodesics_so3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Plot a geodesic of SO(3) equipped
with its left-invariant canonical METRIC.
"""
import logging
import os
import matplotlib.pyplot as plt
import numpy as np
import geomstats.visualization as visualization
from geomstats.geometry.special_orthogonal import SpecialOrthogonal
SO3_GROUP = SpecialOrthogonal(n=3)
METRIC = SO3_GROUP.bi_invariant_metric
def main():
initial_point = SO3_GROUP.identity
initial_tangent_vec = [0.5, 0.5, 0.8]
geodesic = METRIC.geodesic(initial_point=initial_point,
initial_tangent_vec=initial_tangent_vec)
n_steps = 10
t = np.linspace(0, 1, n_steps)
points = geodesic(t)
visualization.plot(points, space='SO3_GROUP')
plt.show()
if __name__ == '__main__':
if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow':
logging.info('Examples with visualizations are only implemented '
'with numpy backend.\n'
'To change backend, write: '
'export GEOMSTATS_BACKEND = \'numpy\'.')
else:
main()