求作直角三角形,已知角平分线长
题目如下。几何画法没有思考用高飞鸟大师的代码解一元三次方程可以画出这个三角形
;;已知直角三角形的两个锐角的角平分线的长度,在cad中画出这个直角三角形 命令tt
;;解一元三次方程的代码是高飞鸟大师的,再此表示感谢
;|*********************************************************************************************;
软件作者: Highflybird ;
软件用途: 为AutoCAD 的LISP定制的一些算法和函数 ;
日期地点: 2012.12.29 深圳 ;
**********************************************************************************************|;
;;;----------------------------------------------------;
;;;一元二次方程的解 ;
;;;f(x) = a*x^2+b*x+c = 0 ;
;;;Input: the coefficients a, b, c are real numbers ;
;;;Output: when a /= 0,one or Two solutions,all of them;
;;; like this: (x y),means: x + y * i,if it's a ;
;;; real number,then y = 0. ;
;;; Otherwise , return a real number or nil ;
;;;Ref: http://en.wikipedia.org/wiki/Quadratic_equation;
;;;----------------------------------------------------;
(defun Math:Quadratic_Equation (a b c / d e g)
(if (zerop a)
(if (not (zerop b))
(list (list (/ (- c) (float b)) 0))
)
(progn
(setq a (float a))
(if (not (equal a 1 1e-14))
(setq b (/ b a)
c (/ c a)
)
)
(setq d (- (* b b) (* 4 c)))
(setq e (* b -0.5))
(cond
( (equal d 0 1e-14)
(list (list e 0) (list e 0))
)
( (> d 0)
(setq g (* (sqrt d) -0.5))
(list (list (- e g) 0) (list (+ e g) 0))
)
( (< d 0)
(setq g (* (sqrt (- d)) -0.5))
(list (list e (- g)) (list e g))
)
)
)
)
)
;;;----------------------------------------------------;
;;;一元三次方程的解 ;
;;;f(x) = a*x^3+b*x^2+c*x+d = 0 ;
;;;Input: the coefficients a, b, c, d are real numbers ;
;;;Output: when a /= 0,Three solutions,all of them like;
;;; this: (x y),means: x + y * i,if it's a real ;
;;; number,then y = 0; ;
;;; otherwise goto "Math:Quadratic_Equation" ;
;;;Ref: http://en.wikipedia.org/wiki/Cubic_function ;
;;;----------------------------------------------------;
(defun Math:Cubic_Equation (a b c d / e f g h u w x y)
(cond
( (zerop a)
(Math:Quadratic_Equation b c d)
)
( (zerop d)
(cons '(0 0) (Math:Quadratic_Equation a b c))
)
(t
(setq b (/ b a 3.0))
(setq c (/ c a 6.0))
(setq d (/ d a 2.0))
(setq e (- (* b (- (+ c c c) (* b b))) d)) ;Alpha
(setq f (- (* b b) c c)) ;Beta
(setq g (- (* e e) (* f f f))) ;Delta,The nature of the roots
(cond
( (equal g 0 1e-14)
(setq u (MATH:CubeRoot e))
(list (list (- (+ u u) b) 0.0)
(list (- (+ b u)) 0.0)
(list (- (+ b u)) 0.0)
)
)
( (> g 0)
(setq h (sqrt g))
(setq u (MATH:CubeRoot (+ e h)))
(setq w (MATH:CubeRoot (- e h)))
(setq x (- (+ b (* (+ u w) 0.5))))
(setq y (* (sqrt 3) (- u w) 0.5))
(list (list (+ u w (- b)) 0)
(list x y)
(list x (- y))
)
)
( (< g 0)
(setq x (/ e f (sqrt f)))
(setq y (sqrt (abs (- 1 (* x x)))))
(setq u (/ (atan y x) 3))
(setq w (/ (+ pi pi) 3))
(setq h (* 2 (sqrt f)))
(list (list (- (* (cos u) h) b) 0)
(list (- (* (cos (+ u w)) h) b) 0)
(list (- (* (cos (- u w)) h) b) 0)
)
)
)
)
)
)
;;;----------------------------------------------------;
;;;立方根(为解三次和四次方程编写,因为expt函数第一个参;
;;;数不能为负数) ;
;;;输入:x 实数 ;
;;;输出:x 的立方根 ;
;;;----------------------------------------------------;
(defun MATH:CubeRoot (x)
(if (< x 0)
(- (expt (- x) 0.33333333333333333333333))
(expt x 0.33333333333333333333333)
)
)
;;-------------画三角形主程序----------------
(defun c:tt(/ A AB AC ANG1 ANG1J ANG2 ANG2J B BC C JIE M N XS ZHI)
(setq m (getdist "\n输入m的值"))
(setq n (getdist "\n输入n的值"))
(setq xs(-(* (* 2 (sqrt 2)) (/ mn)) 1))
(setq jie(Math:Cubic_Equation 1 1 xs-1))
(setq zhi(caar(vl-remove-if-not '(lambda(x)(= 0 (cadr x))) jie )))
(setq ang1(* 2 (atan zhi))) ;(* ang1 (/ 180 pi))
(setq ang1j(* ang1 (/ 180 pi)) )
(setq ang2(- (* 0.5 pi) ang1))
(setq ang2j(* ang2 (/ 180 pi)))
(setq BC(/(* m (cos (atan zhi))) (cos (* 2 (atan zhi)))))
(setq AB(* BC (cos (* 2 (atan zhi)))))
(setq AC(* BC (sin (* 2 (atan zhi)))))
(list AB AC BC ang1 ang2)
(setq B(getpoint"\n 点击确定B点位置"))
(setq C(list (+(car B) BC) (cadr B) 0))
(setq A (polar B ang1 AB))
(vl-cmdf "pline" B C A "c")
(list "两直角边、斜边和两锐角的值分别为:" AB AC BC ang1j ang2j)
)
化简得到一个一元三次方程,估计是无法尺规做图吧。 将定长改成特定数值,有尺规解。
chenmik 发表于 2025-8-23 13:40
将定长改成特定数值,有尺规解。
https://tieba.baidu.com/p/5572485584?share=9105&fr=sharewise&see_lz=0&share_from=post&sfc=copy&client_type=2&client_version=12.87.1.1&st=1755933692&is_video=false&unique=7E88BACB450CA969831315C95584D3B3
这个之前有人发过,最后要解一个三次方程,好在可以因式分解。 本帖最后由 mahuan1279 于 2025-8-23 16:13 编辑
chenmik 发表于 2025-8-23 13:40
将定长改成特定数值,有尺规解。
tan(∠B/2)=1/2
页:
[1]