:bigyello:
Printable View
:bigyello:
And this......
http://www.futureproducers.com/tutorial.php/id/29
If you want to be banned just go away send a PM to a mod to ask and stop spamming the Forums...
That's for later on incase VBForums ends up making me fat again. :lol:
Use:VB Code:
End
Need this too.
You need a lot of things don't you? ;)
Like the love of a good woman...
Already get that every night. I love my Jasmine. :bigyello:Quote:
Originally Posted by thegreatone
Good on yer.Quote:
Originally Posted by Jacob Roman
Need this too :p
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? :ehh:Quote:
Originally Posted by jcis
and now I need this... don't hate me for it...
What'cha doing with my Korg Triton Extreme?!!! :eek:
Lucky little punk. :mad:
I wanted that for so long. :(
Need this as well.
http://www.physicsclassroom.com/Clas...aws/U2L2c.html
Physics! How can I not need em! :bigyello:
Just incase I'm not able to get on this computer
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
VB Code:
For Y = 0 To Map_Height For X = 0 To Map_Width If Clip_Polygon(Vertex_List(I + 0), Vertex_List(I + 4)) = False Then X2 = X2 + 1 If Temp <> Y Then Temp = Y Y2 = Y2 + 1 End If New_Tile(X2 - 1,Y2 - 1) = Tile(X,Y) End If I = I + Number_Of_Vertices_Per_Quad End If Next X Next Y
If you want more smilies you can always post them in the Fx Extension thread...and I will add them next time...
The ban plz smilie and w00t! smilie should definitely be added ;)
Also this one :lol:
:bigyello:
:eek:
Quake 4 physics from the SDK :eek2:
quake 3 would make a nice virtual world.
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
FridgeCutter 3D ;)
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];
}
}
//===========================================================================//
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.
:eek:
:eek2:Quote:
Originally Posted by Jacob Roman
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)
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:
Option Explicit Dim dt As Single Private Sub Timer1_Timer() Dim k1 As Single, k2 As Single, k3 As Single, k4 As Single Dim l1 As Single, l2 As Single, l3 As Single, l4 As Single Dim x As Single, v As Single, a As Single Dim xnew As Single, vnew As Single Dim f As Single, m As Single Dim x0 As Single, v0 As Single ScaleMode = 3 AutoRedraw = True DrawWidth = 10 f = 5 m = 5 v = 1 a = f / m 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 xnew = x + k1 / 6 + k2 / 3 + k3 / 3 + k4 / 6 vnew = v + l1 / 6 + l2 / 3 + l3 / 3 + l4 / 6 Cls PSet (xnew, 100) Caption = xnew & " " & vnew dt = dt + 0.1 End Sub
http://www.gamedev.net/community/for...opic_id=374930
Post #14
VB Code:
Option Explicit Private Sub Form_Activate() AutoRedraw = True Dim k1 As Single, k2 As Single, k3 As Single, k4 As Single Dim l1 As Single, l2 As Single, l3 As Single, l4 As Single Dim x As Single, x0 As Single, v As Single, f As Single Dim a As Single, dt As Single, v0 As Single, m As Single v0 = 1 a = 0 List1.AddItem "Euler Integration" List1.AddItem "---------------------" For dt = 0 To 10 Step 0.5 x = x0 + v * dt v = v0 + a * dt List1.AddItem "X: " & x & " " & "V: " & v Next dt List1.AddItem "" List1.AddItem "RK4 Integration" List1.AddItem "---------------------" f = 0 m = 1 v0 = 1 a = f / m For dt = 0 To 10 Step 0.5 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 = x0 + k1 / 6 + k2 / 3 + k3 / 3 + k4 / 6 v = v0 + l1 / 6 + l2 / 3 + l3 / 3 + l4 / 6 List1.AddItem "X: " & x & " " & "V: " & v Next dt End Sub
VB Code:
Option Explicit Private Sub Main() Dim S As String, S2 As String, S3 As String, S4 As String Dim k1 As Single, k2 As Single, k3 As Single, k4 As Single Dim l1 As Single, l2 As Single, l3 As Single, l4 As Single Dim x As Single, x0 As Single, v As Single, f As Single Dim xc As Single Dim a As Single, dt As Single, dt2 As Single, v0 As Single, m As Single Dim i As Long Dim Old_A As Single a = 9.8 dt = 1 / 10 x = 0 v = 0 'S = S & "" & vbCrLf S = S & "Euler Integration" & vbCrLf S = S & "---------------------" & vbCrLf For i = 0 To 9 x = x + v * dt v = v + a * dt S = S & "X: " & x & " " & "V: " & v & vbCrLf Next i x = 0 v = 0 S = S & "" & vbCrLf S = S & "2nd Order Euler Integration" & vbCrLf S = S & "---------------------" & vbCrLf For i = 0 To 9 x = x + v * dt + 0.5 * a * dt * dt v = v + a * dt S = S & "X: " & x & " " & "V: " & v & vbCrLf Next i x = 0 v = 0 S2 = S2 & "" & vbCrLf S2 = S2 & "Newton Stormer Verlet (Semi Implicit Euler)" & vbCrLf S2 = S2 & "---------------------" & vbCrLf For i = 0 To 9 v = v + a * dt x = x + v * dt S2 = S2 & "X: " & x & " " & "V: " & v & vbCrLf Next i x = 0 v = 0 S2 = S2 & "" & vbCrLf S2 = S2 & "Velocity-less Verlet Integration" & vbCrLf S2 = S2 & "---------------------" & vbCrLf For i = 0 To 9 v = x - x0 + a * dt * dt x0 = x x = x + v S2 = S2 & "X: " & x & " " & "V: " & v / dt & vbCrLf Next i x = 0 v = 0 dt2 = dt * dt S3 = S3 & "" & vbCrLf S3 = S3 & "NSV Variant Integration" & vbCrLf S3 = S3 & "---------------------" & vbCrLf For i = 0 To 9 v = v + a * dt2 x = x + v S3 = S3 & "X: " & x & " " & "V: " & v / dt & vbCrLf Next i x = 0 v = 0 'FIX THIS '///////////////////////////////////////////////////////////// S3 = S3 & "" & vbCrLf S3 = S3 & "Velocity Verlet Integration" & vbCrLf S3 = S3 & "---------------------" & vbCrLf Old_A = a For i = 0 To 9 x = x + v * dt + 0.5 * Old_A * dt * dt v = v + 0.5 * (Old_A + a) * dt S3 = S3 & "X: " & x & " " & "V: " & v / dt & vbCrLf Next i '///////////////////////////////////////////////////////////// S4 = S4 & "" & vbCrLf S4 = S4 & "RK4 Integration" & vbCrLf S4 = S4 & "---------------------" & vbCrLf x = 0 v = 0 For i = 0 To 9 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 S4 = S4 & "X: " & x & " " & "V: " & v & vbCrLf Next i MsgBox S MsgBox S2 MsgBox S3 MsgBox S4 End End Sub
VB Code:
Option Explicit Private Sub Form_Activate() Dim k1 As Single, k2 As Single, k3 As Single, k4 As Single Dim l1 As Single, l2 As Single, l3 As Single, l4 As Single Dim x As Single, v As Single, a As Single Dim dt As Single, dt2 As Single Dim f As Single, m As Single Dim Old_X As Single, Old_A As Single Dim i As Long a = 9.8 dt = 1 / 100 x = 0 v = 0 'List1.AddItem "" List1.AddItem "Euler Integration" List1.AddItem "---------------------" For i = 0 To 99 x = x + v * dt v = v + a * dt List1.AddItem "X: " & x & " " & "V: " & v Next i x = 0 v = 0 List1.AddItem "" List1.AddItem "2nd Order Euler Integration" List1.AddItem "---------------------" For i = 0 To 99 x = x + v * dt + 0.5 * a * dt * dt v = v + a * dt List1.AddItem "X: " & x & " " & "V: " & v Next i x = 0 v = 0 List1.AddItem "" List1.AddItem "Newton Stormer Verlet (Semi Implicit Euler)" List1.AddItem "---------------------" For i = 0 To 99 v = v + a * dt x = x + v * dt List1.AddItem "X: " & x & " " & "V: " & v Next i x = 0 v = 0 List1.AddItem "" List1.AddItem "Velocity-less Verlet Integration" List1.AddItem "---------------------" For i = 0 To 99 v = x - Old_X + a * dt * dt Old_X = x x = x + v List1.AddItem "X: " & x & " " & "V: " & v / dt Next i x = 0 v = 0 dt2 = dt * dt List1.AddItem "" List1.AddItem "Newton Stormer Verlet Variant Integration" List1.AddItem "---------------------" For i = 0 To 99 v = v + a * dt2 x = x + v List1.AddItem "X: " & x & " " & "V: " & v / dt Next i x = 0 v = 0 Old_A = a List1.AddItem "" List1.AddItem "Velocity Verlet Integration" List1.AddItem "---------------------" For i = 0 To 99 x = x + v * dt + 0.5 * Old_A * dt * dt v = v + 0.5 * (Old_A + a) * dt Old_A = a List1.AddItem "X: " & x & " " & "V: " & v Next i List1.AddItem "" List1.AddItem "RK4 Integration" List1.AddItem "---------------------" x = 0 v = 0 For i = 0 To 99 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 List1.AddItem "X: " & x & " " & "V: " & v Next i List1.AddItem "" List1.AddItem "RK2 Integration" List1.AddItem "---------------------" x = 0 v = 0 For i = 0 To 99 k1 = dt * v l1 = dt * a k2 = dt * (v + k1 / 2) l2 = dt * a x = x + k2 v = v + l2 List1.AddItem "X: " & x & " " & "V: " & v Next i End Sub
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