Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI biquadFilter
geometry.cpp@2:fc869e45e672, 2016-11-02 (annotated)
- Committer:
- ronvbree
- Date:
- Wed Nov 02 08:51:12 2016 +0000
- Revision:
- 2:fc869e45e672
- Parent:
- 0:494acf21d3bc
- Child:
- 7:a80cb6b06320
abcdg
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ronvbree | 2:fc869e45e672 | 1 | #include "math.h" |
| ronvbree | 2:fc869e45e672 | 2 | #include "geometry.h" |
| ronvbree | 0:494acf21d3bc | 3 | |
| ronvbree | 0:494acf21d3bc | 4 | /* |
| ronvbree | 0:494acf21d3bc | 5 | Methods |
| ronvbree | 0:494acf21d3bc | 6 | */ |
| ronvbree | 0:494acf21d3bc | 7 | |
| ronvbree | 0:494acf21d3bc | 8 | // Sets the required arm lengths in the 'upper' and 'lower' parameters |
| ronvbree | 0:494acf21d3bc | 9 | void getArmLengthsForRollerPosition(float x, float y, float &upper, float &lower) { |
| ronvbree | 0:494acf21d3bc | 10 | lower = sqrt(pow(y-h,2)+pow(x,2)); |
| ronvbree | 0:494acf21d3bc | 11 | upper = sqrt(pow(lower,2)+pow(d,2)-2*d*sqrt(pow(lower,2)-pow(x,2))); |
| ronvbree | 0:494acf21d3bc | 12 | } |
| ronvbree | 0:494acf21d3bc | 13 | |
| ronvbree | 0:494acf21d3bc | 14 | // Sets the roller position corresponding to the current arm lengths in the x and y parameters |
| ronvbree | 0:494acf21d3bc | 15 | void getRollerPositionForArmLengths(float upper, float lower, float &x, float &y) { |
| ronvbree | 0:494acf21d3bc | 16 | y=(pow(lower,2)-pow(upper,2)+2*h*d+pow(d,2))/(2*d); |
| ronvbree | 0:494acf21d3bc | 17 | x=sqrt(pow(upper,2)-pow(y-h,2)); //TODO |
| ronvbree | 0:494acf21d3bc | 18 | } |
| ronvbree | 0:494acf21d3bc | 19 | |
| ronvbree | 0:494acf21d3bc | 20 | /* |
| ronvbree | 0:494acf21d3bc | 21 | Getters |
| ronvbree | 0:494acf21d3bc | 22 | */ |
| ronvbree | 0:494acf21d3bc | 23 | |
| ronvbree | 0:494acf21d3bc | 24 | float getMaximalArmLength(){ |
| ronvbree | 0:494acf21d3bc | 25 | return L_max; |
| ronvbree | 0:494acf21d3bc | 26 | } |
| ronvbree | 0:494acf21d3bc | 27 | |
| ronvbree | 0:494acf21d3bc | 28 | float getMinimalArmLength(){ |
| ronvbree | 0:494acf21d3bc | 29 | return L_min; |
| ronvbree | 0:494acf21d3bc | 30 | } |
| ronvbree | 0:494acf21d3bc | 31 | |
| ronvbree | 0:494acf21d3bc | 32 | float getReach(){ |
| ronvbree | 0:494acf21d3bc | 33 | return reach; |
| ronvbree | 0:494acf21d3bc | 34 | } |
| ronvbree | 0:494acf21d3bc | 35 | |
| ronvbree | 0:494acf21d3bc | 36 | float getMaximalRollerHeight(){ |
| ronvbree | 0:494acf21d3bc | 37 | return y_max; |
| ronvbree | 0:494acf21d3bc | 38 | } |
| ronvbree | 0:494acf21d3bc | 39 | |
| ronvbree | 0:494acf21d3bc | 40 | float getMinimalRollerHeight(){ |
| ronvbree | 0:494acf21d3bc | 41 | return y_min; |
| ronvbree | 0:494acf21d3bc | 42 | } |
| ronvbree | 0:494acf21d3bc | 43 |