Lee Mac 发表于 2022-7-6 09:54:53

好的,首先让我为糟糕的图表道歉——用纸笔表达数学比用AutoCAD容易得多。。。
 
我认为问题可以归结为通过将面积(红线)划分为以下两个长度(标记为黄色和绿色):
 
http://www.lee-mac.com/files/Im1.png
 
在确定了这些长度后,可以计算上图中红线的长度(使用毕达哥拉斯),然后我得到了计算形成有界区域的两个直角三角形的面积所需的所有长度。
 
首先,要计算绿线的长度:
 
http://www.lee-mac.com/files/Im2.png
 
注意,主对角线的长度为sqrt(2),从左下角到圆中心的线段长度为(sqrt(2)*r)(由毕达哥拉斯在“r”上绘制)。
 
因此,主对角线减去较小的线段是由我们的绿色长度和半径形成的三角形的斜边。
 
现在,使用毕达哥拉斯,我可以求解格林长度。
 
对于黄色长度:
 
http://www.lee-mac.com/files/Im3.png
 
首先,我计算从圆心到右上角的直线,以及从右上角到使用直角三角形三角形与圆相切的直线所形成的角度。
 
利用主对角线和正方形侧面之间的角度为pi/4,并且两条切线垂直的事实,我可以推断出标记为“θ”的角度(在右侧)。
 
然后,使用平行线(正方形的边)的规则,我知道标记为“θ”的两个角度是相同的。
 
现在,由于角度θ所包含的三角形是等腰三角形,我可以通过在其中一个三角形上使用直角三角来获得黄色长度,半径和角度θ/2。
 
对于这两种长度,可以通过计算两个直角三角形的面积并将这些面积相加来求解面积。
 
在LISP中(我用一点代数简化了一些表达式):
 

(defun AreaCalc ( r / side1 side2 side3 area1 area2 )

(setq side1 (- (sqrt (+ (- (* r r) (* 4. r)) 2.)) r)
       side2 (+ r (/ r (tan (+ (/ pi 8.) (* 0.5 (asin (/ r (* (sqrt 2.) (- 1. r)))))))))
       side3 (sqrt (1- (+ (* side1 side1) (* side2 side2))))
       area1 (* 0.5 side1 side2)
       area2 (* 0.5 side3)
)
(+ area1 area2)
)

(defun tan ( x )
(if (not (equal 0. (cos x) 1e-) (/ (sin x) (cos x)))
)

(defun asin ( x )
(if (<= (abs x) 1.)
   (if (equal (abs x) 1. 1e-
   (* x pi 0.5)
   (atan x (sqrt (- 1. (* x x))))
   )
)
)

SEANT 发表于 2022-7-6 09:58:12

这个挑战接受了类似的治疗。我经常想,在CADTutor,这也会是一个很好的挑战。
http://www.theswamp.org/index.php?topic=12578.0

eldon 发表于 2022-7-6 09:59:03

考虑到LISP论坛对这个帖子的兴趣相对较低,也许值得在不同的论坛板上发布一个链接,这样那些不经常访问LISP论坛的人就可以意识到这个挑战并参与进来?
 
编辑:我看你已经有了

SEANT 发表于 2022-7-6 10:04:27

就我个人而言,我只需点击“最新消息”,然后查看任何具有有趣主题的内容。所以对于我来说,发布到哪个论坛部分并不重要。
 
我还没有在沼泽注册(有些链接需要你注册),因为它似乎没有CADTutor那么吸引人,而且有点复杂,所以我可能错过了很多。

Lee Mac 发表于 2022-7-6 10:05:33

 
哦,我明白了——我倾向于去LISP论坛看看有什么新东西,然后四处看看,所以我想知道其他成员是否坚持使用他们最喜欢的论坛板。
 
 
TheSwamp与CADTutor有着不同的氛围,并且更加面向编程。我更喜欢这里的一些线程,因为大多数成员都是经验丰富且非常聪明的程序员;相比之下,对于那些刚开始使用LISP的人来说,这里的LISP论坛更像是一个“初学者”论坛。我并不是说theSwamp没有初学者,但更多的是,我们在CADTutor这里看到的经验丰富的程序员数量并不相同。无论如何,这只是我的想法,不要读太多-我确实喜欢参加这两个论坛。

SEANT 发表于 2022-7-6 10:08:24

哇!
 
我确实喜欢把事情复杂化。
 
新方法:
 
该方法源于一个奇怪的事实,即超大三角形的面积(由上面Sean建议的单位平方和半径的对角线导出)等于1-2r,恰好是较小三角形的一条边的长度(由超大直角三角形上的毕达哥拉斯导出):
 

 
然而,由于在计算中使用了超大三角形的边,引入了难看的平方根,因此计算较小三角形面积的方法在一定程度上破坏了这种优雅。我花了很长时间寻找一种方法,该方法不涉及较小三角形内角的三角,因此保留了解决方案的优雅性。

Lee Mac 发表于 2022-7-6 10:13:27

eldon 发表于 2022-7-6 10:17:07

Personally speaking, I just click on "What's New", and look at anything that has an intriguing thread title. So it would not matter to me as to which Forum section something was posted.
 
I have not registered with the Swamp (some links need you to be registered) as it seems a bit less inviting than CADTutor and a bit more complicated to get around, so I probably miss a lot.

Lee Mac 发表于 2022-7-6 10:18:10

 
Oh I see - I tend to go to the LISP forum to see whats new, then look around after that, so I wondered if other members perhaps stuck to their 'favourite' forum boards.
 
 
TheSwamp has a different atmosphere to CADTutor, and is far more programming oriented. I prefer it in that I am challenged more by some of the threads there since most of the members are experienced and very clever programmers; whereas the LISP forum here is more of a 'beginners' forum by comparison, for those just starting out with LISP. I'm not saying that there aren't beginners at theSwamp, but more that we don't see the same number of experienced programmers here at CADTutor. Anyway, that's just my thoughts, don't read too much into it - I do like to participate at both forums.

Lee Mac 发表于 2022-7-6 10:22:44

Wow.
 
I sure do like to complicate things.
 
New method:
 

(defun AreaCalc ( r / x1 x2 ) (setq x1 (- 1 (* 2 r))       x2 (sqrt (+ (* (- r 4) r) 2)) ) (- x1 (* 0.5 x1 x1 (/ (- x2 r) (+ x2 r)))))The method derives from the curious fact that the area of the oversized triangle (derived from the diagonals of the unit square and radius as suggested by Sean above) is equal to 1-2r which just so happens to be the length of a side of the smaller triangle (derived from Pythagoras on the oversized right-angled triangle):
 

 
This elegance is somewhat spoiled however by the method to calculate the area of the smaller triangle, since the sides of the oversized triangle are used in the calculation, which introduces ugly square roots. I strived for quite a while to find a method which didn't involve trig on the interior angle of the smaller triangle and hence retain the elegance of the solution.
页: 1 [2]
查看完整版本: 格式中立挑战