明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: gprspda

通过程序计算出来的数值和手动计算的数值不一样,是不是我的程序写错了?

  [复制链接]
 楼主| 发表于 2011-10-22 22:14:42 | 显示全部楼层
Andyhon 发表于 2011-10-22 22:04
(setq α (getangle "\n输入转弯坡度角: "))
==>
  (setq α (getReal "\n输入转弯坡度角: "))

打扰你这么长时间真是不好意思,非常感谢你的帮助
发表于 2011-10-22 22:22:00 | 显示全部楼层
本帖最后由 Andyhon 于 2011-10-23 10:16 编辑

比较版


  1. (defun c:flx (/ p p0 p1 p2 p3 p4 p5 p6 v c h w r1 r2 b1 b2 b3 α e t1)
  2.   (setq v (getReal "\n输入指示空速: "))
  3.   (setq c (getReal "\n输入与ISA的差值: "))
  4.   (setq h (getReal "\n输入高度(米): "))
  5.   (setq w (getReal "\n输入风速: "))
  6.   (setq p (getpoint "\n确定起始点: "))
  7.   (setq α (getAngle "\n输入转弯坡度角: "))
  8.   
  9.   (setq t1 (/ (* v 171233 (expt (- (+ 288 c) (* 0.006496 h)) 0.5))
  10.             (expt (- 288 (* 0.006496 h)) 2.628)
  11.          )
  12.   )

  13.   ;;; 公式是r2=3431*tan(25°)/(π t1).
  14.   ;;; (setq r2 (/ (* 3431 (tan α))  pi t1))
  15.   (setq r2 (/ (* 3431 (/ (sin α) (cos  α))) Pi t1))
  16.   
  17.   (if (> r2 3)
  18.     (setq r2 3)
  19.   )
  20.   
  21.   (setq r1 (/ t1 (* 20 pi r2)))
  22.   (setq p0 (polar p 0 r1))
  23.   (setq e (/ w (* 40 r2)))
  24.   (setq p1 (polar p0 (/ pi 2) e))
  25.   (setq p2 (polar p0 0 e))
  26.   (setq p3 (polar p0 (/ (- pi) 2) e))
  27.   (setq b1 (expt (+ (* r1 r1) (* e e)) 0.5))
  28.   (setq b2 (+ r1 e))
  29.   (setq b3 (+ r1 (* 2 e)))
  30.   (setq p4 (polar p1 (/ pi 2) b1))
  31.   (setq p5 (polar p2 0 b2))
  32.   (setq p6 (polar p3 (/ (- pi) 2) b3))
  33.   
  34.   (setVar "OsMode" 0)


  35.   ;|
  36.   (command "arc" "c" p1 p4 p)
  37.   (command "arc" "c" p2 p5 p4)
  38.   (command "arc" "c" p3 p6 p5)
  39.   |;

  40.   (command "arc" "c" p1 p4 p)
  41.   (setq e1 (entlast))
  42.   (command "arc" "c" p2 p5 p4)
  43.   (setq e2 (entlast))
  44.   (command "arc" "c" p3 p6 p5)
  45.   (setq e3 (entlast))
  46.   
  47.   (command "Pedit" "m" e1 e2 e3 "" "j" "" "")

  48.   (setq fn (open (getfiled "将文件保存为:" "gc.txt" "txt" 1) "w"))
  49.   (write-line (strcat "t1=" (rtos t1)) fn)
  50.   (write-line (strcat "r2=" (rtos r2)) fn)
  51.   (write-line (strcat "r1=" (rtos r1)) fn)
  52.   (write-line (strcat "b1=" (rtos b1)) fn)
  53.   (write-line (strcat "b2=" (rtos b2)) fn)
  54.   (write-line (strcat "b3=" (rtos b3)) fn)
  55.   (close fn)
  56.   (command "_zoom" "0.5X")
  57.   (princ)
  58. )
 楼主| 发表于 2011-10-23 09:49:48 | 显示全部楼层
Andyhon 发表于 2011-10-22 22:22
比较版

谢谢,两个版本运行的结果都是一样的...
有没有一个程序,可以让我画出来的弧连成一个整体?现在画出的弧是分三段的
发表于 2011-10-23 09:57:58 | 显示全部楼层
  (command "arc" "c" p1 p4 p)
  (command "arc" "c" p2 p5 p4)
  (command "arc" "c" p3 p6 p5)


===>
  (command "arc" "c" p1 p4 p)
  (setq e1 (entlast))
  (command "arc" "c" p2 p5 p4)
  (setq e2 (entlast))
  (command "arc" "c" p3 p6 p5)
  (setq e3 (entlast))
  
  (command "Pedit" "m" e1 e2 e3 "" "j" "" "")
 楼主| 发表于 2011-10-23 10:08:56 | 显示全部楼层
Andyhon 发表于 2011-10-23 09:57
(command "arc" "c" p1 p4 p)
  (command "arc" "c" p2 p5 p4)
  (command "arc" "c" p3 p6 p5)

程序运行之后出来的选项应该选哪个?我挨个试了一下,好像都不可以啊
发表于 2011-10-23 10:17:10 | 显示全部楼层
修订了 32#
 楼主| 发表于 2011-10-23 10:25:42 | 显示全部楼层
Andyhon 发表于 2011-10-23 10:17
修订了 32#

太感谢你了,谢谢,终于可以交差了...
 楼主| 发表于 2011-10-23 14:43:17 | 显示全部楼层
Andyhon 发表于 2011-10-23 10:17
修订了 32#

不好意思,还要打扰一下,程序运行之后为什么不能把结果显示在gc.txt这个文件里了?以前还是可以的
发表于 2011-10-23 15:24:55 | 显示全部楼层
这会儿重测正常,
建议您重新启动后再调试
 楼主| 发表于 2011-10-23 15:40:57 | 显示全部楼层
Andyhon 发表于 2011-10-23 15:24
这会儿重测正常,
建议您重新启动后再调试

我重新启动了,按照正常步骤,加载,运行,图形结果正确,但是参数的计算结果没有显示..是不是有什么地方冲突?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-6-9 20:01 , Processed in 0.183387 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表