Results 1 to 10 of 15

Thread: 2D Skeletal Animation System Questions (and Source)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    How do you calculate the new X1,Y1 position?

    I have the original X0, Y0 values and X1, Y1 Values. And the length of Bone, L.

    Code:
    X1 := X0 + L * Cos(DegToRad(Angle-90));
    Y1 := Y0 + L * Sin(DegToRad(Angle-90));
    This almost works for me. It only works if the Initial Angle between (X0,Y0) and (X1,Y1) is 0 otherwise I got a small difference after the rotation. And my Math does not help!

    Do you have any advice?

  2. #2
    My first advice is to not work with Degrees (Animation.zip):
    Code:
    var 
      S, C: Single;
    
    SinCos(Angle, S, C);
    X1:= X0 + L * S;
    Y1:= Y0 - L * C;
    Your angle must be in the range from 0 to 2*Pi (Figure A, Picture 1):
    If Angle > 2*Pi then Angle:= Angle - 2*Pi;
    If Angle < 0 then Angle:= Angle + 2*Pi;
    (but this should not happen if your animation is prepare properly)

    Figure B and C presents the problem that you can have by using Auto Frames.
    In my case, one minute of animation takes 40 KB with Auto Frames and 200 KB without Auto Frames - this is still not much, so it is not necessary to implement Auto Frames.
    Attached Images Attached Images
    Attached Files Attached Files

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •