Reference documentation for deal.II version 9.4.1
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Functions
Physics::VectorRelations Namespace Reference

Functions

template<int spacedim, typename Number >
Number angle (const Tensor< 1, spacedim, Number > &a, const Tensor< 1, spacedim, Number > &b)
 
template<int spacedim, typename Number >
Number signed_angle (const Tensor< 1, spacedim, Number > &a, const Tensor< 1, spacedim, Number > &b, const Tensor< 1, spacedim, Number > &axis)
 

Detailed Description

Functions to compute relations between spatial vectors.

Function Documentation

◆ angle()

template<int spacedim, typename Number >
Number Physics::VectorRelations::angle ( const Tensor< 1, spacedim, Number > &  a,
const Tensor< 1, spacedim, Number > &  b 
)

Calculate the angle \(\theta\) between two vectors a and b. The returned angle will be in the range \([0, \pi]\).

This function uses the geometric definition of the scalar product.

\[ \vec{a} \cdot \vec{b} = \|\vec{a}\| \|\vec{b}\| \cos(\theta) \]

◆ signed_angle()

template<int spacedim, typename Number >
Number Physics::VectorRelations::signed_angle ( const Tensor< 1, spacedim, Number > &  a,
const Tensor< 1, spacedim, Number > &  b,
const Tensor< 1, spacedim, Number > &  axis 
)

Calculate the angle \(\theta\) between two vectors a and b, where both vectors are located in a plane described by a normal vector axis.

The angle computed by this function corresponds to the rotation angle that would transform the vector a into the vector b around the vector axis. Thus, contrary to the function above, we get a signed angle which will be in the range \([-\pi, \pi]\).

The vector axis needs to be a unit vector and be perpendicular to both vectors a and b.

This function uses the geometric definitions of both the scalar and cross product.

\begin{align*} \vec{a} \cdot \vec{b} &= \|\vec{a}\| \|\vec{b}\| \cos(\theta) \\ \vec{a} \times \vec{b} &= \|\vec{a}\| \|\vec{b}\| \sin(\theta) \vec{n} \end{align*}

We can create the tangent of the angle using both products.

\[ \tan{\theta} = \frac{\sin(\theta)}{\cos(theta)} = \frac{(\vec{a} \times \vec{b}) \cdot \vec{n}}{\vec{a} \cdot \vec{b}} \]

Note
Only applicable for three-dimensional vectors spacedim == 3.