分享

测量线段角度

 h_jtao 2021-11-13

前端时间发过,由于某个原因,已经找不回来了。再次分享给大家。
allegro好像不能直接测量线段的角度。由于近期发现一些不规则的板子,比如圆形outline。
布局时,也可能需要按任意角度摆放,这就需要涉及到按一定的角度来放置。
所以就简单弄了个工具,如果大家觉得有用,就收藏一下。。。。


  1. axlCmdRegister("line_degree" 'line_degree ?cmdType "interactive")

  2. defun(line_degree ()

  3. let((line slop)

  4.         axlUIConfirm("\307\353\321\241\324\361\320\350\322\252\262\342\301\277\265\304Cline/Line!")

  5.         axlSetFindFilter(?enabled '(noall clinesegs linesegs) ?onButtons        '(noall clinesegs linesegs))

  6.         axlSingleSelectPoint()

  7.         line = car(axlGetSelSet())

  8.         axlClearSelSet()

  9.         when(line        

  10.         axlHighlightObject(line)

  11.         slop = axlLineSlope(line->startEnd)

  12.         if(slop

  13.                 then

  14.                         axlUIConfirm(sprintf(nil "Degree : %.2f" axlRadToDeg(atan(slop))))

  15.                 else

  16.                         axlUIConfirm("Degree : 90.0")

  17.         )

  18.         axlDehighlightObject(line)

  19.         )

  20. )

  21. );end defun

复制代码

其实代码很简单,核心语句就是axlRadToDeg(atan(axlLineSlope(line->startEnd))),axlRadToDeg函数只能在16.6及以上版本使用。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多