0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(途中)大人用「(長方形の折り紙)高校入試チャレンジ問題 台形BCDEの面積を求めよ (灘中学校の入試問題(改)... 」を、計算はsympyで、作図のmatplotlibは教えてもらいました。

Last updated at Posted at 2025-12-27

・作図は未です。
・まだ、Youtubeのコメント様を見ていません。申し訳ありません。

オリジナル

Youtube

YUUU0123 様 (0:00〜6:10) いつもお世話になっております。
↓高校入試チャレンジ問題 台形BCDEの面積を求めよ (灘中学校の入試問題(改)ですが、高校入試としても、十分出せる問題です)
https://youtu.be/WfBWUzFqgnY

sympyで(Youtbeオリジナル 様の方法を参考に)

ver0.1

・丸写しです。
・>まず、相似な三角形を考えます。...
・>パタンと折ったので...

# ver0.1
from sympy import *
var('a,b,BC,DE',positive=True)
AB,AE=3,1
b_sol=solve(Eq(a     /b     ,Rational(1,3))                ,b)[0] # ;print(b_sol)
a_sol=solve(Eq((AB-b)/(AE+a),Rational(1,3)).subs({b:b_sol}),a)[0] # ;print(a_sol)
print("#",((BC+DE)*AB/2).subs({BC:1+a,DE:a}).subs({a:a_sol})) 
# 39/10

sympyで(いつもの座標の方法で)

ver1.1

・1点ずつ。ワタシ的には、お気に入りです。
・>パタンと折ったので...

# ver1.1
from sympy import *
AB,AE=3,1
B,A,E=map(Point,[(0,0),(AB,0),(AB,-AE)])
Ad   =A.rotate(Line(E,A).angle_between(Line(E,B))*2,pt=E)  #;print(Ad)
C,D  =map(Point,[(0,Ad.y),(AB,Ad.y)])
print("#",Polygon(B,C,D,E).area)
# 39/10

ver1.2

・反転、Lineの projctionで。他に??? 私の探し方が上手くいかないかも。

# ver1.2
from sympy import *
AB,AE=3,1
B,A,E=map(Point,[(0,0),(AB,0),(AB,-AE)])
Ad   =A+(Line(B,E).projection(A)-A)*2  #;print(Ad)
C,D  =map(Point,[(0,Ad.y),(AB,Ad.y)])
print("#",Polygon(B,C,D,E).area)
# 39/10

ver1.3

・2つの円が見えます。

# ver1.3
from sympy import *
AB,AE=3,1
B,A,E=map(Point,[(0,0),(AB,0),(AB,-AE)])
Ad   =Circle(B,AB).intersection(Circle(E,AE))[0]  #;print(Ad)
C,D  =map(Point,[(0,Ad.y),(AB,Ad.y)])
print("#",Polygon(B,C,D,E).area)
# 39/10

ver1.4

・??? polygonのreflectが、Triangleになりました。

# ver1.4
from sympy import *
def reflect_polygon(polygon, mirror_line):
    """
    polygon     : sympy.geometry.Polygon
    mirror_line : sympy.geometry.Line
    return      : 線対称移動後の Polygon
    """
    new_vertices = []

    for P in polygon.vertices:
        H = mirror_line.projection(P)   # 垂線の足
        P_ref = Point(2*H.x - P.x, 2*H.y - P.y)
        new_vertices.append(P_ref)

    return Polygon(*new_vertices)
AB,AE=3,1
B,A,E=map(Point,[(0,0),(AB,0),(AB,-AE)])
Ad   =reflect_polygon(Polygon(B,A,E),Line(B,E)).vertices[1]
C,D  =map(Point,[(0,Ad.y),(AB,Ad.y)])
print("#",Polygon(B,C,D,E).area)
# # 39/10

↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
今日はここまでです。
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

(本日の)ChatGPT先生へ

以下の座標図を教えて下さい。matplotlib による作図で。
(表示省略:verのソースコード)

(matplotlibのソースコードを省略)

FreeCADのマクロを教えて下さい。

(省略)

いつもの自力??? FreeCADのマクロで作図

(省略)

いつもの? sympyの実行環境と 参考のおすすめです。

sympyのweb上での実行方法

SymPy Live Shellで。FreeCADのマクロは、以下で実行できません。
https://qiita.com/mrrclb48z/items/00dd08b0317069be9342#web%E4%B8%8A%E3%81%AE%E5%AE%9F%E8%A1%8C%E6%96%B9%E6%B3%95sympy-live-shell%E3%81%A7

(テンプレート)

いつもと違うおすすめです。

(正方形の)類題

sympy のdoc

ver0.1

ver1.1

・angle_between(l2) < Line
https://docs.sympy.org/latest/modules/geometry/lines.html#sympy.geometry.line.LinearEntity.angle_between

・rotate(angle, pt=None) < Point
https://docs.sympy.org/latest/modules/geometry/points.html#sympy.geometry.point.Point2D.rotate

ver1.2

・projection(other) < Line
https://docs.sympy.org/latest/modules/geometry/lines.html#sympy.geometry.line.LinearEntity.projection

ver1.3

・intersection(o) < Circle
https://docs.sympy.org/latest/modules/geometry/ellipses.html#sympy.geometry.ellipse.Ellipse.intersection

ver1.4

・class sympy.geometry.polygon.Triangle(*args, **kwargs)
https://docs.sympy.org/latest/modules/geometry/polygons.html#sympy.geometry.polygon.Triangle

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?