موضوع: How to animate a ball using math

ردود: 5 | زيارات: 675
  1. #1

    Post How to animate a ball using math

    • How to animate a ball using math
    • the scientific side of computer graphics"
    • what we are going to do is to animat a ball using math expressions ,the
      ball will bounce against the floor with attenuation during its movement.
    • to do this follow these are step by step instructions
    • 1-craet nurbs plane and scale it 24 times.
      2-create nurbs sphere .
      3-still select the sphere ,right-mouse-click on "translate Y"
      and choose Experssion, a window will appear to you.
      4-in this window under experssion write this :
      =========================================
      nurbsSphere1.translateY=cos(time);
      =========================================
      this line tells MAYA to move the sphere in y direction according to cos function.
    • just a little review:
      cos : x-----cos(x)
      cos : ]-infinity,+infinity[ ------> [-1,+1]
    • in our situation the free variable is (TIME), and it begins at 0,as we know
      cos(0)=1 which tells that the pivot of our sphere will be at (0,1,0)
      at the beginning of the time,if we play the animation ,the "translateY" will decrease untill reaching (0,-1,0)
      where it stops and then back again to (0,1,0) and start over again.

      5-we need some adjustment to acheive the we goul,
      let us multiply the cos function with 4,so the previous line will be:
      ============================================
      nurbsSphere1.translateY=4*cos(time);
      ============================================
    • here the movement will oscillate between (0,4,0) and (0,-4,0).
    • 5-untill now it not seems like our ball is bounsing at all,
      to fix this lets us remmeber absolotw value (abs) function
    • abs : x ---->|x|
      abs : ]-infinity,+infinity[------>[0,+infinity[
    • that GRAPHICALLY means (when you draw the graph of this function )
      every point under x axes (minuse values) will be refected above the
      x axes.
    • now play back the animation and watch the new motion.
    • 6-the ball penetrate the plane , to fix this problem
      just add 1 to the script line above ,so it will look like this:
    • ===========================================
      nurbsSphere1.translateY=abs(4*cos(time))+1;
      ===========================================
    • 7-if you like to make the motion faster multiply the time inside cos function
      ====================================
      nurbsSphere1.translateY=abs(4*cos(time*5))+1;
      ============================================
      this will make it 5 times faster.
    • 8-now we need some attenuation. and this will be done by (exp) function.
    • exp :x-------->exp(x)
      exp :]-infinity,+infinity[------]0,+infinity[
    • the propersty of this function that we are goning to use is its
      'acceleration' ,while the free variable(x) increase (decrease) ,exp(x)
      will increase (decrease) much much faster .
    • adjust the script line like this
      ====================================
      nurbsSphere1.translateY=exp(-time)*abs(4*cos(time*5))+1;
      ====================================
      I multiply exp(-time) with the previous expression
      "abs(4*cos(time*5))+1" and this will attenuate the bouncing by time.
    • if you want more attenuation try exp(-time/2), if you want less attenuation
      try exp(-time*2) .
    • now we have done with bouning and attenuation, let us go to rotation
      and translation to some direction and let it be x direction.
    • 9-right-mouse-click on "translate x"and choose Experssion :
      right (like you have done above) this script:
    • ========================================
      nurbsSphere1.translateX=4*log(time+1);
      ========================================
    • log :x---->log(x)
      log :]0,+infinity[---->]-infinity,+infinity[
    • I add 1 in log function because there is no log(0), and multiply
      by 3 to make the movement to "x" lasts a little longer.
    • play back and watch.
    • 10- we need to rotate the ball so it will look more realistic motion.to do this

      right-mouse-click on "rotate Z" and choose Experssion
    • right down this script:
      =======================================
      nurbsSphere1.rotateZ=-200*log(time+1);
      ======================================
    • by the logic of translation x
    • and here it is.
    • if you further explainations,i will try to answer you Q at this e-mail
      or in this page.

      justforthis101@yahoo.com


  2. #2

    How to animate aball using math

    you can download a better written tutorial .

  3. #3
    عضو نشيط
    صور رمزية Rami3D
    تاريخ التسجيل
    Mar 2005
    المنطقة
    الاردن
    العمر
    38
    ردود
    479
    مرحبا اخي theone
    انا اشكرك على الدرس وهو جميل
    لكن لو كنت تنسق الدرس بطريقة افضل حتى يكون اسهل للمبتدئين
    ولو تقدر تكتبه بالعربي يكون افضل حتى يستفيد منه الجميع
    جزاك الله كل خير
    Palestine4Ever

  4. #4

    Smile

    شكرا على ملاحظاتك,ساحاول ترتيب الدرس بشكل افضل المرة القادمة,ولكن بالنسبة للكتابة باللغة العربية ,انا بطيء جدا جدا...وقد يستغرق درس مثل هذا ساعتان كتابة؟؟؟؟؟؟؟!ّ!!!!.....لذلك اعذرني...

  5. #5
    مشكور اخي على الدرس ممتاز
    There is a man he would to give his life to keep a life you loved beside him
    "Charles dickens"

Bookmarks

قوانين الموضوعات

  • لا يمكنك اضافة موضوع جديد
  • لا يمكنك اضافة ردود
  • لا يمكنك اضافة مرفقات
  • لا يمكنك تعديل مشاركاتك
  •  
  • كود BB مفعّل
  • رموز الحالة مفعّل
  • كود [IMG] مفعّل
  • [VIDEO] code is مفعّل
  • كود HTML معطل