diff options
| author | leochanj105 <leochanj@live.unc.edu> | 2020-10-19 23:09:30 -0400 |
|---|---|---|
| committer | leochanj105 <leochanj@live.unc.edu> | 2020-10-20 02:40:39 -0400 |
| commit | f618466c25d43f3bae9e40920273bf77de1e1149 (patch) | |
| tree | 460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/localization/src/c/eul2quat.c | |
| parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) | |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/localization/src/c/eul2quat.c')
| -rw-r--r-- | SD-VBS/benchmarks/localization/src/c/eul2quat.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/localization/src/c/eul2quat.c b/SD-VBS/benchmarks/localization/src/c/eul2quat.c new file mode 100644 index 0000000..bea75cf --- /dev/null +++ b/SD-VBS/benchmarks/localization/src/c/eul2quat.c | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include <stdio.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include "localization.h" | ||
| 8 | |||
| 9 | F2D* eul2quat(F2D* angle) | ||
| 10 | { | ||
| 11 | F2D *ret; | ||
| 12 | F2D *x, *y, *z; | ||
| 13 | int k, i, j; | ||
| 14 | int rows, cols; | ||
| 15 | |||
| 16 | rows = angle->height; | ||
| 17 | cols = angle->width; | ||
| 18 | |||
| 19 | x = fDeepCopyRange(angle, 0, angle->height, 0, 1); | ||
| 20 | y = fDeepCopyRange(angle, 0, angle->height, 1, 1); | ||
| 21 | z = fDeepCopyRange(angle, 0, angle->height, 2, 1); | ||
| 22 | |||
| 23 | ret = fSetArray(x->height, 4, 0); | ||
| 24 | |||
| 25 | for(i=0; i<rows; i++) | ||
| 26 | { | ||
| 27 | float xi, yi, zi; | ||
| 28 | k = 0; | ||
| 29 | xi = asubsref(x,i); | ||
| 30 | yi = asubsref(y,i); | ||
| 31 | zi = asubsref(z,i); | ||
| 32 | |||
| 33 | subsref(ret,i,k) = cos(xi/2)*cos(yi/2)*cos(zi/2)+sin(xi/2)*sin(yi/2)*sin(zi/2); | ||
| 34 | k++; | ||
| 35 | subsref(ret,i,k) = sin(xi/2)*cos(yi/2)*cos(zi/2)-cos(xi/2)*sin(yi/2)*sin(zi/2); | ||
| 36 | k++; | ||
| 37 | subsref(ret,i,k) = cos(xi/2)*sin(yi/2)*cos(zi/2)+sin(xi/2)*cos(yi/2)*sin(zi/2); | ||
| 38 | k++; | ||
| 39 | subsref(ret,i,k) = cos(xi/2)*cos(yi/2)*sin(zi/2)-sin(xi/2)*sin(yi/2)*cos(zi/2); | ||
| 40 | } | ||
| 41 | |||
| 42 | fFreeHandle(x); | ||
| 43 | fFreeHandle(y); | ||
| 44 | fFreeHandle(z); | ||
| 45 | |||
| 46 | return ret; | ||
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | |||
