4#include <deal.II/base/point.h>
11#include <deal.II/base/point.h>
13using namespace dealii;
23template <
int spacedim>
25 const Point<spacedim> a,
const Point<spacedim> b) {
35template <
int spacedim>
37 const Point<spacedim> a,
const Point<spacedim> b) {
38 double dot_product = 0.0;
39 for (
unsigned int i = 0; i < spacedim; ++i) {
40 dot_product += a[i] * b[i];
44 double norm_a = a.norm();
45 double norm_b = b.norm();
48 double cosine = std::min(1.0, std::max(-1.0, dot_product / (norm_a * norm_b)));
50 return std::acos(cosine);
61template <
int spacedim>
63 const Point<spacedim> a,
const Point<spacedim> b) {
64 Vector<double> gradient(spacedim);
65 for (
unsigned int i = 0; i < spacedim; ++i) {
66 gradient[i] = (a[i] - b[i]);
78template <
int spacedim>
80 const Point<spacedim> a,
const Point<spacedim> b) {
81 Vector<double> gradient(spacedim);
84 double dot_product = 0.0;
85 for (
unsigned int i = 0; i < spacedim; ++i) {
86 dot_product += a[i] * b[i];
89 for (
unsigned int i = 0; i < spacedim; ++i) {
90 gradient[i] = -2 * (dist/std::sin(dist)) * (b[i]-dot_product*a[i]);
102template <
int spacedim>
104 const Point<spacedim> a,
const Vector<double> v) {
106 for (
unsigned int i = 0; i < spacedim; ++i) {
119template <
int spacedim>
121 const Point<spacedim> a,
const Vector<double> v) {
123 for (
unsigned int i = 0; i < spacedim; ++i) {
124 b[i] = std::cos(v.l2_norm())*a[i] + std::sin(v.l2_norm()) * (v[i]/v.l2_norm());
Point< spacedim > spherical_distance_exp_map(const Point< spacedim > a, const Vector< double > v)
Computes the exponential map for the spherical distance.
Vector< double > euclidean_distance_gradient(const Point< spacedim > a, const Point< spacedim > b)
Computes the gradient of the squared Euclidean distance.
double euclidean_distance(const Point< spacedim > a, const Point< spacedim > b)
Computes the Euclidean distance between two points.
double spherical_distance(const Point< spacedim > a, const Point< spacedim > b)
Computes the spherical distance between two points.
Point< spacedim > euclidean_distance_exp_map(const Point< spacedim > a, const Vector< double > v)
Computes the exponential map for the Euclidean distance.
Vector< double > spherical_distance_gradient(const Point< spacedim > a, const Point< spacedim > b)
Computes the gradient of the squared spherical distance.