{"id":1936,"date":"2024-09-30T17:19:56","date_gmt":"2024-09-30T16:19:56","guid":{"rendered":"https:\/\/blog.univ-angers.fr\/mathsinfo\/?p=1936"},"modified":"2024-09-30T17:27:37","modified_gmt":"2024-09-30T16:27:37","slug":"fractales","status":"publish","type":"post","link":"https:\/\/blog.univ-angers.fr\/mathsinfo\/2024\/09\/30\/fractales\/","title":{"rendered":"Fractales"},"content":{"rendered":"\n<p><a href=\"https:\/\/www.wolframscience.com\/nks\/p188--substitution-systems-and-fractals\/\" target=\"_blank\" rel=\"noreferrer noopener\">Sur cette page de Wolfram<\/a>, on peut voir diff\u00e9rentes fractales :<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"722\" height=\"863\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-3.png\" alt=\"\" class=\"wp-image-1937\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-3.png 722w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-3-251x300.png 251w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Et en bas de cette m\u00eame page les algorithmes utilis\u00e9s pour transformer les cases :<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"193\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-5.png\" alt=\"\" class=\"wp-image-1939\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-5.png 900w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-5-300x64.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-5-768x165.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-5-500x107.png 500w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Ci-dessous un programme Python qui permet d&rsquo;appliquer le motif voulu, il suffit d&rsquo;indiquer les coordonn\u00e9es des cases blanches. Par exemple pour le <em>(a)<\/em>, la seule <strong>case blanche<\/strong> est au milieu (coordonn\u00e9es <strong>(1,1)<\/strong>)<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"121\" height=\"121\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-6.png\" alt=\"\" class=\"wp-image-1940\" \/><\/a><figcaption class=\"wp-element-caption\">La case blanche en (1,1)<\/figcaption><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-code\"><code>from PIL import Image, ImageDraw\nimport numpy as np\n\n# Dimensions de l'image finale (\u00e0 modifier comme vous le voulez)\nsource = Image.new(\"RGB\", (600, 600), color=\"white\")\ndraw = ImageDraw.Draw(source)\n\n# Recherche s'il y a une case blanche\ndef has_common(str1, str2, pattern):\n    min_len = min(len(str1), len(str2))\n    for i in range(1, min_len + 1):\n        for p in pattern:\n            # Ne pas afficher si on trouve une case blanche\n            if str1&#091;-i] == p&#091;0] and str2&#091;-i] == p&#091;1]:\n                return False\n    # Sinon case noire\n    return True\n\n# Construction de la fractale\ndef fractal(pattern):\n    # On parcourt les colonnes\n    for c in range(600):\n        # Convertir 'c' en base 3 (ici \u00e0 l'aide de numpy)\n        t1 = np.base_repr(c, base=3)\n        # On parcourt les lignes\n        for l in range(600):\n            t2 = np.base_repr(l, base=3)\n            # Si pas de case blanche, afficher le point\n            if has_common(t1, t2, pattern):\n                draw.point((c, l), fill=(0, 0, 0))\n\n# Exemple avec le tapis de Sierpi\u0144ski\nfractal(&#091;\"11\"])\nsource.show()<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-7.png\" alt=\"\" class=\"wp-image-1941\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-7.png 600w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-7-300x300.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-7-150x150.png 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption class=\"wp-element-caption\">Motif (a) = case blanche en (1,1)<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Quelques motifs<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-9.png\" alt=\"\" class=\"wp-image-1945\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-9.png 600w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-9-300x300.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-9-150x150.png 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption class=\"wp-element-caption\">(b) = fractal([&rsquo;00&rsquo;,&rsquo;02&rsquo;,&rsquo;20&rsquo;,&rsquo;22&rsquo;])<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-10.png\" alt=\"\" class=\"wp-image-1947\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-10.png 600w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-10-300x300.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-10-150x150.png 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption class=\"wp-element-caption\">(d) = fractal([&rsquo;10&rsquo;,&rsquo;20&rsquo;,&rsquo;21&rsquo;])<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-11.png\" alt=\"\" class=\"wp-image-1949\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-11.png 600w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-11-300x300.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-11-150x150.png 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption class=\"wp-element-caption\">(e) = fractal([&rsquo;00&rsquo;,&rsquo;02&rsquo;,&rsquo;11&rsquo;,&rsquo;20&rsquo;,&rsquo;22&rsquo;])<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-12.png\" alt=\"\" class=\"wp-image-1950\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-12.png 600w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-12-300x300.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-12-150x150.png 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption class=\"wp-element-caption\">(g) = fractal([&rsquo;11&rsquo;,&rsquo;20&rsquo;])<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-13.png\" alt=\"\" class=\"wp-image-1951\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-13.png 600w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-13-300x300.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-13-150x150.png 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption class=\"wp-element-caption\">(h) = fractal([&rsquo;02&rsquo;,&rsquo;11&rsquo;,&rsquo;20&rsquo;])<\/figcaption><\/figure>\n<\/div>\n\n\n<p>Et on peut en inventer de nouveaux :<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-14.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-14.png\" alt=\"\" class=\"wp-image-1953\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-14.png 600w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-14-300x300.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2024\/09\/image-14-150x150.png 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption class=\"wp-element-caption\">fractal([&rsquo;02&rsquo;,&rsquo;10&rsquo;,&rsquo;20&rsquo;])<\/figcaption><\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Sur cette page de Wolfram, on peut voir diff\u00e9rentes fractales : Et en bas de cette m\u00eame page les algorithmes utilis\u00e9s pour transformer les cases : Ci-dessous un programme Python qui permet d&rsquo;appliquer le motif voulu, il suffit d&rsquo;indiquer les &hellip; <a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/2024\/09\/30\/fractales\/\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4913,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1936","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/users\/4913"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/comments?post=1936"}],"version-history":[{"count":6,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1936\/revisions"}],"predecessor-version":[{"id":1954,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1936\/revisions\/1954"}],"wp:attachment":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/media?parent=1936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/categories?post=1936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/tags?post=1936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}