functie getangles bepaald de hoeken theta 1 en theta 2 bij een vooraf gegeven x en y

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
marijnstudent
Date:
Wed Oct 14 13:15:29 2015 +0000
Commit message:
werkende functie die de hoeken theta1 en theta2 berekend bij geen gewenste x en y

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Oct 14 13:15:29 2015 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "math.h"
+
+// x & y zijn inputs L is lengte van de arm r is de vector naar de end effector
+double x = 50;
+double y = 60;
+const double L = 36;
+const double pi = 3.1415926535897;
+double theta1= 0;
+double theta2 = 0;
+
+// functies die de hoeken berekend
+void getangles(double x,double y,double &theta_one,double &theta_two) // xy inputs
+{
+    double r = sqrt(pow(L,2)+pow(L,2)); // vector naar end effector
+    double alfa = acos((2*pow(L,2))/(4*L)); // alfa is de hoek tussen upper en lower arm
+    double beta = acos((pow(r,2))/(2*L*r)); // beta is de hoek tussen upper arm en r
+    // hoeken berekenen
+    theta_one = atan2(y,x)+beta;
+    theta_two = pi + alfa;
+ }
+ 
+ int main()
+ {
+     while(true)
+     {
+         getangles(x,y,theta1,theta2);
+         }
+     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Oct 14 13:15:29 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file