Теорема о параллелограмме
This commit is contained in:
80
Горшенин Дмитрий/Param.rkt
Normal file
80
Горшенин Дмитрий/Param.rkt
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#lang racket/base
|
||||||
|
|
||||||
|
(define (square x) (* x x))
|
||||||
|
|
||||||
|
(define (lengths_eq x1 y1 x2 y2 x3 y3 x4 y4)
|
||||||
|
(if (equal? (+ (square(- x1 x2)) (square(- y1 y2)))
|
||||||
|
(+ (square(- x3 x4)) (square(- y3 y4))))
|
||||||
|
(displayln "Lines (1,2) and (3,4) have the same length.")
|
||||||
|
(displayln "Lines (1,2) and (3,4) do not have the same length.")))
|
||||||
|
|
||||||
|
(define (collinear x1 y1 x2 y2 x3 y3)
|
||||||
|
(if (equal? (* (- x1 x2) (- y2 y3)) (* (- y1 y2) (- x2 x3)))
|
||||||
|
#t #f
|
||||||
|
))
|
||||||
|
|
||||||
|
(define (perpendicular x1 y1 x2 y2 x3 y3 x4 y4)
|
||||||
|
(if (equal? (+ (* (- x1 x2) (- x3 x4)) (* (- y1 y2) (- y3 y4))) 0 )
|
||||||
|
#t #f
|
||||||
|
))
|
||||||
|
|
||||||
|
(define (parallel x1 y1 x2 y2 x3 y3 x4 y4)
|
||||||
|
(if (equal? (* (- x1 x2) (- y3 y4)) (* (- y1 y2) (- x3 x4)))
|
||||||
|
(displayln "Lines (1,2) and (3,4) are parallel.")
|
||||||
|
(displayln "Lines (1,2) and (3,4) are not parallel.")))
|
||||||
|
|
||||||
|
|
||||||
|
(define (is_intersection x1 y1 x2 y2 x3 y3 x4 y4 x5 y5)
|
||||||
|
(if (and (equal? (* (- x1 x2) (- y2 y3)) (* (- y1 y2) (- x2 x3)) )
|
||||||
|
(equal? (* (- x1 x4) (- y4 y5)) (* (- y1 y4) (- x4 x5)) ) )
|
||||||
|
(displayln "Lines (2,3) and (4,5) meet at point 1.")
|
||||||
|
(displayln "Lines (2,3) and (4,5) do not intersect at point 1.")))
|
||||||
|
|
||||||
|
(define (is_midpoint x1 y1 x2 y2 x3 y3)
|
||||||
|
(if (and (equal? (* 2 x1) (+ x2 x3)) (equal? (* 2 y1) (+ y2 y3)))
|
||||||
|
(displayln "Point 1 is the midpoint of line (2,3).")
|
||||||
|
(displayln "Point 1 is not the midpoint of line (2,3).")
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
(define (grobner_decide a_x a_y b_x b_y c_x c_y d_x d_y e_x e_y)
|
||||||
|
(if (and (parallel a_x a_y b_x b_y d_x d_y c_x c_y)
|
||||||
|
(parallel a_x a_y d_x d_y b_x b_y c_x c_y)
|
||||||
|
(is_intersection e_x e_y a_x a_y c_x c_y b_x b_y d_x d_y))
|
||||||
|
(begin
|
||||||
|
(lengths_eq a_x a_y e_x e_y e_x e_y c_x c_y)
|
||||||
|
(displayln "This is a parallelogram.")
|
||||||
|
)
|
||||||
|
(displayln "This is not a parallelogram.")
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
(define (grobner_decide_coll a_x a_y b_x b_y c_x c_y d_x d_y e_x e_y)
|
||||||
|
(if (and (parallel a_x a_y b_x b_y d_x d_y c_x c_y)
|
||||||
|
(parallel a_x a_y d_x d_y b_x b_y c_x c_y)
|
||||||
|
(is_intersection e_x e_y a_x a_y c_x c_y b_x b_y d_x d_y)
|
||||||
|
(not (collinear a_x a_y b_x b_y c_x c_y))
|
||||||
|
)
|
||||||
|
(begin
|
||||||
|
(lengths_eq a_x a_y e_x e_y e_x e_y c_x c_y)
|
||||||
|
(displayln "This is a parallelogram.")
|
||||||
|
)
|
||||||
|
(displayln "This is not a parallelogram.")
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
(define (grobner_decide_mid a_x a_y b_x b_y c_x c_y d_x d_y m_x m_y)
|
||||||
|
(if (and (is_midpoint m_x m_y a_x a_y c_x c_y)
|
||||||
|
(not (perpendicular a_x a_y c_x c_y m_x m_y b_x b_y)))
|
||||||
|
(begin
|
||||||
|
(lengths_eq a_x a_y b_x b_y b_x b_y c_x c_y)
|
||||||
|
(displayln "This is a parallelogram.")
|
||||||
|
)
|
||||||
|
(displayln "This is not a parallelogram.")
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(grobner_decide 0 0 1 2 4 2 3 0 2 1)
|
||||||
|
(grobner_decide_coll 0 0 1 2 4 2 3 0 2 1)
|
||||||
|
(grobner_decide_mid 0 0 1 2 4 2 3 0 2 1)
|
||||||
22
Горшенин Дмитрий/README.md
Normal file
22
Горшенин Дмитрий/README.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Теорема о параллелограмме
|
||||||
|
## Ссылка на видеоразбор
|
||||||
|
https://youtu.be/YGmrNKP__bg
|
||||||
|
## Код из сайта
|
||||||
|
START_INTERACTIVE;;
|
||||||
|
(grobner_decide ** originate)
|
||||||
|
<<is_midpoint(m,a,c) /\ perpendicular(a,c,m,b)
|
||||||
|
==> lengths_eq(a,b,b,c)>>;;
|
||||||
|
|
||||||
|
#Parallelogram theorem
|
||||||
|
|
||||||
|
grobner_decide ** originate)
|
||||||
|
<<parallel(a,b,d,c) /\ parallel(a,d,b,c) /\
|
||||||
|
is_intersection(e,a,c,b,d)
|
||||||
|
==> lengths_eq(a,e,e,c)>>;;
|
||||||
|
|
||||||
|
(grobner_decide ** originate)
|
||||||
|
<<parallel(a,b,d,c) /\ parallel(a,d,b,c) /\
|
||||||
|
is_intersection(e,a,c,b,d) /\ ~collinear(a,b,c)
|
||||||
|
==> lengths_eq(a,e,e,c)>>;;
|
||||||
|
END_INTERACTIVE;;
|
||||||
|
|
||||||
Reference in New Issue
Block a user