/usr/share/pyshared/pyromaths/cinquiemes/symetrie.py is in pyromaths 11.05.1b2-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | #!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Pyromaths
# Un programme en Python qui permet de créer des fiches d'exercices types de
# mathématiques niveau collège ainsi que leur corrigé en LaTeX.
# Copyright (C) 2006 -- Jérôme Ortais (jerome.ortais@pyromaths.org)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
import random
import string
from math import atan, cos, pi, sin, floor, ceil
#===============================================================================
# Symétrique d'une figure par rapport à une droite avec quadrillage
#===============================================================================
def valeurs_quad2(nb_pts):
vals = []
for i in range(nb_pts):
angle = random.randrange((i * 360) / nb_pts, ((i + 1) * 360) /
nb_pts)
vals.append(((random.randrange(1, 7) * .5) * cos((angle * pi) /
180), (random.randrange(1, 7) * .5) * sin((angle *
pi) / 180)))
return vals
def valeurs_quad(nb_pts):
vals = []
for i in range(nb_pts):
(alpha, beta) = ((i * 360) / nb_pts, ((i + 1) * 360) / nb_pts)
(x, y) = (0, 0)
while x == 0 or angle < alpha or angle > beta:
(x, y) = (random.randrange(-6, 7) * .5, random.randrange(-6,
7) * .5)
if x > 0:
angle = int((atan((y * 1.0) / x) * 180) / pi + 360) % \
360
if x < 0:
angle = int((atan((y * 1.0) / x) * 180) / pi + 180)
vals.append((x, y))
return vals
def centre_sym(vals):
fin = 0
while not fin:
(fin, cpt) = (1, 0)
(o1, o2) = (random.randrange(-6, 7) * .5, random.randrange(-6, 7) *
.5)
while fin and cpt < len(vals):
fin = fin and -3 <= 2 * o1 - vals[cpt][0] <= 3 and -3 <= 2 * \
o2 - vals[cpt][1] <= 3
cpt = cpt + 1
return (o1, o2)
def place_pts(vals, O):
txt = [" \\pstGeonode[PointSymbol=none,PointName=none]"]
for i in range(len(vals)):
txt.append("(%s,%s)" % vals[i])
txt.append("{%s}" % chr(i + 97))
txt.append("\n \\pstGeonode[PointSymbol=x, linecolor=Black, dotsize=6pt](%s,%s){O}" % O)
txt.append("\n \\pspolygon[linewidth=1pt]")
for i in range(len(vals)):
txt.append("(%s)" % chr(i + 97))
return ("").join(txt)
def place_pts_sym(vals):
txt = [" \\pstSymO[PointSymbol=x,PointName=none]{O}{"]
for i in range(len(vals)):
if i > 0:
txt.append(",")
txt.append("%s" % chr(i + 97))
txt.append("}[")
for i in range(len(vals)):
if i > 0:
txt.append(",")
txt.append("%s1" % chr(i + 97))
txt.append("]\n\pspolygon[linecolor=Black,linestyle=dashed, linewidth=1pt]")
for i in range(len(vals)):
txt.append("(%s1)" % chr(i + 97))
return ("").join(txt)
def exo_quadrillage(f0, f1):
pass
def main():
exo = ["\\exercice",
u"Construire la symétrique de chacune des figures par rapport au point O en",
"utilisant le quadrillage :\\par", "\\psset{unit=.9cm}"]
cor = ["\\exercice*",
u"Construire la symétrique de chacune des figures par rapport au point O en",
"utilisant le quadrillage :\\par", "\\psset{unit=.9cm}"]
nbpts = 5
langles = [0, 90, 45, 135]
for i in range(3):
angle = langles.pop(random.randrange(len(langles)))
vals = valeurs_quad(nbpts)
O = centre_sym(vals)
txt = place_pts(vals, O)
exo.append("\\begin{pspicture*}(-3,-3)(3,3)")
exo.append("\\psgrid[subgriddiv=2,gridlabels=0pt]")
exo.append(txt)
cor.append("\\begin{pspicture*}(-3,-3)(3,3)")
cor.append("\\psgrid[subgriddiv=2,gridlabels=0pt]")
cor.append(txt)
cor.append(place_pts_sym(vals))
exo.append("\end{pspicture*}")
cor.append("\end{pspicture*}")
if i < 2:
exo.append("\\hfill")
cor.append("\\hfill")
return (exo, cor)
|