{"id":1490,"date":"2023-05-13T12:39:04","date_gmt":"2023-05-13T11:39:04","guid":{"rendered":"https:\/\/blog.univ-angers.fr\/mathsinfo\/?page_id=1490"},"modified":"2023-05-14T17:04:44","modified_gmt":"2023-05-14T16:04:44","slug":"dessiner-en-perspective","status":"publish","type":"page","link":"https:\/\/blog.univ-angers.fr\/mathsinfo\/dessiner-en-perspective\/","title":{"rendered":"Dessiner en perspective"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Vid\u00e9o d&rsquo;explication de la th\u00e9orie<\/h3>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Cr\u00e9ons un outil pour dessiner les plans en perspective\" width=\"584\" height=\"329\" src=\"https:\/\/www.youtube.com\/embed\/Uo7eceUOiQw?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\">Explications en vid\u00e9o<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Le programme principal<\/h3>\n\n\n\n<p>Copier-coller le programme ci-dessous sur cette page : <a href=\"https:\/\/geogebra.org\/python\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/geogebra.org\/python\/index.html<\/a><\/p>\n\n\n\n<p>J&rsquo;ai ajout\u00e9 2 param\u00e8tres, <strong>cx<\/strong> et <strong>cy<\/strong>, qui permettent d&rsquo;\u00e9tirer les valeurs num\u00e9riques horizontalement et verticalement. Par exemple si vous avez dessin\u00e9 un cube de largeur <strong>1 cm<\/strong> sur votre plan et que vous voulez une taille <strong>8 cm<\/strong> en perspective, utilisez <strong>cx = cy = 8<\/strong>. Vous pouvez mettre des valeurs diff\u00e9rentes pour d\u00e9former le r\u00e9sultat.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\npf, h = 4, 4\n\ncx, cy = 1, 1\n\nV = Point(0, h)\n\ndef drte(*pts):\n    (xa, ya), (xb, yb) = pts\n    return (yb - ya, xa - xb, xa * yb - xb * ya)\n\ndef persp(xyz):\n    x, y, z = xyz\n    pt1 = solve22(drte((x, y), (x + 1, y - 1)), (0, 1, 0))\n    pt2 = solve22(drte((x, y), (x - 1, y - 1)), (0, 1, 0))\n    if z != h:\n        pt1&#091;1] += z\n        pt2&#091;1] += z\n    sol = solve22(drte(pt1, (-pf, h)), drte(pt2, (pf, h)))\n    if z == h:\n        return sol&#091;0], h\n    else:\n        return sol\n\ndef solve22(*eq):\n    (a, b, e), (c, d, f) = eq\n    det = a * d - b * c\n    if det != 0:\n        x = (e * d - b * f) \/ det\n        y = (a * f - e * c) \/ det\n    return &#091;cx * x, cy * y]\n\ndef poly(p, coul = 'black'):\n    print('-' * 20)\n    i = 0\n    res = &#091;]\n    for (x, y, z) in p:\n        Z = Point(*persp((x, y, z)), is_visible = False)\n        print(Z)\n        res.append(Z)\n    A = Polygon(res)\n    A.color = coul\n\n# Exemple : Repr\u00e9sentation d'un plan\n\nplan1 = &#091;(-6, 2, 0),(-2, 2, 0), (-2, 8, 0), (-6, 8, 0)]\nplan2 = &#091;(-6, 2, 3),(-2, 2, 3), (-2, 8, 3), (-6, 8, 3)]\n\npoly(plan1, 'green')\npoly(plan2, 'red')\n<\/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\/2023\/05\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"669\" height=\"439\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image.png\" alt=\"\" class=\"wp-image-1491\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image.png 669w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-300x197.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-457x300.png 457w\" sizes=\"auto, (max-width: 669px) 100vw, 669px\" \/><\/a><figcaption class=\"wp-element-caption\">2 plans parall\u00e8les<\/figcaption><\/figure>\n<\/div>\n\n\n<p><span style=\"text-decoration: underline\">Remarque<\/span> : Les calculs des coordonn\u00e9es des points <strong>pt1<\/strong> et <strong>pt2<\/strong> ont \u00e9t\u00e9 faits en utilisant notre fonction <strong>solve22<\/strong> mais bien entendu un calcul direct \u00e9tait possible ! Vous pourrez montrer que la droite passant par les points <strong>A(x_A, y_A)<\/strong> et <strong>B(x_A + 1, y_A &#8211; 1)<\/strong> coupe l&rsquo;axe des abscisses en <strong>x_A + y_A<\/strong>. De m\u00eame, la droite passant par <strong>A(x_A, y_A)<\/strong> et <strong>B(x_A &#8211; 1, y_A &#8211; 1)<\/strong> coupe l&rsquo;axe des abscisses en <strong>x_A &#8211; y_A<\/strong>. La simplification est alors :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Ces 2 lignes :\n    \npt1 = solve22(drte((x, y), (x + 1, y - 1)), (0, 1, 0))\npt2 = solve22(drte((x, y), (x - 1, y - 1)), (0, 1, 0))\n\n# deviennent :\n\npt1 = &#091;x + y, 0]\npt2 = &#091;x - y, 0]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Programme pour les TI-82, 83&#8230;<\/h3>\n\n\n\n<p>Vous pouvez changer les valeurs du point de fuite (not\u00e9 <strong>P<\/strong>) et de la hauteur <strong>H<\/strong><\/p>\n\n\n\n<p>Voici le programme \u00e0 taper <a href=\"https:\/\/uabox.univ-angers.fr\/index.php\/s\/fFH3vVidb75zhs4\" target=\"_blank\" rel=\"noreferrer noopener\">ou \u00e0 t\u00e9l\u00e9charger<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRGM PERSP\n\n4\u2192P:4\u2192H:1\u2192S\nDisp \"X,Y,Z\nInput X\nInput Y\nInput Z\n0\u2192U\nIf Z\u2260H:Z\u2192U\nH-U\u2192A:X+Y+P\u2192B:UP+H(X+Y\u2192E\nH-U\u2192C:X-Y-P\u2192D\n\u00adUP+H(X-Y\u2192F:AD-BC\u2192G\n{ED-BF,AF-EC\u2192L\u2082\nIf Z=H:GH\u2192L\u2082(2\nDisp round(SL\u2082\/G,2\n\nUtilisation :\n\n- Lancez le programme PERSP\n- Entrez les coordonn\u00e9es X, Y et Z une par une\n- Les coordonn\u00e9es de sa projection s'affichent\n- ENTER pour entrer de nouvelles coordonn\u00e9es<\/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\/2023\/05\/Capturer1-1684063496908-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"324\" height=\"244\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/Capturer1-1684063496908-2.png\" alt=\"\" class=\"wp-image-1537\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/Capturer1-1684063496908-2.png 324w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/Capturer1-1684063496908-2-300x226.png 300w\" sizes=\"auto, (max-width: 324px) 100vw, 324px\" \/><\/a><figcaption class=\"wp-element-caption\">Projection du point (3, 4, 1) vers le point (1.5 , 2.5)<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-17-1024x768.png\" alt=\"\" class=\"wp-image-1540\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-17-1024x768.png 1024w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-17-300x225.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-17-768x576.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-17-1536x1152.png 1536w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-17-400x300.png 400w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-17.png 1872w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Repr\u00e9sentation point par point en utilisant une TI-83  avec les param\u00e8tres 15\u2192P:15\u2192H:2\u2192S<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-18.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-18-1024x768.png\" alt=\"\" class=\"wp-image-1544\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-18-1024x768.png 1024w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-18-300x225.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-18-768x576.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-18-1536x1152.png 1536w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-18-400x300.png 400w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-18.png 1872w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Autre repr\u00e9sentation \u00e0 la main en changeant point de fuite, hauteur et \u00e9chelle<\/figcaption><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">Exemples<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">La chambre<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>pf, h = 4, 4\n\nV = Point(0, h)\n\nsol = (-7, 0, 0), (5, 0, 0), (5, 15, 0), (-7, 15, 0)\nfond = (-7, 15, 0), (-7, 15, 5), (5, 15, 5), (5, 15, 0)\ngauche = (-7, 0, 0), (-7, 15, 0), (-7, 15, 5), (-7, 0, 5)\ndroite = (5, 0, 0), (5, 15, 0), (5, 15, 5), (5, 0, 5)\nchevet_cotes = (-7, 6, 0), (-5, 6, 0), (-5, 8, 0), (-5, 8, 1), (-5, 6, 1), (-7, 6, 1)\nchevet_haut = (-7, 6, 1), (-7, 8, 1), (-5, 8, 1), (-5, 6, 1)\nlit_cotes = (-7, 9, 0), (-1, 9, 0), (-1, 13, 0), (-1, 13, 1), (-1, 9, 1), (-7, 9, 1)\nlit_haut = (-7, 9, 1), (-1, 9, 1), (-1, 13, 1), (-7, 13, 1)\narmoire_cotes = (3, 10, 0), (5, 10, 0), (5, 10, 5), (3, 10, 5)\narmoire_face = (3, 10, 0), (3, 15, 0), (3, 15, 5), (3, 10, 5)\ncadre = (5, 6, 2), (5, 8, 2), (5, 8, 4), (5, 6, 4)\n\ndef drte(*pts):\n    (xa, ya), (xb, yb) = pts\n    return (yb - ya, xa - xb, xa * yb - xb * ya)\n\ndef persp(xyz):\n    x, y, z = xyz\n    pt1 = solve22(drte((x, y), (x + 1, y - 1)), (0, 1, 0))\n    pt2 = solve22(drte((x, y), (x - 1, y - 1)), (0, 1, 0))\n    if z != h:\n        pt1&#091;1] += z\n        pt2&#091;1] += z\n    sol = solve22(drte(pt1, (-pf, h)), drte(pt2, (pf, h)))\n    if z == h:\n        return sol&#091;0], h\n    else:\n        return sol\n\ndef solve22(*eq):\n    (a, b, e), (c, d, f) = eq\n    det = a * d - b * c\n    if det != 0:\n        x = (e * d - b * f) \/ det\n        y = (a * f - e * c) \/ det\n    return &#091;x, y]\n\ndef poly(p, coul = 'black'):\n    print('-' * 20)\n    res = &#091;]\n    for (x, y, z) in p:\n        Z = Point(*persp((x, y, z)), is_visible = False)\n        print(Z)\n        res.append(Z)\n    A = Polygon(res)\n    A.color = coul\n\npoly(sol, 'green')\npoly(fond, 'grey')\npoly(gauche, 'grey')\npoly(droite, 'grey')\npoly(chevet_cotes, 'red')\npoly(chevet_haut, 'red')\npoly(lit_cotes, 'blue')\npoly(lit_haut, 'blue')\npoly(armoire_cotes, 'brown')\npoly(armoire_face, 'brown')\npoly(cadre, 'pink')\n<\/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\/2023\/05\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"521\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-1.png\" alt=\"\" class=\"wp-image-1496\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-1.png 923w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-1-300x169.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-1-768x434.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-1-500x282.png 500w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/a><figcaption class=\"wp-element-caption\">pf, h = 4, 4<\/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\/2023\/05\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"915\" height=\"552\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-2.png\" alt=\"\" class=\"wp-image-1497\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-2.png 915w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-2-300x181.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-2-768x463.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-2-497x300.png 497w\" sizes=\"auto, (max-width: 915px) 100vw, 915px\" \/><\/a><figcaption class=\"wp-element-caption\">pf, h = 40, 20<\/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\/2023\/05\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"441\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-3.png\" alt=\"\" class=\"wp-image-1498\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-3.png 900w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-3-300x147.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-3-768x376.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-3-500x245.png 500w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><figcaption class=\"wp-element-caption\">pf, h = 40, 2<\/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\/2023\/05\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-6.png\" alt=\"\" class=\"wp-image-1507\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-6.png 320w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-6-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><figcaption class=\"wp-element-caption\">pf, h = 15, 1  sur la calculatrice NUMWORKS<\/figcaption><\/figure>\n<\/div>\n\n\n<h4 class=\"wp-block-heading\">Prisme dod\u00e9cagonal<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>from math import *\n\npf, h = 10, 10\n\nV = Point(0, h)\n\nhaut, bas = &#091;], &#091;]\n\nn = 12\nfor i in range(n):\n    x , y = -6+4 * cos(2 * i * pi \/ n), 5 + 4 * sin(2 * i * pi \/ n)\n    haut.append((x,y,5))\n    bas.append((x,y,0))\n    \ndef drte(*pts):\n    (xa, ya), (xb, yb) = pts\n    return (yb - ya, xa - xb, xa * yb - xb * ya)\n\ndef persp(xyz):\n    x, y, z = xyz\n    pt1 = solve22(drte((x, y), (x + 1, y - 1)), (0, 1, 0))\n    pt2 = solve22(drte((x, y), (x - 1, y - 1)), (0, 1, 0))\n    if z != h:\n        pt1&#091;1] += z\n        pt2&#091;1] += z\n    sol = solve22(drte(pt1, (-pf, h)), drte(pt2, (pf, h)))\n    if z == h:\n        return sol&#091;0], h\n    else:\n        return sol\n\ndef solve22(*eq):\n    (a, b, e), (c, d, f) = eq\n    det = a * d - b * c\n    if det != 0:\n        x = (e * d - b * f) \/ det\n        y = (a * f - e * c) \/ det\n    return &#091;x, y]\n\ndef poly(p, coul = 'black'):\n    print('-' * 20)\n    i = 0\n    res = &#091;]\n    for (x, y, z) in p:\n        Z = Point(*persp((x, y, z)), is_visible = False)\n        print(Z)\n        res.append(Z)\n    A = Polygon(res, line_thickness=6)\n    A.color = coul\n    \npoly(bas,'green')\n\nfor i in range(n):\n    poly(&#091;bas&#091;i],haut&#091;i],haut&#091;(i+1)%n],bas&#091;(i+1)%n]], 'grey' if i &lt;= n\/2 else 'black')<\/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\/2023\/05\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"907\" height=\"524\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-4.png\" alt=\"\" class=\"wp-image-1500\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-4.png 907w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-4-300x173.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-4-768x444.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-4-500x289.png 500w\" sizes=\"auto, (max-width: 907px) 100vw, 907px\" \/><\/a><figcaption class=\"wp-element-caption\">pf, h = 10, 10<\/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\/2023\/05\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"824\" height=\"475\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-5.png\" alt=\"\" class=\"wp-image-1501\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-5.png 824w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-5-300x173.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-5-768x443.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-5-500x288.png 500w\" sizes=\"auto, (max-width: 824px) 100vw, 824px\" \/><\/a><figcaption class=\"wp-element-caption\">pf, h = 20, 1<\/figcaption><\/figure>\n<\/div>\n\n\n<p>Version pour la calculatrice NUMWORKS : <a href=\"https:\/\/my.numworks.com\/python\/schraf\/prisme\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/my.numworks.com\/python\/schraf\/prisme<\/a><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-8.png\" alt=\"\" class=\"wp-image-1510\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-8.png 320w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-8-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><figcaption class=\"wp-element-caption\">pf, h = 40, 10<\/figcaption><\/figure>\n<\/div>\n\n\n<h4 class=\"wp-block-heading\">Exemple plus avanc\u00e9<\/h4>\n\n\n\n<p>Voici le plan (vue du dessus) d&rsquo;une cuisine : <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"956\" height=\"654\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-10.png\" alt=\"\" class=\"wp-image-1514\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-10.png 956w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-10-300x205.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-10-768x525.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-10-439x300.png 439w\" sizes=\"auto, (max-width: 956px) 100vw, 956px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Supposons que les meubles fassent 1 de hauteur. Pour m\u00e9moriser un meuble, on peut regarder uniquement ses coordonn\u00e9es en diagonale, par exemple pour le meuble du bas en vert, sa diagonale est (-4,0,<strong>0<\/strong>) et (-1,1,<strong>1<\/strong>), le <strong>0<\/strong> parce que le meuble touche le sol et <strong>1<\/strong> qui correspond \u00e0 sa hauteur.<\/p>\n\n\n\n<p>On peut alors cr\u00e9er une fonction <strong>box<\/strong> qui affichera les 5 ou 6 faces (on peut s&rsquo;\u00e9pargner la face inf\u00e9rieure). Voir code plus loin.<\/p>\n\n\n\n<p>On peut \u00e9galement ajouter une fonction de rotation pour avoir une vue sous diff\u00e9rents angles horizontalement.<\/p>\n\n\n\n<p>Voici le script final avec 10 meubles :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from math import *\npf, h = 20, 10\n\ncx, cy = 1, 1\n\n# Les faces d'un meuble\n\nfaces = ((0,0,0),(0,0,1),(0,1,1),(0,1,0)), ((0,0,0),(0,0,1),(1,0,1),(1,0,0)),\\\n        ((1,0,0),(1,0,1),(1,1,1),(1,1,0)), ((0,0,1),(0,1,1),(1,1,1),(1,0,1)),\\\n        ((0,1,0),(0,1,1),(1,1,1),(1,1,0))\n\n# Les meubles\no1 = (-4,0,0), (-1,1,1)\no2 = (-5,0,0), (-4,1.5,1)\no3 = (-5,1.5,0), (-4,2.5,1)\no4 = (-5,2.5,0), (-4,4,1)\no5 = (-4,3,0), (-2,4,1)\no6 = (-2,3,0), (-1,4,1)\no7 = (-1,3,0), (0,4,1)\no8 = (0,3,0), (1,4,1)\no9 = (-5,0,2), (-4.5,4,3)\no10 = (-2,3.5,2), (1,4,3)\n\n# Matrice de rotation\ndef rotate(x,y,angle):\n  xr = x*cos(angle) - y*sin(angle)\n  yr = x*sin(angle) + y*cos(angle)\n  return (xr,yr)\n\n# Affichage d'un meuble\ndef box(ob):\n    for f in faces:\n     s = &#091;]    \n     for (i,j,k) in f:\n         a,b = rotate(ob&#091;i]&#091;0],ob&#091;j]&#091;1], radians(-45))\n         s.append((a,b,ob&#091;k]&#091;2]))\n     poly(s, 'green')     \n        \ndef drte(*pts):\n    (xa, ya), (xb, yb) = pts\n    return (yb - ya, xa - xb, xa * yb - xb * ya)\n\ndef persp(xyz):\n    x, y, z = xyz\n    pt1 = solve22(drte((x, y), (x + 1, y - 1)), (0, 1, 0))\n    pt2 = solve22(drte((x, y), (x - 1, y - 1)), (0, 1, 0))\n    if z != h:\n        pt1&#091;1] += z\n        pt2&#091;1] += z\n    sol = solve22(drte(pt1, (-pf, h)), drte(pt2, (pf, h)))\n    if z == h:\n        return cx * sol&#091;0], cy * h\n    else:\n        return cx * sol&#091;0], cy * sol&#091;1]\n\ndef solve22(*eq):\n    (a, b, e), (c, d, f) = eq\n    det = a * d - b * c\n    if det != 0:\n        x = (e * d - b * f) \/ det\n        y = (a * f - e * c) \/ det\n    return &#091;x, y]\n\ndef poly(p, coul = 'black'):\n    print('-' * 20)\n    res = &#091;]\n    for (x, y, z) in p:\n        Z = Point(*persp((x, y, z)), is_visible = False)\n        print(Z)\n        res.append(Z)\n    A = Polygon(res)\n    A.color = coul\n\nfor ob in (o1,o2,o3,o4,o5,o6,o7,o8,o9,o10): box(ob)<\/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\/2023\/05\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"828\" height=\"549\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-13.png\" alt=\"\" class=\"wp-image-1518\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-13.png 828w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-13-300x199.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-13-768x509.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-13-452x300.png 452w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/a><figcaption class=\"wp-element-caption\">R\u00e9sultat avec pf, h = 20, 10 et une rotation de -45\u00b0<\/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\/2023\/05\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"875\" height=\"539\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-16.png\" alt=\"\" class=\"wp-image-1522\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-16.png 875w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-16-300x185.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-16-768x473.png 768w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/05\/image-16-487x300.png 487w\" sizes=\"auto, (max-width: 875px) 100vw, 875px\" \/><\/a><figcaption class=\"wp-element-caption\">R\u00e9sultat avec pf, h = 10, 2 et une rotation de -80\u00b0<\/figcaption><\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Vid\u00e9o d&rsquo;explication de la th\u00e9orie Le programme principal Copier-coller le programme ci-dessous sur cette page : https:\/\/geogebra.org\/python\/index.html J&rsquo;ai ajout\u00e9 2 param\u00e8tres, cx et cy, qui permettent d&rsquo;\u00e9tirer les valeurs num\u00e9riques horizontalement et verticalement. Par exemple si vous avez dessin\u00e9 un &hellip; <a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/dessiner-en-perspective\/\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4913,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1490","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/pages\/1490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/types\/page"}],"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=1490"}],"version-history":[{"count":28,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/pages\/1490\/revisions"}],"predecessor-version":[{"id":1552,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/pages\/1490\/revisions\/1552"}],"wp:attachment":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/media?parent=1490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}