Commit Graph

646 Commits

Author SHA1 Message Date
Randy Mackay c18fce6714 AP_Math: add quaternion rotation test 2020-04-09 19:41:08 +09:00
Randy Mackay 61a06bbb04 AP_Math: add quaternion rotate, from_rotation and invert 2020-04-09 19:41:08 +09:00
Randy Mackay 338548c5eb AP_Math: move HALF_SQRT_2 def to rotation.h
This allows it to be used by the Quaternion class
2020-04-09 19:41:08 +09:00
Samuel Tabor 45cb663d73 AP_Math: Add template for Vector2f::projected. 2020-04-08 09:11:54 +10:00
Randy Mackay 9c8a5a7392 AP_Math: add comments above some quaternion methods
thanks to jchallinger
2020-04-03 10:16:07 +09:00
Randy Mackay 7a48a3f354 AP_Math: minor comment fix 2020-03-30 20:20:02 +09:00
Patrick José Pereira 1635054c4f AP_Math: Add missing constexpr
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2020-03-17 10:23:47 +11:00
Andrew Tridgell f908e56154 AP_Math: define ROTATION_MAX_AUTO_ROTATION
we don't want to use ROTATION_PITCH_7 in our auto rotation mix, as it
is too close to level
2020-01-01 16:59:27 +11:00
Randy Mackay f87ae7d445 AP_Math: add vector2f::offset_bearing 2020-01-01 13:38:41 +09:00
Andrew Tridgell ff2cfbaafb AP_Math: added smaller footprint crc32 2019-10-28 15:53:16 +11:00
Siddharth Purohit fb48d8ee1b AP_Math: add method for generating hash 2019-10-19 09:55:38 +11:00
Andrew Tridgell 66b4e92444 AP_Math: make fill_nanf() use a signalling NaN
we want use of these values to trigger a FPE
2019-10-01 17:35:26 +10:00
Peter Barker 6fe09b6120 AP_Math: move is_valid_octal into adsb
This doesn't ensure the value is octal digits - there's more magic in
it.
2019-10-01 09:18:15 +10:00
Peter Barker 189ef5f1e7 AP_Math: define != for Vector2<int> 2019-09-28 07:58:48 +09:00
Andrew Tridgell 13a2367278 AP_Math: change optimisation from -O3 to -O2 2019-09-28 08:57:26 +10:00
Peter Barker 975804fa35 AP_Math: remove unit_mod concept from wrap functions
devcall decided it would be clearer to have non-shared implementation
for the _cd variants
2019-09-25 13:19:44 +10:00
Andrew Tridgell 9b746b89db AP_Math: added fill_nanf()
used in SITL to invalidate memory
2019-09-24 12:51:54 +10:00
Peter Barker 5692f3d79e AP_Math: stop returning float for integer wrap_180/wrap_360 etc 2019-09-18 12:57:02 +10:00
Peter Barker 84d999142f AP_Math: add more tests for wrap functions 2019-09-18 12:57:02 +10:00
Randy Mackay c7ca9c04f8 AP_Math: add comment to vector2f::point_on_segment 2019-08-10 12:21:01 +09:00
Peter Barker 4c434c2df9 AP_Math: add WARN_IF_UNUSED to bool methods 2019-07-26 09:26:02 +09:00
Andrew Tridgell 2480a62e55 AP_Math: added speed/distance conversions 2019-07-13 11:05:57 +10:00
murata c5a471e778 AP_Math: Common modbus crc method 2019-07-12 15:33:21 +10:00
Randy Mackay 614b0f6dc8 AP_Math: Polygon_intersects handles unclosed polygons 2019-07-07 04:08:34 -07:00
Peter Barker da5d5c9203 AP_Math: add tests for Vector2 2019-06-13 19:36:49 +10:00
Randy Mackay c2bcc0d5f0 AP_Math: define Vector2f::perpendicular 2019-06-11 13:13:22 +09:00
Randy Mackay 071e340827 AP_Math: Polygon_closest_distance_line returns neg numbers
value is negative distance from intersection to p2
2019-06-11 13:13:22 +09:00
Andrew Tridgell 6eb816fd3b AP_Math: add Polygon_closest_distance_line
Also add optimisations
2019-06-11 13:13:22 +09:00
Andrew Tridgell a5fd7ac5ca AP_Math: add vector2f::closest_distance_between_line_and_point_squared
also add vector2f::closest_distance_between_line_and_point and vector2f::closest_distance_between_lines_squared
2019-06-11 13:13:22 +09:00
Andrew Tridgell 2457bf71d4 AP_Math: add simplified vector2f::closest_point
this simpler version assumes the line segment originates at the origin
2019-06-11 13:13:22 +09:00
Andrew Tridgell c8e49259a0 AP_Math: add vector2f::closest_distance_between_radian_and_point_squared 2019-06-11 13:13:22 +09:00
Andrew Tridgell dbf337e1b3 AP_Math: move closest_point to cpp 2019-06-11 13:13:22 +09:00
Andrew Tridgell bfc28dfde9 AP_Math: move normalize, reflect, project and perpendicular to cpp 2019-06-11 13:13:22 +09:00
Andrew Tridgell 01e541b7d1 AP_Math: minor formatting changes to length method 2019-06-11 13:13:22 +09:00
Andrew Tridgell 4c4de1f021 AP_Math: vector2f::length_squared always returns float 2019-06-11 13:13:22 +09:00
Andrew Tridgell 46617e6c72 AP_Math: remove unused include from Vector2 2019-06-11 13:13:22 +09:00
Andrew Tridgell 69781cda42 AP_Math: add Vector2::angle 2019-06-11 13:13:22 +09:00
Peter Hall ea4ecebfc4 AP_Math: add speed unit converstion defs 2019-06-03 10:48:19 +09:00
Peter Barker e4de5a17d1 AP_Math: add pitch-7 to rotation tests 2019-05-29 17:12:32 +10:00
Andrew Tridgell e2eda63d2c AP_Math: added new rotation for PITCH_7 2019-05-29 17:12:32 +10:00
Peter Barker 977fe09276 AP_Math: add a more complex polygon for Polygon_outside tests 2019-05-29 15:34:02 +10:00
Peter Barker d3971c18fa AP_Math: more tests for closed-vs-open polygons 2019-05-29 15:34:02 +10:00
Peter Barker d74e6db12e AP_Math: add more tests for Polygon_outside 2019-05-29 15:34:02 +10:00
Peter Barker 36fe9a18a0 AP_Math: make Polygon_outside cope with being passed unclosed polygons 2019-05-29 15:34:02 +10:00
Peter Barker 64aafb2af2 AP_Math: add Polygon_outside tests for long template instantiation 2019-05-28 09:08:07 +10:00
Peter Barker 51a0401383 AP_Math: correct Polygon_outside floating point instatiation
This routine was entemplatificated from the integer version, which was
designed to be perfect across representable ranges of points.  The
floating point version suffered from a rounding problem.
2019-05-28 09:08:07 +10:00
Peter Barker b35b65eed1 AP_Math: add GTEST suite for Polygon_outside 2019-05-28 09:08:07 +10:00
Peter Barker f09efe0908 AP_Math: correct URL for Polygon_outside algorithm 2019-05-24 13:17:43 +10:00
Francisco Ferreira 6e95a144ef AP_Math: add macro for m/s to knots convertion 2019-05-21 09:41:15 +10:00
murata c6bcb1d54c AP_Math: Collect CRC16 into CRC file
AP_Math: Collect CRC16 into CRC file
2019-05-21 09:19:19 +10:00
Andrew Tridgell 85ce10adfd AP_Math: fixed test build 2019-05-15 15:33:48 +10:00
murata 7f42be5d3e AP_Math: Commonize the CRC4 method 2019-04-24 08:44:11 -07:00
Mark Whitehorn b515431008 AP_Math: add expo and throttle_curve functions 2019-04-23 09:46:38 +10:00
Peter Barker b22d3a0103 AP_Math: avoid casting floats to int32's for temporary variables
Note the use of 64-bit integer arithmetic further down, however
2019-04-23 09:36:17 +10:00
Pierre Kancir ff4587a33a AP_Math: move location define to Location class 2019-04-23 09:20:43 +10:00
Pierre Kancir 1854681e09 AP_Math: use past_interval_finish_line and line_path_proportion from Location 2019-04-23 09:20:43 +10:00
Pierre Kancir 4f31c3dcd5 AP_Math: move line_path_proportion to Location 2019-04-23 09:20:43 +10:00
Pierre Kancir e06d7dbbf7 AP_Math: move location_passed_point to Location and rename 2019-04-23 09:20:43 +10:00
Peter Barker 11dcdc58e0 AP_Math: clean up includes a little 2019-04-16 10:00:29 +10:00
Pierre Kancir 121e5d0abf AP_Math: move location_3d_diff_NED to Location and rename 2019-04-09 20:59:48 +10:00
Peter Barker 381bb41a5e AP_Math: make constraining NaNs an internal error 2019-04-09 10:18:43 +10:00
Pierre Kancir e787922ab0 AP_Math: move check_latlng to Location 2019-04-08 12:56:01 -07:00
Pierre Kancir b10e75f4e1 AP_Math: move locations_are_same to Location and rename to same_latlon_as 2019-04-08 08:05:05 -07:00
Pierre Kancir 058cade92c AP_Math: use get_distance_NE instead of location_diff 2019-04-08 08:00:52 -07:00
Pierre Kancir 00fa07ef33 AP_Math: move location_diff to Location and rename 2019-04-08 08:00:52 -07:00
Peter Barker ce53ae63ae AP_Math: use /2 in place of *0.5f
MdB says:

dividing by 2 is actually optimal. It's type correct for all usage, and the compiler generates the multiplication if it's float, and sticks with divide for integers

Godbolt indicates on any optimization level (O1-O3, and Os) that the compiler will correctly optimize the / 2 into a float multiplication if using a float, but if using integer types in the template it will stick with the / 2 which is faster then doing the conversions to/from float.
2019-04-05 23:04:17 -07:00
Peter Barker 39ae285a7f AP_Math: add floating point constant designators 2019-04-05 23:04:17 -07:00
Pierre Kancir b31e5bf055 AP_Math: move location_update to Location and rename to offset_bearing 2019-04-06 09:10:28 +11:00
Pierre Kancir 88b29ff18c AP_Math: move get_bearing_cd to Location and rename to get_bearing_to 2019-04-06 09:10:28 +11:00
Pierre Kancir f6941beeb9 AP_Math: fix circulary inclusion error 2019-04-02 19:00:02 +11:00
Pierre Kancir d47e9c8514 AP_Math: add missing include on matrix3 2019-04-02 19:00:02 +11:00
Peter Barker e6a8e337c7 AP_Math: move sanitize to be a method on location 2019-04-02 10:19:38 +11:00
Peter Barker 431bd77d7e AP_Math: move print_latlon into sole caller 2019-04-02 10:19:38 +11:00
Peter Barker 499cc45ac0 AP_Math: move longitude_scale into Location class 2019-03-12 10:11:12 +11:00
Dr.-Ing. Amilcar do Carmo Lucas 65ccef04b9 AP_Math: replace location_offset() and get_distance() C function calls with Location object member (C++) function calls
This allows removing duplicated code in the AP_Math/location.cpp file
2019-02-28 11:44:09 +11:00
Andrew Tridgell ecbe67a0fe AP_Math: fixed inefficient sq() function 2019-02-23 21:04:00 +11:00
Randy Mackay 07f7d793df AP_Math: add quaternion::angular_difference 2019-02-22 13:00:07 +09:00
Peter Barker 81ddeef1bd AP_Math: remove keywords.txt 2019-02-17 00:29:38 -08:00
Pierre Kancir 695073db49 AP_Math: correct crc_xmodem definition 2019-02-06 23:20:07 +11:00
Pierre Kancir 9e927d1376 AP_Math: correct copyright, add pragma-once 2019-02-06 23:20:07 +11:00
Pierre Kancir 97ce39bf0c AP_Math: use direct assignment for rotate() 2019-02-06 21:41:30 +11:00
Pierre Kancir dd0283d537 AP_Math: reduce variable scope in crc_crc8 2019-02-06 21:41:30 +11:00
Peter Barker 2fa0b61f8b AP_Math: update example/test for Location_Class merge 2019-01-16 11:45:29 +11:00
Peter Barker 31fa9e582e AP_Math: adjust for Location_Class and Location unification 2019-01-16 11:45:29 +11:00
Peter Barker ce37c9f69b AP_Math: adjust for location flags being moved out of union 2019-01-16 11:45:29 +11:00
Pierre Kancir 85b83ed6af AP_Math: remove non-ascii caracter 2018-12-22 08:39:23 +09:00
Pierre Kancir f1270b4b22 AP_Math: const correctness 2018-12-22 08:39:06 +09:00
Michael du Breuil 48610ea0a0 AP_Math: Remove an unneeded safe_sqrtf, leverage is_zero 2018-11-07 10:43:28 +11:00
Peter Barker 154d771e6c AP_Math: correct compilation when running MATH_CHECK_INDEXES 2018-10-19 08:46:43 +11:00
Peter Barker dc14d7bce4 AP_Math: add another test for wrap_360_cd 2018-10-16 10:29:24 +11:00
Lucas De Marchi 5521fce676 AP_Math: add non-uniform Vector3f scaling 2018-10-15 14:41:09 -07:00
Andrew Tridgell d4eaf09baf AP_Math: added rotation_equal() 2018-10-01 14:26:56 +09:00
Michael du Breuil 9cd1be1d6f AP_Math: Speed up location calculations slightly 2018-09-19 14:40:48 +10:00
Peter Barker 43f3d611b2 AP_Math: pragma away the float-equal test for the maths tests
There are legitimate reasons for doing direct equivalence in these files
2018-08-28 09:54:47 +10:00
Peter Barker 8fee27937a AP_Math: eliminate SITL float-equals issues 2018-08-28 09:54:47 +10:00
Peter Barker fa5757f618 AP_Math: fix float-equals warnings 2018-08-15 12:16:49 +10:00
Andrew Tridgell c3cf8f5435 AP_Math: fixed a bug in segment_intersection()
we could get an intercept point beyond the end of the segment
2018-08-14 19:41:45 +10:00
Peter Barker 626467db14 AP_Math: add tests for line intersection 2018-08-14 19:41:45 +10:00
Michael du Breuil d568767164 AP_Math: Add conversion between inches of water to pascals 2018-08-08 09:07:17 +10:00
Michael du Breuil 46355e3de9 AP_Math: Add a warning to rotations to indicate that it is expected to
match the MAVLink definitions
2018-07-26 12:58:14 +09:00
Andrew Tridgell 8170fbcf80 AP_Math: added a comment on conventions for to_euler() 2018-07-18 16:07:19 +10:00
Peter Barker 20d22f3629 AP_Math: quaternion requires isnan, so include math.h to get it 2018-07-02 09:31:11 +10:00
Peter Barker 6af0dcfed0 AP_Math: create a constrain_int64
The template system doesn't work across 32/64 bit builds (SITL
vs fmuv4), probably because int is typedef'd to int64
2018-06-15 08:01:22 +10:00
Tom Pittenger 3653ba61d7 AP_Math: add is_valid_octal helper function.
returns true if valid
2018-05-23 14:02:45 -07:00
Patrick José Pereira 1ca6647b2e AP_Math: Create Standard Sea Level variables
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2018-05-23 02:36:43 +01:00
Andrew Tridgell d4d7d1f734 AP_Math: avoid double maths when not needed 2018-05-07 11:43:23 +10:00
Andrew Tridgell 61c8dfac31 AP_Math: split out double precision location functions
this allows ALLOW_DOUBLE_MATH_FUNCTIONS to be used
2018-05-07 11:43:23 +10:00
Andrew Tridgell 3b8ec3a2a0 AP_Math: allow double precision maths where needed 2018-05-07 11:43:23 +10:00
Jacob Walser f97ac4af30 AP_Math: add custom rotation option 2018-04-24 13:04:37 +01:00
Jacob Walser 4f02f709a2 AP_Math: fix typo 2018-04-24 13:04:37 +01:00
Jacob Walser e738f33770 AP_Math: Add ROTATION_PITCH_315 and ROTATION_ROLL_90_PITCH_315 2018-04-24 13:04:37 +01:00
Andrew Tridgell a6e05cbf5a AP_Math: added crc32 for IOMCU bootloader protocol 2018-04-17 08:44:44 +10:00
Andrew Tridgell 17f2f40b11 AP_Math: added xmodem CRC
used by blheli 4-way ESC protocol
2018-04-07 09:10:29 +10:00
Peter Barker febcdd766b AP_Math: narrow enumeration to uint8_t to avoid narrowing-warnings
/home/pbarker/rc/ardupilot/libraries/DataFlash/LogFile.cpp:361:25:
error: non-constant-expression cannot be narrowed from type 'enum
Rotation' to 'uint8_t' (aka 'unsigned char') in initializer list
[-Wc++11-narrowing]
        orient1       : s0 ? s0->orientation() : ROTATION_NONE,
2018-04-02 14:12:09 +09:00
Peter Barker c343a286c5 AP_Math: quaternion: add contructor from float[4] 2018-03-27 20:13:03 +09:00
bnsgeyer 600e0dac92 AP_Math: added support for cubic spline interpolation 2018-03-27 09:07:03 +11:00
Randy Mackay c28cfcdc27 AP_Math: add Vector2f::circle_segment_intersection 2018-01-22 17:18:41 +09:00
Randy Mackay a655c36159 AP_Math: add Vector2f::segment_intersection 2018-01-22 17:18:41 +09:00
Andrew Tridgell ee1fea55ce AP_Math: moved constants from AP_Baro 2018-01-16 07:14:20 +11:00
Andrew Tridgell 4ce696a520 AP_Math: fixed example build on ChibiOS 2018-01-15 11:46:02 +11:00
Andrew Tridgell f5b24a3838 AP_Math: fixed build of Sub with ChibiOS 2018-01-15 11:46:02 +11:00
Andrew Tridgell 3d2c4ffa79 AP_Math: allow write to indexed vector2 2018-01-15 11:46:02 +11:00
Andrew Tridgell f088c3de23 AP_Math: added long templates 2018-01-15 11:46:02 +11:00
Dr.-Ing. Amilcar Do Carmo Lucas e13281ab2d AP_Math: add overloaded functions get_horizontal_distance_cm() and get_bearing_cd() (NFC) 2017-12-05 08:54:49 +09:00
Dr.-Ing. Amilcar Do Carmo Lucas ec1790dad9 AP_Math: Use DEGX100 define instead of hardcoded value (NFC) 2017-12-05 08:54:49 +09:00
Andrew Tridgell 9660973975 AP_Math: make crc_crc8 const 2017-11-27 10:15:07 +09:00
Andrew Tridgell 3f226cd2b9 AP_Math: added from_rotation() method to Matrix3
this is used to get a rotation matrix from a rotation enum
2017-11-23 14:26:11 +11:00
Peter Barker 1ca76173a5 AP_Math: set radians(...) and degrees(...) as constexpr 2017-10-27 16:33:45 +11:00
Randy Mackay 2aa1f3f100 AP_Math: replace divide with multiply in distance_to_segment 2017-09-09 14:05:41 +09:00
Randy Mackay e892bbbac0 AP_Math: add Vector3f::distance_to_segment 2017-09-09 14:05:41 +09:00
Randy Mackay e6328c350d AP_Math: add Vector3f::distance_squared 2017-09-09 14:05:41 +09:00
khancyr 15398f8b0e AP_Math: correct variable init and remove define in polygon 2017-07-31 17:35:08 +09:00
Miguel Arroyo 7cea21afa2 AP_Math: Moves rand_vec3f from SITL_State. 2017-06-29 09:22:08 +10:00
Francisco Ferreira da5060964b AP_Math: uniformize template type parameter keyword
Use typename everywhere instead of class
2017-06-21 18:19:31 +09:00
Francisco Ferreira 1ffe12008c AP_Math: adapt test for new norm method API 2017-06-21 18:19:31 +09:00
Francisco Ferreira 7b98f41947 AP_Math: correct norm to need two arguments
Correctly use sqrtf instead of the double version
Stop casting to float since sq already returns one
2017-06-21 18:19:31 +09:00
Randy Mackay db45442de2 AP_Math: remove unused angle method 2017-06-09 15:21:58 +09:00
Michael du Breuil 2cd6ff6dd5 AP_Math: Accept float epsilon in is_positive is_negative as a valid result 2017-05-27 10:46:59 -07:00
Michael du Breuil 5a15413513 AP_Math: Add is_negative and is_positive helpers 2017-05-24 15:22:27 -07:00
Andrew Tridgell 607220d12b AP_Math: rename macros to avoid conflicts
these macros were also defined in NuttX in clock.h
2017-05-06 15:21:14 +10:00
Andrew Tridgell 2fcecaa7c5 AP_Math: added rand_float() 2017-05-03 20:12:04 +10:00
Pierre Kancir f2812c1efd AP_Math: example fix travis warning
missing function declaration
implicit cast
some style fix
2017-04-13 19:56:16 +01:00
Tom Pittenger 1abeb03d2b AP_Math: remove HAL_CPU_CLASS_16 2017-04-12 17:25:30 -07:00
Andrey Kolobov a1fa2a9de3 AP_Math: added matrixN for soaring controller 2017-03-14 08:35:44 +11:00
Francisco Ferreira 7afcbf51ec
AP_Math: also fix SEC_PER_WEEK 2017-03-13 02:57:30 +00:00
murata 1982285e23 AP_Math: update MSEC_PER_SEC definition to fix GPS time calcs 2017-03-13 11:50:33 +09:00
Michael du Breuil c5c94949bf AP_Math: Extend vector2::angle(vector2) to distinguish parallel and antiparallel vectors
There are a number of use cases where distingusihing antiparallel from parallel vectors is important
2017-03-02 00:50:44 +00:00
Michael du Breuil 97c57764c4 AP_Math: Add a 3D location difference, returning NED 2017-02-13 09:23:14 +11:00
murata 30151c8253 Global: Define MSEC_PER_SEC, MSEC_PER_WEEK, SEC_PER_WEEK and UNIX_OFFSET. 2017-02-11 01:34:09 -08:00
Lucas De Marchi 2b9478f430 AP_Math: tests: make both arguments double
libraries/AP_Math/tests/test_math.cpp.3.o: In function `MathTest_IsEqual_Test::TestBody()':
test_math.cpp:(.text._ZN21MathTest_IsEqual_Test8TestBodyEv+0x1a0): undefined reference to `std::enable_if<std::is_floating_point<std::common_type<float, double>::type>::value, bool>::type is_equal<float, double>(float, double)'
collect2: error: ld returned 1 exit status
2017-02-06 09:27:22 -08:00