|
@@ -37,6 +37,56 @@
|
|
|
"cell_type": "markdown",
|
|
|
"metadata": {
|
|
|
"slideshow": {
|
|
|
+ "slide_type": "subslide"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "source": [
|
|
|
+ "# Introduction\n",
|
|
|
+ "\n",
|
|
|
+ "I wanted to show nice graphs and simulations, but it's not my domain and the talk is supposed to be a 101\n",
|
|
|
+ "\n",
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {
|
|
|
+ "slideshow": {
|
|
|
+ "slide_type": "subslide"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "source": [
|
|
|
+ "# Introduction\n",
|
|
|
+ "\n",
|
|
|
+ "- But the subject is still interesting, how can we have an introduction without digging too much ?\n",
|
|
|
+ "- Video games are a great example, implementing real physics is usually a bad idea, it doesn't feel good or is not fun for the gamer\n",
|
|
|
+ "- Then we implement an alternative physics which have similar behavior\n",
|
|
|
+ "- It's interesting to study those, usually much simplier and still gives a good idea of the real deal\n",
|
|
|
+ "\n",
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {
|
|
|
+ "slideshow": {
|
|
|
+ "slide_type": "notes"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "source": [
|
|
|
+ "## misconception\n",
|
|
|
+ "\n",
|
|
|
+ "- bernoulli effect is not THE explaination (faster = lower pressure, increase in the speed of a fluid occurs simultaneously with a decrease in pressure)\n",
|
|
|
+ "- It's a combination of effects\n",
|
|
|
+ " - air compression at the tip of the wing\n",
|
|
|
+ " - accelerate the air on one side (kind of bernouilli)\n",
|
|
|
+ " - air is accelerated downward so the wing is pushed up -> conservation of mass, momentum and energy"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {
|
|
|
+ "slideshow": {
|
|
|
"slide_type": "skip"
|
|
|
}
|
|
|
},
|
|
@@ -46,7 +96,7 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 6,
|
|
|
+ "execution_count": 5,
|
|
|
"metadata": {
|
|
|
"slideshow": {
|
|
|
"slide_type": "subslide"
|
|
@@ -62,6 +112,7 @@
|
|
|
"screen = None\n",
|
|
|
"drone = None\n",
|
|
|
"ground = None\n",
|
|
|
+ "ui = None\n",
|
|
|
"all = pygame.sprite.RenderUpdates()\n",
|
|
|
"clock = pygame.time.Clock()\n",
|
|
|
"\n",
|
|
@@ -76,15 +127,29 @@
|
|
|
" def reset(self):\n",
|
|
|
" self.velocity = (0, 0)\n",
|
|
|
" self.acceleration = (0, 1)\n",
|
|
|
- " self.rect = pos\n",
|
|
|
+ " self.rect = pos.copy()\n",
|
|
|
" \n",
|
|
|
"class Drone(DroneBase):\n",
|
|
|
- " pass"
|
|
|
+ " pass\n",
|
|
|
+ "\n",
|
|
|
+ "class UI(pygame.sprite.Sprite):\n",
|
|
|
+ " \n",
|
|
|
+ " def __init__(self):\n",
|
|
|
+ " self.containers = all\n",
|
|
|
+ " pygame.sprite.Sprite.__init__(self, self.containers)\n",
|
|
|
+ " self.font = pygame.font.Font(None, 24)\n",
|
|
|
+ " self.image = pygame.Surface((640, 20))\n",
|
|
|
+ " self.rect = pygame.Rect(0, 0, 640, 20)\n",
|
|
|
+ " \n",
|
|
|
+ " def update(self):\n",
|
|
|
+ " self.image.fill(pygame.Color('gray'))\n",
|
|
|
+ " self.image.blit(self.font.render(\"drone: vel={}, acc={}\".format(drone.velocity, drone.acceleration), True, (0, 0, 0)), (320, 1))\n",
|
|
|
+ " self.image.blit(self.font.render(\"r=reset, q=quit\", True, (0, 0, 0)), (5, 1))"
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 7,
|
|
|
+ "execution_count": 6,
|
|
|
"metadata": {
|
|
|
"slideshow": {
|
|
|
"slide_type": "subslide"
|
|
@@ -93,22 +158,24 @@
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
"def init():\n",
|
|
|
- " global running, screen\n",
|
|
|
+ " global running, screen, ui\n",
|
|
|
" running = True\n",
|
|
|
" \n",
|
|
|
" # Initialize pygame\n",
|
|
|
" pygame.init()\n",
|
|
|
" pygame.display.set_caption('Drone Physics 101')\n",
|
|
|
" screen = pygame.display.set_mode((x, y))\n",
|
|
|
+ " ui = UI()\n",
|
|
|
" \n",
|
|
|
" # Init sprite\n",
|
|
|
" all.empty()\n",
|
|
|
- " all.add(drone)"
|
|
|
+ " all.add(drone)\n",
|
|
|
+ " all.add(ui)"
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 8,
|
|
|
+ "execution_count": 7,
|
|
|
"metadata": {
|
|
|
"slideshow": {
|
|
|
"slide_type": "subslide"
|
|
@@ -131,6 +198,7 @@
|
|
|
" func()\n",
|
|
|
" \n",
|
|
|
" # Drawing everything\n",
|
|
|
+ " ui.update()\n",
|
|
|
" all.draw(screen)\n",
|
|
|
" pygame.display.flip()\n",
|
|
|
" \n",
|
|
@@ -171,8 +239,12 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 9,
|
|
|
- "metadata": {},
|
|
|
+ "execution_count": 6,
|
|
|
+ "metadata": {
|
|
|
+ "slideshow": {
|
|
|
+ "slide_type": "subslide"
|
|
|
+ }
|
|
|
+ },
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
"drone = Drone()\n",
|
|
@@ -192,7 +264,7 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 12,
|
|
|
+ "execution_count": 9,
|
|
|
"metadata": {
|
|
|
"slideshow": {
|
|
|
"slide_type": "subslide"
|
|
@@ -211,6 +283,8 @@
|
|
|
" self.velocity = (x, y)\n",
|
|
|
" if not self.rect.colliderect(ground):\n",
|
|
|
" self.rect.move_ip(x, y)\n",
|
|
|
+ " else:\n",
|
|
|
+ " self.velocity = (0, 0)\n",
|
|
|
" \n",
|
|
|
"drone = Drone()\n",
|
|
|
"render(drone.move)"
|
|
@@ -218,7 +292,11 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "markdown",
|
|
|
- "metadata": {},
|
|
|
+ "metadata": {
|
|
|
+ "slideshow": {
|
|
|
+ "slide_type": "notes"
|
|
|
+ }
|
|
|
+ },
|
|
|
"source": [
|
|
|
"* La physique\n",
|
|
|
" * Se battre contre la gravité (brick, ne peux pas planer)\n",
|