Page 1 of 2 12 LastLast
Results 1 to 40 of 73

Thread: Need this

  1. #1

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Need this

    Attached Images Attached Images   

  2. #2

  3. #3
    Hyperactive Member Iron Skull's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    325

    Re: Need this

    If you want to be banned just go away send a PM to a mod to ask and stop spamming the Forums...

    506C65617365205261746520506F7374732E2E2E

  4. #4

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    That's for later on incase VBForums ends up making me fat again.

  5. #5
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Need this

    Use:
    VB Code:
    1. End
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  6. #6

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Need this too.
    Attached Images Attached Images  

  7. #7

  8. #8
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: Need this

    You need a lot of things don't you?
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  9. #9
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Need this

    Like the love of a good woman...
    Zeegnahtuer?

  10. #10

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Quote Originally Posted by thegreatone
    Like the love of a good woman...
    Already get that every night. I love my Jasmine.

  11. #11
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Need this

    Quote Originally Posted by Jacob Roman
    Already get that every night. I love my Jasmine.
    Good on yer.
    Zeegnahtuer?

  12. #12

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Need this too
    Attached Files Attached Files

  13. #13
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Need this

    That interleaved code of yours, all your modules must have double of the amount of lines needed, and the screen shows the same its shown with normal code in a 640x480 resolution.

  14. #14

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Quote Originally Posted by jcis
    That interleaved code of yours, all your modules must have double of the amount of lines needed, and the screen shows the same its shown with normal code in a 640x480 resolution.
    Huh?

  15. #15
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Need this

    and now I need this... don't hate me for it...
    Last edited by timeshifter; Jan 2nd, 2006 at 05:15 PM.

  16. #16

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    What'cha doing with my Korg Triton Extreme?!!!

    Lucky little punk.
    I wanted that for so long.

  17. #17

  18. #18

  19. #19

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Physics! How can I not need em!
    Attached Files Attached Files

  20. #20

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Just incase I'm not able to get on this computer
    Attached Files Attached Files

  21. #21

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Working and (sorta complete) Tile Engine I wrote!!!
    DXTut - Tile Engine.zip

    Other DX 2D tutorials I must cover:

    Quadtrees
    Time Based Movement
    Scrolling Backgrounds
    Sprite Layers
    Animation States
    Clipping
    Rotation
    Scaling
    Filling Modes
    Multitexturing

  22. #22

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    VB Code:
    1. For Y = 0 To Map_Height
    2.  
    3.     For X = 0 To Map_Width
    4.  
    5.         If Clip_Polygon(Vertex_List(I + 0), Vertex_List(I + 4)) = False Then
    6.  
    7.             X2 = X2 + 1
    8.  
    9.             If Temp <> Y Then
    10.  
    11.                 Temp = Y
    12.  
    13.                 Y2 = Y2 + 1
    14.  
    15.             End If
    16.  
    17.             New_Tile(X2 - 1,Y2 - 1) = Tile(X,Y)
    18.  
    19.         End If
    20.  
    21.         I = I + Number_Of_Vertices_Per_Quad
    22.  
    23.         End If
    24.  
    25.     Next X
    26.  
    27. Next Y

  23. #23
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Need this

    If you want more smilies you can always post them in the Fx Extension thread...and I will add them next time...

  24. #24

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    The ban plz smilie and w00t! smilie should definitely be added

  25. #25

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Also this one
    Attached Images Attached Images  

  26. #26

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Attached Images Attached Images  

  27. #27

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Attached Files Attached Files

  28. #28

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Quake 4 physics from the SDK
    Attached Files Attached Files

  29. #29
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Re: Need this

    quake 3 would make a nice virtual world.

  30. #30

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Forward Euler
    Backward Euler
    Symplectic Euler
    Explicit Euler
    Inplicit Euler
    Verlet
    Time Corrected Verlet
    Runge Kutta 2
    Runge Kutta 4
    Runge Kutta 6
    Newton Stormer Verlet
    Euler-Verlet Variant
    Feynman

  31. #31
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Need this

    FridgeCutter 3D
    Zeegnahtuer?

  32. #32

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Code:
    //-----------------------------------------------------------------------------
    //                                                                           
    //                           heat1d_simple.cpp                               
    //     Simulates the 1D Heat Equation by Forward (Explicit) Euler Method     
    //                in the case of constant Dirichlet BCs.                     
    //
    //  * The number of grid points (nj+1) is fixed at compile time.
    //  * Boundary values are fixed by initial conditions and do not change.   
    //                                                                                     
    //-----------------------------------------------------------------------------
    
    #include <iostream>
    #include <fstream>
    #include <cmath>
    
    using namespace std;
    
    // Global variables 
    // ----------------
    const double pi = 3.14159265358979323846;
    const int nj = 100;		// Number of spatial grid points = nj + 1
    
    // Function prototypes 
    // -------------------
    void    Step_fe (double U[], const double dt, const double dx);
    
    
    //===========================================================================//
    
    int main (void)
    {
      int     nsteps;
      double  U[nj + 1], dt, dx, t_f, length;
    
      // Set and write problem parameters 
      // --------------------------------
      cout << "Enter length, final time, number of time steps" << endl;
      cin >> length >> t_f >> nsteps;
    
      dt = t_f / nsteps;
      dx = length / nj;
    
      cout << endl << "Parameters:  \n";
      cout << " nj = " << nj << "\t"
        << " length = " << length << "\t" << " dx = " << dx << endl;
      cout << " nsteps = " << nsteps << "\t"
        << " t_f = " << t_f << "\t" << " dt = " << dt << endl;
      cout << " nu = " << dt / (dx * dx) << endl << endl;
    
      // Set initial conditions 
      // ----------------------
      // Two initial conditions are given:
      // U(x) = x + sin(4 pi x) + 2 sin(9 pi x) 
      // U(x) = 4 * x * ( 1 - x )
      // uncomment as desired. 
    
      for (int j = 0; j <= nj; j++)
        {
          U[j] = j * dx + sin (4. * pi * j * dx) + 2. * sin (9. * pi * j * dx);
          // 4. * j * dx * (1. - j * dx);
        }
    
      // Main time stepping loop 
      // -----------------------
      for (int time_step = 0; time_step < nsteps; time_step++)
        {
          Step_fe (U, dt, dx);
        }
    
      // Write final results to a file
      // -----------------------------
      ofstream fout ("heat1d.txt");
      for (int j = 0; j <= nj; j++)
        {
          fout << j << "\t" << U[j] << endl;
        }
    
      return 0;
    }
    
    //===========================================================================//
    
    void Step_fe (double U[], const double dt, const double dx)
    {
      // Function for taking one Forward-Euler time-step.  For all
      // interior grid points, it replaces U[j] with U[j] at the next time
      // step.  Values at the boundaries j=0 and j=nj are unchanged.  The
      // array A_plus_on_U is necessary for temporary storage.
    
      const double nu = dt / (dx * dx);
      double  A_plus_on_U[nj + 1];
    
      for (int j = 1; j < nj; j++)
        {
          A_plus_on_U[j] = U[j] + nu * (U[j - 1] - 2. * U[j] + U[j + 1]);
        }
    
      for (int j = 1; j < nj; j++)
        {
          U[j] = A_plus_on_U[j];
        }
    }
    
    //===========================================================================//

  33. #33

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Explicit methods calculate the state of a system at next instance in time using the state of the system at the current time, while an implicit method finds it by solving an equation involving both the current system state and the future one.


  34. #34
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Need this

    Quote Originally Posted by Jacob Roman
    Explicit methods calculate the state of a system at next instance in time using the state of the system at the current time, while an implicit method finds it by solving an equation involving both the current system state and the future one.

    Zeegnahtuer?

  35. #35

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Time Step Integration Methods


    x - Position
    v - Velocity
    a - Acceleration
    dt - Delta Time
    x0 - Initial Position
    v0 - Initial Velocity


    Euler Integration:
    x = x0 + v * dt
    v = v0 + a * dt

    Velocity-less Verlet:
    v = x - old_x + a * dt * dt
    x = x0 + v
    old_x = x

    Time Corrected Velocity-less Verlet
    v = x + (x - old_x) * (dt / old_dt) + a * dt * dt
    x = x0 + v
    old_x = x
    old_dt = dt

    Prescaled Euler
    v = v0 + a * dt * dt
    x = x0 + v

    Re-ordered traditional Euler, AKA "Semi-implicit" Euler):
    v = v0 + a * dt
    x = x0 + v * dt

    http://www.msu.edu/~brechtjo/physics.../netForce.html
    http://www.devmaster.net/wiki/Integration_methods
    http://xbeams.chem.yale.edu/~batista/vaa/node60.html
    http://www.openmp.org/samples/md.html
    http://www.compsoc.man.ac.uk/~lucky/...ry/verlet.html
    http://www.cs.unc.edu/~coombe/comp259/hw1/

    A must see, with code samples!!!
    http://www.ph.ed.ac.uk/~graeme/compmeth/verlet.html

    Still trying the LeapFrog
    http://www.artcompsci.org/vol_1/v1_web/node35.html

    'h - step size
    'y - position
    'y0 - initial position
    't0 - intial time
    'f() - function


    'Euler: y'(t) = f(y(t),t) y(t0) = y0

    'Forward Euler (Explicit): y(t+1) = y(t) + h * f(y(t),t)

    'Backward Euler (Implicit): y(t+1) = y(t) + h * f(y(t + 1),t + 1)

  36. #36

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    Code:
    struct Test {
    
      Test() {
        int count = 100;
        flt x = 0.f;
        flt v = 0.f;
        flt a = 9.81f;
        flt dt = 1.f/flt(count);
        int i;
    
        lprintf("Simple Euler:\n");
        for (i=0; i < count; i++) {
          x += v*dt;
          v += a*dt;
          lprintf("V: %f X: %f\n",v,x);
        } // for
    
        x = v = 0.f;
        lprintf("More Accurate Euler:\n");
        for (i=0; i < count; i++) {
          x += v*dt + .5f*a*dt*dt;
          v += a*dt;
          lprintf("V: %f X: %f\n",v,x);
        } // for
    
        x = v = 0.f;
        lprintf("NSV: Newton-Stormer-Verlet ('Semi-implicit' Euler):\n");
        for (i=0; i < count; i++) {
          v += a*dt;
          x += v*dt;
          lprintf("V: %f X: %f\n",v,x);
        } // for
        lprintf("Velocity-less Verlet:\n");
        flt xc = 0.f;
        flt xo = xc;
        for (i=0; i < count; i++) {
          v = xc - xo + a*dt*dt;
          xo = xc;
          xc += v;
          lprintf("V: %f X: %f\n",v/dt,xc);
        } // for
        lprintf("My NSV variant\n");
        x = v = 0.f;
        flt dt2 = dt*dt;
        for (i=0; i < count; i++) {
          v += a*dt2;
          x += v; // v is prescaled: really a displacement.
          lprintf("V: %f X: %f\n",v/dt,x);
        } // for
    
        lprintf("Velocity Verlet variant\n");
        flt oldAccel = a; //0.f; // May be self-starting issues...
        x = v = 0.f;
        for (i=0; i < count; i++) {
          x += v*dt + .5f*oldAccel*dt*dt;
          v +=        .5f*(oldAccel+a)*dt;
          oldAccel = a;
          lprintf("V: %f X: %f\n",v,x);
        } // for
      }
    
    } test;
    VB Code:
    1. Option Explicit
    2.  
    3. Dim dt As Single
    4.  
    5. Private Sub Timer1_Timer()
    6.  
    7.     Dim k1 As Single, k2 As Single, k3 As Single, k4 As Single
    8.     Dim l1 As Single, l2 As Single, l3 As Single, l4 As Single
    9.     Dim x As Single, v As Single, a As Single
    10.     Dim xnew As Single, vnew As Single
    11.     Dim f As Single, m As Single
    12.     Dim x0 As Single, v0 As Single
    13.    
    14.     ScaleMode = 3
    15.     AutoRedraw = True
    16.     DrawWidth = 10
    17.    
    18.     f = 5
    19.     m = 5
    20.     v = 1
    21.    
    22.     a = f / m
    23.    
    24.     k1 = dt * v
    25.     l1 = dt * a
    26.    
    27.     k2 = dt * (v + k1 / 2)
    28.     l2 = dt * a
    29.    
    30.     k3 = dt * (v + k2 / 2)
    31.     l3 = dt * a
    32.    
    33.     k4 = dt * (v + k3)
    34.     l4 = dt * a
    35.    
    36.     xnew = x + k1 / 6 + k2 / 3 + k3 / 3 + k4 / 6
    37.     vnew = v + l1 / 6 + l2 / 3 + l3 / 3 + l4 / 6
    38.    
    39.     Cls
    40.    
    41.     PSet (xnew, 100)
    42.     Caption = xnew & "    " & vnew
    43.  
    44.     dt = dt + 0.1
    45.  
    46. End Sub

  37. #37

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    http://www.gamedev.net/community/for...opic_id=374930

    Post #14

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Activate()
    4.    
    5.     AutoRedraw = True
    6.    
    7.     Dim k1 As Single, k2 As Single, k3 As Single, k4 As Single
    8.     Dim l1 As Single, l2 As Single, l3 As Single, l4 As Single
    9.     Dim x As Single, x0 As Single, v As Single, f As Single
    10.     Dim a As Single, dt As Single, v0 As Single, m As Single
    11.    
    12.     v0 = 1
    13.     a = 0
    14.    
    15.     List1.AddItem "Euler Integration"
    16.     List1.AddItem "---------------------"
    17.    
    18.     For dt = 0 To 10 Step 0.5
    19.    
    20.         x = x0 + v * dt
    21.         v = v0 + a * dt
    22.    
    23.         List1.AddItem "X: " & x & "    " & "V: " & v
    24.    
    25.     Next dt
    26.    
    27.     List1.AddItem ""
    28.     List1.AddItem "RK4 Integration"
    29.     List1.AddItem "---------------------"
    30.    
    31.     f = 0
    32.     m = 1
    33.     v0 = 1
    34.    
    35.     a = f / m
    36.  
    37.     For dt = 0 To 10 Step 0.5
    38.  
    39.         k1 = dt * v
    40.         l1 = dt * a
    41.        
    42.         k2 = dt * (v + k1 / 2)
    43.         l2 = dt * a
    44.        
    45.         k3 = dt * (v + k2 / 2)
    46.         l3 = dt * a
    47.        
    48.         k4 = dt * (v + k3)
    49.         l4 = dt * a
    50.        
    51.         x = x0 + k1 / 6 + k2 / 3 + k3 / 3 + k4 / 6
    52.         v = v0 + l1 / 6 + l2 / 3 + l3 / 3 + l4 / 6
    53.        
    54.         List1.AddItem "X: " & x & "    " & "V: " & v
    55.  
    56.     Next dt
    57.  
    58. End Sub

  38. #38

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Main()
    4.    
    5.     Dim S As String, S2 As String, S3 As String, S4 As String
    6.     Dim k1 As Single, k2 As Single, k3 As Single, k4 As Single
    7.     Dim l1 As Single, l2 As Single, l3 As Single, l4 As Single
    8.     Dim x As Single, x0 As Single, v As Single, f As Single
    9.     Dim xc As Single
    10.     Dim a As Single, dt As Single, dt2 As Single, v0 As Single, m As Single
    11.     Dim i As Long
    12.     Dim Old_A As Single
    13.    
    14.     a = 9.8
    15.     dt = 1 / 10
    16.     x = 0
    17.     v = 0
    18.    
    19.     'S = S & "" & vbCrLf
    20.     S = S & "Euler Integration" & vbCrLf
    21.     S = S & "---------------------" & vbCrLf
    22.    
    23.     For i = 0 To 9
    24.    
    25.         x = x + v * dt
    26.         v = v + a * dt
    27.    
    28.         S = S & "X: " & x & "    " & "V: " & v & vbCrLf
    29.    
    30.     Next i
    31.    
    32.     x = 0
    33.     v = 0
    34.    
    35.     S = S & "" & vbCrLf
    36.     S = S & "2nd Order Euler Integration" & vbCrLf
    37.     S = S & "---------------------" & vbCrLf
    38.    
    39.     For i = 0 To 9
    40.    
    41.         x = x + v * dt + 0.5 * a * dt * dt
    42.         v = v + a * dt
    43.    
    44.         S = S & "X: " & x & "    " & "V: " & v & vbCrLf
    45.    
    46.     Next i
    47.    
    48.     x = 0
    49.     v = 0
    50.    
    51.     S2 = S2 & "" & vbCrLf
    52.     S2 = S2 & "Newton Stormer Verlet (Semi Implicit Euler)" & vbCrLf
    53.     S2 = S2 & "---------------------" & vbCrLf
    54.    
    55.     For i = 0 To 9
    56.    
    57.         v = v + a * dt
    58.         x = x + v * dt
    59.    
    60.         S2 = S2 & "X: " & x & "    " & "V: " & v & vbCrLf
    61.    
    62.     Next i
    63.    
    64.     x = 0
    65.     v = 0
    66.    
    67.     S2 = S2 & "" & vbCrLf
    68.     S2 = S2 & "Velocity-less Verlet Integration" & vbCrLf
    69.     S2 = S2 & "---------------------" & vbCrLf
    70.    
    71.     For i = 0 To 9
    72.    
    73.         v = x - x0 + a * dt * dt
    74.         x0 = x
    75.         x = x + v
    76.    
    77.         S2 = S2 & "X: " & x & "    " & "V: " & v / dt & vbCrLf
    78.    
    79.     Next i
    80.    
    81.     x = 0
    82.     v = 0
    83.     dt2 = dt * dt
    84.    
    85.     S3 = S3 & "" & vbCrLf
    86.     S3 = S3 & "NSV Variant Integration" & vbCrLf
    87.     S3 = S3 & "---------------------" & vbCrLf
    88.    
    89.     For i = 0 To 9
    90.    
    91.         v = v + a * dt2
    92.         x = x + v
    93.    
    94.         S3 = S3 & "X: " & x & "    " & "V: " & v / dt & vbCrLf
    95.    
    96.     Next i
    97.    
    98.     x = 0
    99.     v = 0
    100.  
    101.     'FIX THIS
    102.     '/////////////////////////////////////////////////////////////
    103.     S3 = S3 & "" & vbCrLf
    104.     S3 = S3 & "Velocity Verlet Integration" & vbCrLf
    105.     S3 = S3 & "---------------------" & vbCrLf
    106.    
    107.     Old_A = a
    108.    
    109.     For i = 0 To 9
    110.    
    111.       x = x + v * dt + 0.5 * Old_A * dt * dt
    112.       v = v + 0.5 * (Old_A + a) * dt
    113.    
    114.         S3 = S3 & "X: " & x & "    " & "V: " & v / dt & vbCrLf
    115.    
    116.     Next i
    117.  
    118.     '/////////////////////////////////////////////////////////////
    119.    
    120.     S4 = S4 & "" & vbCrLf
    121.     S4 = S4 & "RK4 Integration" & vbCrLf
    122.     S4 = S4 & "---------------------" & vbCrLf
    123.  
    124.     x = 0
    125.     v = 0
    126.  
    127.     For i = 0 To 9
    128.  
    129.         k1 = dt * v
    130.         l1 = dt * a
    131.        
    132.         k2 = dt * (v + k1 / 2)
    133.         l2 = dt * a
    134.        
    135.         k3 = dt * (v + k2 / 2)
    136.         l3 = dt * a
    137.        
    138.         k4 = dt * (v + k3)
    139.         l4 = dt * a
    140.        
    141.         x = x + k1 / 6 + k2 / 3 + k3 / 3 + k4 / 6
    142.         v = v + l1 / 6 + l2 / 3 + l3 / 3 + l4 / 6
    143.        
    144.         S4 = S4 & "X: " & x & "    " & "V: " & v & vbCrLf
    145.  
    146.     Next i
    147.    
    148.     MsgBox S
    149.     MsgBox S2
    150.     MsgBox S3
    151.     MsgBox S4
    152.    
    153.     End
    154.  
    155. End Sub

  39. #39

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Activate()
    4.    
    5.     Dim k1 As Single, k2 As Single, k3 As Single, k4 As Single
    6.     Dim l1 As Single, l2 As Single, l3 As Single, l4 As Single
    7.    
    8.     Dim x As Single, v As Single, a As Single
    9.    
    10.     Dim dt As Single, dt2 As Single
    11.     Dim f As Single, m As Single
    12.    
    13.     Dim Old_X As Single, Old_A As Single
    14.    
    15.     Dim i As Long
    16.    
    17.     a = 9.8
    18.     dt = 1 / 100
    19.     x = 0
    20.     v = 0
    21.    
    22.     'List1.AddItem ""
    23.     List1.AddItem "Euler Integration"
    24.     List1.AddItem "---------------------"
    25.    
    26.     For i = 0 To 99
    27.    
    28.         x = x + v * dt
    29.         v = v + a * dt
    30.    
    31.         List1.AddItem "X: " & x & "    " & "V: " & v
    32.    
    33.     Next i
    34.    
    35.     x = 0
    36.     v = 0
    37.    
    38.     List1.AddItem ""
    39.     List1.AddItem "2nd Order Euler Integration"
    40.     List1.AddItem "---------------------"
    41.    
    42.     For i = 0 To 99
    43.    
    44.         x = x + v * dt + 0.5 * a * dt * dt
    45.         v = v + a * dt
    46.    
    47.         List1.AddItem "X: " & x & "    " & "V: " & v
    48.    
    49.     Next i
    50.    
    51.     x = 0
    52.     v = 0
    53.    
    54.     List1.AddItem ""
    55.     List1.AddItem "Newton Stormer Verlet (Semi Implicit Euler)"
    56.     List1.AddItem "---------------------"
    57.    
    58.     For i = 0 To 99
    59.    
    60.         v = v + a * dt
    61.         x = x + v * dt
    62.    
    63.         List1.AddItem "X: " & x & "    " & "V: " & v
    64.    
    65.     Next i
    66.    
    67.     x = 0
    68.     v = 0
    69.    
    70.     List1.AddItem ""
    71.     List1.AddItem "Velocity-less Verlet Integration"
    72.     List1.AddItem "---------------------"
    73.    
    74.     For i = 0 To 99
    75.    
    76.         v = x - Old_X + a * dt * dt
    77.         Old_X = x
    78.         x = x + v
    79.    
    80.         List1.AddItem "X: " & x & "    " & "V: " & v / dt
    81.    
    82.     Next i
    83.    
    84.     x = 0
    85.     v = 0
    86.     dt2 = dt * dt
    87.    
    88.     List1.AddItem ""
    89.     List1.AddItem "Newton Stormer Verlet Variant Integration"
    90.     List1.AddItem "---------------------"
    91.    
    92.     For i = 0 To 99
    93.    
    94.         v = v + a * dt2
    95.         x = x + v
    96.    
    97.         List1.AddItem "X: " & x & "    " & "V: " & v / dt
    98.    
    99.     Next i
    100.    
    101.     x = 0
    102.     v = 0
    103.     Old_A = a
    104.  
    105.     List1.AddItem ""
    106.     List1.AddItem "Velocity Verlet Integration"
    107.     List1.AddItem "---------------------"
    108.    
    109.     For i = 0 To 99
    110.    
    111.         x = x + v * dt + 0.5 * Old_A * dt * dt
    112.         v = v + 0.5 * (Old_A + a) * dt
    113.         Old_A = a
    114.    
    115.         List1.AddItem "X: " & x & "    " & "V: " & v
    116.    
    117.     Next i
    118.  
    119.     List1.AddItem ""
    120.     List1.AddItem "RK4 Integration"
    121.     List1.AddItem "---------------------"
    122.  
    123.     x = 0
    124.     v = 0
    125.  
    126.     For i = 0 To 99
    127.  
    128.         k1 = dt * v
    129.         l1 = dt * a
    130.        
    131.         k2 = dt * (v + k1 / 2)
    132.         l2 = dt * a
    133.        
    134.         k3 = dt * (v + k2 / 2)
    135.         l3 = dt * a
    136.        
    137.         k4 = dt * (v + k3)
    138.         l4 = dt * a
    139.        
    140.         x = x + k1 / 6 + k2 / 3 + k3 / 3 + k4 / 6
    141.         v = v + l1 / 6 + l2 / 3 + l3 / 3 + l4 / 6
    142.        
    143.         List1.AddItem "X: " & x & "    " & "V: " & v
    144.  
    145.     Next i
    146.  
    147.     List1.AddItem ""
    148.     List1.AddItem "RK2 Integration"
    149.     List1.AddItem "---------------------"
    150.  
    151.     x = 0
    152.     v = 0
    153.  
    154.     For i = 0 To 99
    155.  
    156.         k1 = dt * v
    157.         l1 = dt * a
    158.        
    159.         k2 = dt * (v + k1 / 2)
    160.         l2 = dt * a
    161.        
    162.         x = x + k2
    163.         v = v + l2
    164.        
    165.         List1.AddItem "X: " & x & "    " & "V: " & v
    166.  
    167.     Next i
    168.  
    169. End Sub

  40. #40

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Need this


    x - Position
    v - Velocity
    a - Acceleration
    dt - Delta Time


    Euler
    Aliases: Forward Euler, Explicit Euler
    ----------------------------------------
    x = x + v * dt
    v = v + a * dt

    2nd Order Euler
    ----------------------------------------
    x = x + v * dt + 0.5 * a * dt * dt
    v = v + a * dt

    Verlet
    Aliases: Velocity-less Verlet
    ----------------------------------------
    v = x - old_x + a * dt * dt
    x = x + v
    old_x = x

    Time Corrected Velocity-less Verlet
    ----------------------------------------
    v = (x - old_x) * (dt / old_dt) + a * dt * dt
    x = x + v
    old_x = x
    old_dt = dt

    Prescaled Euler
    Aliases: Newton Stomer Verlet Variant
    ----------------------------------------
    v = v + a * dt * dt
    x = x + v

    Re-ordered traditional Euler
    Aliases: Semi-Implicit Euler, Newton Stormer Verlet, Backwards Euler
    ----------------------------------------
    v = v + a * dt
    x = x + v * dt

    Velocity Verlet
    ----------------------------------------
    x = x + v * dt + 0.5 * Old_A * dt * dt
    v = v + 0.5 * (Old_A + a) * dt
    Old_A = a

    2nd Order Runge Kutta,
    Aliases: Midpoint Method, RK2
    ----------------------------------------
    k1 = dt * v
    l1 = dt * a

    k2 = dt * (v + k1 / 2)
    l2 = dt * a

    x = x + k2
    v = v + l2

    4th Order Runge Kutta
    Aliases: RK4
    ----------------------------------------
    k1 = dt * v
    l1 = dt * a

    k2 = dt * (v + k1 / 2)
    l2 = dt * a

    k3 = dt * (v + k2 / 2)
    l3 = dt * a

    k4 = dt * (v + k3)
    l4 = dt * a

    x = x + k1 / 6 + k2 / 3 + k3 / 3 + k4 / 6
    v = v + l1 / 6 + l2 / 3 + l3 / 3 + l4 / 6

    DO NOT COPY & PASTE
    http://www.scottsarra.org/nHam/nHam.html
    The Gaffer Articles.....FINALLY
    Even Better, The best rigid body stacking demo with code
    Integration Timestep
    Little help with the Physics engine

Page 1 of 2 12 LastLast

Posting Permissions

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



Click Here to Expand Forum to Full Width