Skip to main content

Posts

Showing posts from April, 2015

Integrating Circular Motion Estimates in 2D

1. Theory 2. Example Circular motion start at (Px 1 ,Py 1 ,theta 1 ) = (5,4,128.6598 o ) with 30 o angular displacement. 3. Code #include <iostream> #include <iomanip> #include <math.h> #define PI 3.14159265 using namespace std; int main () {             double motion0[4] = {5,4,128.6598,30}; // Example Starting :{Px1,Py1,theta1,dtime}        double dtheta = 30 * (PI/180);        double radius = 6.4031;        double motion1[4] ; // {Px2,Py2,theta2,dtime}               cout << motion0[0] << ";" << motion0[1] << ";" << motion0[2] << endl;        motion0[2] = motion0[2] * (PI/180); //Change to radians for ( int i = 0; i < 20; i++)  ...

Find points on circle in C++

1. Theory 2. Code #include <iostream> #include <math.h> using namespace std; int main () { double r = 7; // put the value of radius of circle double h = 2, k = 3; // (h,k) = center of circle coordinate double x = 0, y = 0; // (x,y) = circle coordinate double theta = 0; // in radians, start with 0 rad for(int i = 0; i < 80 ;i++) // Pick 40 points or more ( { x = (cos(theta) * r); // x value, start value is equal with r (cos (0) = 1) y = sqrt(abs(r*r - x*x)); // Determine y value if (theta > 3.1415926535897932384626433832795) // Add offset with center of circle, PI is C&P from Calculator { x = x + h; y = -y + k;} else { x = x + h; y = y + k; } cout  << x << ";" << y << endl; theta = theta + 0.07853975; // Next x value (PI/40 or somethings else) } system("PAUSE"); return 0; } 3. Sample Console Output 9;3 8.97842;3.54921 8.91382;4.09504 8.80659;4.63...