Search Results

Search found 2 results on 1 pages for 'dekz'.

Page 1/1 | 1 

  • Does this code follow the definition of recursion?

    - by dekz
    Hi All, I have a piece of code which I am doubting it as a implementation of recursion by its definition. My understanding is that the code must call itself, the exact same function. I also question whether writing the code this way adds additional overhead which can be seen with the use of recursion. What are your thoughts? class dhObject { public: dhObject** children; int numChildren; GLdouble linkLength; //ai GLdouble theta; //angle of rot about the z axis GLdouble twist; //about the x axis GLdouble displacement; // displacement from the end point of prev along z GLdouble thetaMax; GLdouble thetaMin; GLdouble thetaInc; GLdouble direction; dhObject(ifstream &fin) { fin >> numChildren >> linkLength >> theta >> twist >> displacement >> thetaMax >> thetaMin; //std::cout << numChildren << std::endl; direction = 1; thetaInc = 1.0; if (numChildren > 0) { children = new dhObject*[numChildren]; for(int i = 0; i < numChildren; ++i) { children[i] = new dhObject(fin); } } } void traverse(void) { glPushMatrix(); //draw move initial and draw transform(); draw(); //draw children for(int i = 0; i < numChildren; ++i) { children[i]->traverse(); } glPopMatrix(); } void update(void) { //Update the animation, if it has finished all animation go backwards if (theta <= thetaMin) { thetaInc = 1.0; } else if (theta >= thetaMax) { thetaInc = -1.0; } theta += thetaInc; //std::cout << thetaMin << " " << theta << " " << thetaMax << std::endl; for(int i = 0; i < numChildren; ++i) { children[i]->update(); } } void draw(void) { glPushMatrix(); glColor3f (0.0f,0.0f,1.0f); glutSolidCube(0.1); glPopMatrix(); } void transform(void) { //Move in the correct way, R, T, T, R glRotatef(theta, 0, 0, 1.0); glTranslatef(0,0,displacement); glTranslatef(linkLength, 0,0); glRotatef(twist, 1.0,0.0,0.0); } };

    Read the article

  • Vector deltas and moving in unknown areas

    - by dekz
    Hi All, I was in need of a little math help that I can't seem to find the answer to, any links to documentation would be greatly appreciated. Heres my situation, I have no idea where I am in this maze, but I need to move around and find my way back to the start. I was thinking of implementing a waypoint list of places i've been offset from my start at 0,0. This is a 2D cartesian plane. I've been given 2 properties, my translation speed from 0-1 and my rotation speed from -1 to 1. -1 is very left and +1 is very right. These are speed and not angles so thats where my problem lies. If I'm given 0 as a translation speed and 0.2 I will continually turn to my right at a slow speed. How do I figure out the offsets given these 2 variables? I can store it every time I take a 'step'. I just need to figure out the offsets in x and y terms given the translations and rotation speeds. And the rotation to get to those points. Any help is appreciated.

    Read the article

1