mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_Math: added rotation_equal()
This commit is contained in:
parent
2ad2bb43f8
commit
e90e89b687
@ -255,3 +255,21 @@ bool is_valid_octal(uint16_t octal)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
return true if two rotations are equivalent
|
||||||
|
This copes with the fact that we have some duplicates, like ROLL_180_YAW_90 and PITCH_180_YAW_270
|
||||||
|
*/
|
||||||
|
bool rotation_equal(enum Rotation r1, enum Rotation r2)
|
||||||
|
{
|
||||||
|
if (r1 == r2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Vector3f v(1,2,3);
|
||||||
|
Vector3f v1 = v;
|
||||||
|
Vector3f v2 = v;
|
||||||
|
v1.rotate(r1);
|
||||||
|
v2.rotate(r2);
|
||||||
|
return (v1 - v2).length() < 0.001;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -258,3 +258,5 @@ Vector3f rand_vec3f(void);
|
|||||||
// confirm a value is a valid octal value
|
// confirm a value is a valid octal value
|
||||||
bool is_valid_octal(uint16_t octal);
|
bool is_valid_octal(uint16_t octal);
|
||||||
|
|
||||||
|
// return true if two rotations are equal
|
||||||
|
bool rotation_equal(enum Rotation r1, enum Rotation r2);
|
||||||
|
Loading…
Reference in New Issue
Block a user