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
Fork of PsiSwarm-BeaconDemo_Bluetooth by
vector.cpp
00001 #include "main.h" 00002 #include <math.h> 00003 00004 00005 struct FloatVector addVector(struct FloatVector in_vector, int angle, int distance){ 00006 struct FloatVector out_vector; 00007 float sin_component_old = sin(in_vector.angle * TO_RAD) * in_vector.distance; 00008 float cos_component_old = cos(in_vector.angle * TO_RAD) * in_vector.distance; 00009 float sin_component_new = sin(angle * TO_RAD) * distance; 00010 float cos_component_new = cos(angle * TO_RAD) * distance; 00011 float sin_component_sum = sin_component_old + sin_component_new; 00012 float cos_component_sum = cos_component_old + cos_component_new; 00013 out_vector.distance = sqrt((sin_component_sum * sin_component_sum) + (cos_component_sum * cos_component_sum)); 00014 out_vector.angle = atan2(sin_component_sum ,cos_component_sum) * TO_DEG; 00015 //out("Angle:%f Distance:%f\n",out_vector.angle,out_vector.distance); 00016 return out_vector; 00017 }
Generated on Thu Jul 14 2022 08:02:39 by
1.7.2
