Теорема Симсона

This commit is contained in:
2022-05-12 19:12:08 +03:00
parent c6d0207fa5
commit 512d441517
2 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
# Теорема Симсона
## Ссылка на видеоразбор
https://youtu.be/_ewjiWIH0VY
## Код из книги
START_INTERACTIVE;;
let simson =
<<lengths_eq(o,a,o,b) /\
lengths_eq(o,a,o,c) /\
lengths_eq(o,a,o,d) /\
collinear(e,b,c) /\
collinear(f,a,c) /\
collinear(g,a,b) /\
perpendicular(b,c,d,e) /\
perpendicular(a,c,d,f) /\
perpendicular(a,b,d,g)
==> collinear(e,f,g)>>;;
let vars =
["g_y"; "g_x"; "f_y"; "f_x"; "e_y"; "e_x"; "d_y"; "d_x"; "c_y"; "c_x";
"b_y"; "b_x"; "o_x"]
and zeros = ["a_x"; "a_y"; "o_y"];;
wu simson vars zeros;;

View File

@@ -0,0 +1,38 @@
#lang racket/base
(define (square x) (* x x))
(define (lengths_eq x1 y1 x2 y2 x3 y3)
(if (equal? (+ (square(- x1 x2)) (square(- y1 y2))) (+ (square(- x3 x1)) (square(- y3 y1))))
#t #f
))
(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 (simson o_x o_y a_x a_y b_x b_y c_x c_y d_x d_y e_x e_y f_x f_y g_x g_y)
(if (and
(lengths_eq o_x o_y a_x a_y b_x b_y)
(lengths_eq o_x o_y a_x a_y c_x c_y)
(lengths_eq o_x o_y a_x a_y d_x d_y)
(collinear e_x e_y b_x b_y c_x c_y)
(collinear f_x f_y a_x a_y c_x c_y)
(collinear g_x g_y a_x a_y b_x b_y)
(perpendicular b_x b_y c_x c_y d_x d_y e_x e_y)
(perpendicular a_x a_y c_x c_y d_x d_y f_x f_y)
(perpendicular a_x a_y b_x b_y d_x d_y g_x g_y))
(begin (displayln "3 Points lie on one line.") (collinear e_x e_y f_x f_y g_x g_y)
) (displayln "3 Points do not lie on one line.")
))
(simson 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 )