Psi Swarm Code V0.41 [With Beautiful Meme program]
Dependencies: PsiSwarmLibrary mbed
Fork of BeautifulMemeProjectBT by
Diff: vector.cpp
- Revision:
- 30:513457c1ad12
- Parent:
- 29:9756004e8499
diff -r 9756004e8499 -r 513457c1ad12 vector.cpp --- a/vector.cpp Thu Mar 03 23:22:01 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/// PsiSwarm Beautiful Meme Project Source Code -/// Version 0.4 -/// James Hilder, Alan Millard, Homero Elizondo, Jon Timmis -/// University of York - -// vector.cpp - Functions for calculating floating point bearing vectors - -#include "main.h" -#include <math.h> - - -struct FloatVector addVector(struct FloatVector in_vector, int angle, int distance){ - struct FloatVector out_vector; - float sin_component_old = sin(in_vector.angle * TO_RAD) * in_vector.distance; - float cos_component_old = cos(in_vector.angle * TO_RAD) * in_vector.distance; - float sin_component_new = sin(angle * TO_RAD) * distance; - float cos_component_new = cos(angle * TO_RAD) * distance; - float sin_component_sum = sin_component_old + sin_component_new; - float cos_component_sum = cos_component_old + cos_component_new; - out_vector.distance = sqrt((sin_component_sum * sin_component_sum) + (cos_component_sum * cos_component_sum)); - out_vector.angle = atan2(sin_component_sum ,cos_component_sum) * TO_DEG; - //out("Angle:%f Distance:%f\n",out_vector.angle,out_vector.distance); - return out_vector; -} \ No newline at end of file