用lisp语言写一段cad提取坐标代码

好的,这是用 Lisp 语言写的一段 CAD 提取坐标的代码。这段代码假设已经有了一个名为 "points" 的列表,其中包含了若干个点的坐标(x, y):

(defun extract-coordinates (points)
  (mapcar #'(lambda (point)
              (cons (car point) (cdr point)))
          points))
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,这是一段使用 Lisp 语言CAD 提取坐标代码示例: ``` (defun extract-coordinates (entities) "Extract the coordinates of the given entities." (mapcar (lambda (e) (entity-coordinates e)) entities)) (defun entity-coordinates (entity) "Return the coordinates of the given entity." (cond ((point-entity-p entity) (point-coordinates entity)) ((line-entity-p entity) (line-coordinates entity)) ((arc-entity-p entity) (arc-coordinates entity)) ((circle-entity-p entity) (circle-coordinates entity)) (t (error "Unsupported entity type: ~a" entity)))) (defun point-coordinates (point) "Return the coordinates of the given point." (point-position point)) (defun line-coordinates (line) "Return the coordinates of the start and end points of the given line." (list (line-start-point line) (line-end-point line))) (defun arc-coordinates (arc) "Return the coordinates of the center and end points of the given arc." (list (arc-center arc) (arc-end-point arc))) (defun circle-coordinates (circle) "Return the coordinates of the center and a point on the circumference of the given circle." (list (circle-center circle) (point-on-circle circle))) ``` 这段代码定义了一个 `extract-coordinates` 函数,它接受一个参数 `entities`,表示要提取坐标的实体列表。函数内部调用了 `mapcar` 函数,将列表中的每个实体都传递给 `entity-coordinates` 函数,然后将每个实体的坐标提取出来,最终将所有实体的坐标组成的列表返回。 `entity-coordinates` 函数利用 `cond` 语句,根据实体的类型调用相应的函数提取坐标。例如,如果实体是点,则调用 `point-coordinates` 函数;如果实体是线,则调用 `line-coordinates` 函数,以此类
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值