请教用angle获取的角度值为科学技术法、如何转换为常规角度
本帖最后由 xiaocainiao 于 2024-1-9 18:57 编辑请教一下各位大神!
我用以下代码得到的弧度结果非常大、已经是科学计数法了
(defun c:tt ()
(setq pt1 (getpoint"\n指定第一点"))
(setq pt2 (getpoint pt1 "\n指定第二点"))
(setq ang (angle pt1 pt2))
(print ang)
(princ)
)而实际图中这两点的弧度为0
我想问一下、怎么将这个angle后的弧度结果转换成0~2pi之间、
测试文件已经上传了、求各位大神指点
Command: (setq Val 9.31323e-13)
9.31323e-013
Command: (equal val 0 1e-9)
T
Command: (equal val 0 1e-13)
nil
Command: (equal val 0 1e-12)
T
Determines whether two expressions are equal
(equal expr1 expr2 )
Arguments
expr1
The expression to be compared.
expr2
The expression to compare with expr1.
fuzz
A real number defining the maximum amount by which expr1 and expr2 can differ and still be considered equal.
When comparing two real numbers (or two lists of real numbers, as in points), the two identical numbers can differ slightly if different methods are used to calculate them. You can specify a fuzz amount to compensate for the difference that may result from the different methods of calculation.
本帖最后由 xiaocainiao 于 2024-1-10 08:55 编辑
Andyhon 发表于 2024-1-9 18:14
Command: (setq Val 9.31323e-13)
9.31323e-013
谢谢、这样对比看懂了、但是不明白angle的结果会有误差、我是在开启正交的情况下捕捉的两点 ;; 規整化角度在 0-2pi
(defun p-angle-normal (a / $2pi $4pi $pi/2 $pi/4 $pi3/2)
(setq $pi/4(/ pi 4.)
$pi/2(/ pi 2.)
$pi3/2 (* $pi/2 3.)
$2pi (* pi 2.)
$4pi (* pi 4.)
)
(setq a (rem a $2pi))
(if (< a 0)
(setq a (+ a $2pi))
)
a
) 角度=弧度n*180/π xj6019 发表于 2024-1-9 18:36
;; 規整化角度在 0-2pi
(defun p-angle-normal (a / $2pi $4pi $pi/2 $pi/4 $pi3/2)
(setq $pi/4(/ pi ...
你好、我刚试了一下、这个函数对我这种情况貌似不太管用、余数的结果还是原样 wzg356 发表于 2024-1-9 18:37
角度=弧度n*180/π
我现在得到的是弧度、但是这个弧度值太大了、我想把他转换成0~2pi以内 弧度—(fix(弧度 /2π))*2π wzg356 发表于 2024-1-9 18:59
弧度—(fix(弧度 /2π))*2π
fix不是实数转整数吗、和这个弧度没有啥直接关系吧 xiaocainiao 发表于 2024-1-9 19:05
fix不是实数转整数吗、和这个弧度没有啥直接关系吧
初中知识啊,减掉n个圆周