diff options
author | Matthew Kosarek <mattkae@protonmail.com> | 2021-06-17 21:32:57 -0400 |
---|---|---|
committer | Matthew Kosarek <mattkae@protonmail.com> | 2021-06-17 21:32:57 -0400 |
commit | 2ab6b6cfe81505b029f2da397cef0bb58989444f (patch) | |
tree | 41c581c80310c060dcbdcb049ce88970ca418d72 /2d/rigidbody/rigidbody_1.html.content | |
parent | 8748228bc9effa4779f4c1062f5fbc07f1d07a60 (diff) |
(mkosarek) Beginning to explain rigidbody physics in a reasonable way
Diffstat (limited to '2d/rigidbody/rigidbody_1.html.content')
-rw-r--r-- | 2d/rigidbody/rigidbody_1.html.content | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/2d/rigidbody/rigidbody_1.html.content b/2d/rigidbody/rigidbody_1.html.content index 6ca1619..0e75bdc 100644 --- a/2d/rigidbody/rigidbody_1.html.content +++ b/2d/rigidbody/rigidbody_1.html.content @@ -18,19 +18,51 @@ <h1>Rigidbody #1: Linear Forces</h1> <section> <p> - In this first installment of my 2D rigidbody tutorial, we are going to explore linear forces and how we can begin to simulate them in real time on a computer. As you'll come to see, 2D forces are quite easy to understand and implement if you have some basic knowledge of 2D maths. On top of that, they really add a lot of life into what would otherwise be a static 2D scene. Without further ado, let's jump in. + In this first installment of my 2D rigidbody tutorial, we are going to explore linear forces and how we can begin to simulate them in real time on a computer. As you'll come to see, 2D forces are quite easy to understand and implement if you have some basic knowledge of 2D maths. On top of that, they really add a lot of life into what would otherwise be a static 2D scene. </p> </section> <section> - <h2>What is a Force Anyway?</h2> + <h2>What do we mean by 'Rigid Body Physics'?</h2> + In implementing a rigidy body physics system, we're primarily interested in two sub-fields of physics, namely <b>dynamics</b> and <b>kinematics</b>. Although I'm + far as can be from being an expert in either of these fields, I will explain - from a programmer's perspective - what they mean to me: + + <ul> + <li> + <b>Kinematics</b> is the study of how an object's movement changes over time. These are the classic position, velocity, and acceleration equations that you're most likely familiar with from high school or college physics. Kinematics doesn't care about <i>how</i> a system entered into the state that it is out, but rather that the system <i>is</i> in that state. + </li> + <li> + <b>Dynamics</b> is the study of whats <i>causes</i> kinematic movement. These are the classic force and momentum equations that you may already be familiar with as well. Whereas kinematics only worries itself with the current state of the system, dynamics wants to know <i>how</i> the system entered the state that it is currently in. + </li> + </ul> + + Although the distinction between these two subfields may seem inconsequential, it impacts the conceptual way in which we might begin to setup our 2D rigidbody simulation: <i>the kinematic variables are the data that we act upon, while the dynamics variables are the data that we apply</i>. + + </section> + <section> + <h2>The Kinematics Data Structure</h2> + <p> + Now that we have that understanding, we can begin setting up our rigidbody data structure. + + {{{rigidbody_1/snippet1.cpp}}} + + As you can see, the base data structure exactly mirrors what we already know from 2D newtonian physics. + </p> + </section> + <section> + <h2>The Dynamics Functions</h2> <p> - + Now, let's put that Rigidbody data structure to work! As I mentioned earlier, you can think of dynamics as the <i>input</i> to the system. What we're going to do now is add a way to + + {{{rigidbody_1/snippet2.cpp}}} </p> </section> <section> <h2> Live Example </h2> + <p> + That's all there is to a rigidbody system with 2D linear forces. Now let's see it in action. Click 'Play' on the WebAssembly demo below to see a square bouncing around the screen. When you drag the pointer through the square, we will apply a force equivalent to how fast you were moving your mouse in the direction that you were moving it. (The speed is capped in the demo, or else things get a little out of hand.) + </p> <div class="opengl_canvas_container"> <canvas id="gl_canvas" width="800" height="600"></canvas> <button id="gl_canvas_play" class="play_button"> |