![]() |
Reference documentation for deal.II version 9.5.0
|
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) |
Functions to compute relations between spatial vectors.
| 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) \]
| 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}} \]
spacedim == 3.