乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 44|回复: 19

[编程交流] center of pressure (center of

[复制链接]

4

主题

27

帖子

23

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:09:42 | 显示全部楼层 |阅读模式
  1. (defun eea-centroid-curve-lw (pl bl / L)                            ;|*****************************************************************************************by ElpanovEvgeniy*****************************************************************************************Library function.The center of the weight located along a contour of a lwpolyline, having arc segments.As an example, the center of weight of a wire detail!!! For the closed polylines to add the description of a closing segment.pl - list pointbl - list bulgeDate of creation   2000 - 2005 years.Last edit 08.06.2009*****************************************************************************************(setq e  (car (entsel "\n Select LWPOLYLINE "))     pl nil     bl nil) ;_  setq(foreach a (reverse (entget e))(cond ((= (car a) 10) (setq pl (cons (cdr a) pl)))      ((= (car a) 42) (setq bl (cons (cdr a) bl)))) ;_  cond) ;_  foreach(eea-centroid-curve-lw pl bl)*****************************************************************************************(defun c:c2 (/ e bl pl)(setq e (car (entsel)))(foreach a (reverse (entget e)) (cond ((= (car a) 10) (setq pl (cons (cdr a) pl)))       ((= (car a) 42) (setq bl (cons (cdr a) bl))) ) ;_  cond) ;_  foreach(if (= (cdr (assoc 70 (entget e))) 1) (setq pl (reverse (cons (car pl) (reverse pl))))) ;_  if(entmakex (list '(0 . "point")                '(62 . 2)                (cons 10 (eea-centroid-curve-lw pl bl))                (assoc 210 (entget e))          ) ;_  list) ;_  entmakex) ;_  defun*****************************************************************************************|;(setq l 0)(mapcar (Function /) (apply  (function mapcar)  (cons   (function +)   (mapcar    (function     (lambda (p1 p2 b / BB C D S)      (if (zerop b)       (progn (setq d (distance p1 p2)                    l (+ d l)              ) ;_  setq              (mapcar (function (lambda (a b c) (* (/ (+ a b) 2) c))) p1 p2 (list d d))       ) ;_  progn       (progn (setq c  (distance p1 p2)                    bb (* b b)                    d  (/ (* c (atan b) (1+ bb)) b)                    l  (+ d l)                    s  (- (/ 1 (* 4 (atan b))) (/ (- 1 bb) (* 4 b)))              ) ;_  setq              (mapcar (function (lambda (a b c) (* d (+ (/ (+ a b) 2) c))))                      p1                      p2                      (list (* s (- (cadr p2) (cadr p1))) (* s (- (car p1) (car p2))))              ) ;_  mapcar       ) ;_  progn      ) ;_  if     ) ;_  lambda    ) ;_  function    pl    (cdr pl)    bl   ) ;_  mapcar  ) ;_  cons ) ;_  apply (list l l)) ;_  mapcar) ;_  defun
 
Hi, this lisp calculate center of weight for the closed polylines but I have a problem if it is applied a piercing operation on the material how do I calculate the center of weight. I need a lisp (only geometry not region).
 
070947qgw2hr7la2fzash9.png
 
070948j1g5fv57nffcf5bx.png
 
070949z1bb5bqoibblufbo.png
 
Many thanks in advance for your help.
回复

使用道具 举报

14

主题

719

帖子

706

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 06:13:49 | 显示全部楼层
Hi Kaan and welcome to the forums. I added code-tags around your lisp to make it more readable.
回复

使用道具 举报

44

主题

542

帖子

502

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
220
发表于 2022-7-6 06:17:25 | 显示全部楼层
See http://forums.augi.com/showthread.php?5641-Getting-the-centroid-of-closed-polyline for info on finding the centroid.
回复

使用道具 举报

4

主题

27

帖子

23

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:19:55 | 显示全部楼层
I do not want to calculate centroid I want to calculate center of pressure. That is, they are different things. Center of pressure the center of gravity of the perimeter of blank (not the area blank). The above lisp calculates it but How do I calculate that when there is a hole on the figure.
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 06:23:57 | 显示全部楼层
For a 2D object, centroid is the correct term for whatever shape you have.  Have you looked at using REGION, SUBTRACT & MASSPROP?  There is probably a LISP routine floating around that would plot the resultant X-Y point of the centroid, but you can do it manually using cut & paste.
回复

使用道具 举报

6

主题

23

帖子

15

银币

初来乍到

Rank: 1

铜币
33
发表于 2022-7-6 06:28:39 | 显示全部楼层
You can specify center of each polyline, let denote them C1 and C2. The mass of each polyline is proportional to the length, let say L1 and L2. Then the center of the 2 would lay in the middle of C1 and C2, where L1 and L2 get balance.
回复

使用道具 举报

4

主题

27

帖子

23

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:29:40 | 显示全部楼层
070950vyzn4700fhc0anf4.png
 
there is an example for manual calculation. When there is a hole on the figure I need to subtract the length of the perimeter of the hole. Then center of gravity will change. I wonder how a lisp can be written.
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 06:32:43 | 显示全部楼层
Is there some reason you don't want to try this?  Why not try it on your example?
回复

使用道具 举报

4

主题

27

帖子

23

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:35:35 | 显示全部楼层
I tried that but it didn't work.First I used region command then shape has become single with subtract command but above lisp can't calculate it.
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 06:38:50 | 显示全部楼层
Did you try MASSPROP?
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 18:34 , Processed in 0.402425 second(s), 75 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表