moving a body in a spiral motion

I found a post on the forum (viewtopic.php?f=8&t=2662&p=13316&hilit=spiral+motion+body#p13316) with some code for making a body move in a spiral motion. The body is moving strangely and suddenly goes off screen but not in a spiral motion. I don't fully understand the code, especially how the testAngle is calculated and the condition for the testAngle. I would appreciate any help. Below is my code:

Code: Select all

-(void)spiralBodyScheduler   {
    CGSize screenSize = [[CCDirector sharedDirector] winSize];
    b2Vec2 bodyPosition = body->GetPosition();
    b2Vec2 bodyTargetPosition = b2Vec2(10.0f, screenSize.height/3/PTM_RATIO);
    float bodyChangeX = bodyTargetPosition.x - bodyPosition.x;
    float bodyChangeY = bodyTargetPosition.y - bodyPosition.y;
   
    float bodyAngle = bodyChangeX * tan(bodyChangeX/bodyChangeY);
    bodyAngle += 1.1471975;
   
    if (body->GetPosition().y > screenSize.height/4/PTM_RATIO) {
        bodyAngle -= 3.1415926;
    }
   
    float bodyForceX = sinf(bodyAngle) * SPIRAL_BODY_SPEED;
    float bodyForceY = cosf(bodyAngle) * SPIRAL_BODY_SPEED;

    b2Vec2 bodyForce = b2Vec2(bodyForceX, bodyForceY);
    body->ApplyForce(birdForce, body->GetWorldCenter());
   
}

Original thread: https://box2d.org/forum/viewtopic.php?t=9275