NumCpp
2.17.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
rodriguesRotation.hpp
Go to the documentation of this file.
1
29
#pragma once
30
31
#include <cmath>
32
33
#include "
NumCpp/NdArray.hpp
"
34
#include "
NumCpp/Vector/Vec3.hpp
"
35
36
namespace
nc::rotations
37
{
38
//============================================================================
39
// Method Description:
49
inline
Vec3
rodriguesRotation
(
const
Vec3
& k,
double
theta,
const
Vec3
& v)
noexcept
50
{
51
const
auto
kUnit = k.normalize();
52
53
const
auto
vCosTheta = v * std::cos(theta);
54
55
auto
kCrossV = kUnit.cross(v);
56
kCrossV *= std::sin(theta);
57
58
const
auto
kDotV = kUnit.dot(v);
59
auto
kkDotV = kUnit * kDotV;
60
kkDotV *= 1 - std::cos(theta);
61
62
auto
vec = vCosTheta + kCrossV;
63
vec += kkDotV;
64
65
return
vec;
66
}
67
68
//============================================================================
69
// Method Description:
79
template
<
typename
dtype>
80
NdArray<double>
rodriguesRotation
(
const
NdArray<dtype>
& k,
double
theta,
const
NdArray<dtype>
& v)
81
{
82
return
rodriguesRotation
(
Vec3
(k), theta,
Vec3
(v)).
toNdArray
();
83
}
84
}
// namespace nc::rotations
NdArray.hpp
Vec3.hpp
nc::NdArray
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition
NdArrayCore.hpp:139
nc::Vec3
Holds a 3D vector.
Definition
Vec3.hpp:51
nc::Vec3::toNdArray
NdArray< double > toNdArray() const
Definition
Vec3.hpp:337
nc::rotations
Definition
DCM.hpp:39
nc::rotations::rodriguesRotation
Vec3 rodriguesRotation(const Vec3 &k, double theta, const Vec3 &v) noexcept
Definition
rodriguesRotation.hpp:49
include
NumCpp
Rotations
rodriguesRotation.hpp
Generated by
1.15.0