3

My engine (AndEngine) provides the modifier to move an object by Bezier Curve path, just by providing 3 or 4 points co-ordinate.

In my game, I move some birds with determined 3 points. However, it looks fake because the birds always point to a direction.

This looks like a mathematical question, but I think I should post at StackOverflow instead of Math Exchange: How to determine the rotation angle (in radian or degree) for the birds at a time?

Luke Vo
  • 17,859
  • 21
  • 105
  • 181

2 Answers2

3

You will take two points say P1 and P2 and will find the angle between them and then rotate you bird on that angle

    deltaX = nextPointX - YourBirdX;
    deltaY = NextPointY - YourBirdY;
    degree = ((Math.atan2(deltaY, deltaX)));
    angle = degree * 180 / 3.14;

    if(angle<0)
    {
        angle = 360+angle;
    }

I hope this will help you.

Jawad Amjad
  • 2,532
  • 2
  • 29
  • 59
  • float angleRad =(float)Math.atan2(deltaY, deltaX); float Vx = 50* (float)Math.cos(angleRad); float Vy = 50 * (float)Math.sin(angleRad); body.setVelocity(vX,vY); – AZ_ Feb 16 '12 at 07:44
0

What about (bezier(path, position + epsilon) - bezier(path, position)) / epsilon? Or, if you want it without the epsilon, look up the first derivation of a bezier curve.

Roland Illig
  • 40,703
  • 10
  • 88
  • 121
  • I don't know anything about Bezier Curve! I just input 3 points co-ordianates, and the engine does the rest, so I have no idea what are they. – Luke Vo Nov 15 '11 at 11:22
  • can u please help me?with this question realated to this http://stackoverflow.com/questions/18651025/how-to-move-image-on-curve-on-touch-event-in-android – BhavikKama Sep 06 '13 at 06:36