一些有用的数学函数
LISP编程语言中只涵盖了一些数学函数,所以我想我会再介绍一些;; Inverse Sine (ArcSin)
;; Args: -1 <= x <= 1
(defun asin (x)
(cond ((< 1. (abs x)) nil)
((equal (abs x) 1. 1e-9)
(* x (/ pi 2.)))
(t (atan (/ x (sqrt (- 1 (expt x 2))))))))
;; Inverse Cosine (ArcCos)
;; Args: -1 <= x <= 1
(defun acos (x)
(cond ((< 1. (abs x)) nil)
((zerop x) (/ pi 2.))
(t (atan (/ (sqrt (- 1 (expt x 2))) x)))))
;; Hyperbolic Sine (Sinh)
;; Args: Real x
(defun sinh (x)
(/ (- (exp x) (exp (* -1. x))) 2.))
;; Hyperbolic Cosine (Cosh)
;; Args: Real x
(defun cosh (x)
(/ (+ (exp x) (exp (* -1. x))) 2.))
;; Hyperbolic Tangent (Tanh)
;; Args: Real x
(defun tanh (x)
(/ (- (exp (* 2. x)) 1.)
(+ (exp (* 2. x)) 1.)))
;; Inverse Hyperbolic Sine (ArcSinh)
;; Args: Real x
(defun asinh (x)
(log (+ x (sqrt (+ (expt x 2) 1)))))
;; Inverse Hyperbolic Cosine (ArcCosh)
;; Args: x >= 1
(defun acosh (x)
(cond ((< x 1.) nil)
(t (log (+ x (sqrt (- (expt x 2) 1)))))))
;; Inverse Hyperbolic Tangent (ArcTanh)
;; Args: -1 < x < 1
(defun atanh (x)
(cond ((<= 1. (abs x)) nil)
(t (/ (log (/ (+ 1. x) (- 1. x))) 2.))))
;; Fibonnacci Number Generator
;; Args: Natural x
(defun fib (x)
(cond ((or (minusp x)
(not (eq 'INT (type x))))
nil)
(t
(* (/ 1. (sqrt 5.))
(-
(expt (/ (+ 1. (sqrt 5.)) 2.) (1+ x))
(expt (/ (- 1. (sqrt 5.)) 2.) (1+ x)))))))
嗯,我只是为了好玩才加的
但正如罗伯指出的那样,这可能是有用处的 好的,好的!我放弃:斐波那契是有用的 好的,再多说几句-我从theSwamp获得了矩阵转置-一些很棒的编码。
大卫 很好的一个大卫-这个线程将是一个伟大的参考(可能有粘性?) 嗨Rob
看到你对斐波那契函数的回复,在那里你附上了一张图片。你知道如何在cad 3D中绘制扶手蜗壳吗。我试过helyx挤压,但什么都不管用?? 特别感谢李,这对我来说非常有用,因为我不必离开AutoCAD环境(到matlab)再回来 很高兴你能使用它Cadman:wink: Hi Rob
Saw your reply to the Fibonacci function where you attached a picture . Would you have any idea how to draw that handrail volutes in cad 3D . I have tried helyx extrusion and nothing works ??
页:
[1]
2