40 #include <px4_platform_common/defines.h> 42 #include <mathlib/mathlib.h> 54 if (thr_sp.
length() > 0.00001f) {
65 if (fabsf(body_z(2)) > 0.000001
f) {
67 body_x = y_C % body_z;
70 if (body_z(2) < 0.0
f) {
84 body_y = body_z % body_x;
89 for (
int i = 0; i < 3; i++) {
90 R_sp(i, 0) = body_x(i);
91 R_sp(i, 1) = body_y(i);
92 R_sp(i, 2) = body_z(i);
109 if (
Vector2f(v0 + v1).norm() <= max) {
117 }
else if (fabsf(
Vector2f(v1 - v0).norm()) < 0.001
f) {
121 }
else if (v0.
length() < 0.001f) {
165 float m = u1.
dot(v0);
166 float c = v0.
dot(v0) - max *
max;
167 float s = -m + sqrtf(m * m - c);
178 if (ab_norm.
length() < 0.01f) {
183 Vector3f d = line_a + ab_norm * ((sphere_c - line_a) * ab_norm);
184 float cd_len = (sphere_c - d).length();
186 if (sphere_r > cd_len) {
188 float dx_len = sqrtf(sphere_r * sphere_r - cd_len * cd_len);
190 if ((sphere_c - line_b) * ab_norm > 0.0
f) {
196 res = d + ab_norm * dx_len;
207 if ((sphere_c - line_a) * ab_norm < 0.0
f) {
212 if ((sphere_c - line_b) * ab_norm > 0.0
f) {
bool cross_sphere_line(const Vector3f &sphere_c, const float sphere_r, const Vector3f &line_a, const Vector3f &line_b, Vector3f &res)
This method was used for smoothing the corners along two lines.
void copyTo(Type dst[M *N]) const
Vector normalized() const
Type dot(const MatrixM1 &b) const
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
Vector2< float > Vector2f
void thrustToAttitude(const Vector3f &thr_sp, const float yaw_sp, vehicle_attitude_setpoint_s &att_sp)
Converts thrust vector and yaw set-point to a desired attitude.
Vector3< float > Vector3f
Vector3 normalized() const
Vector2f constrainXY(const Vector2f &v0, const Vector2f &v1, const float &max)
Outputs the sum of two vectors but respecting the limits and priority.
Dual< Scalar, N > max(const Dual< Scalar, N > &a, const Dual< Scalar, N > &b)
Simple functions for vector manipulation that do not fit into matrix lib.