yinzhiw 发表于 2006-7-12 10:28:00

求垂足坐标题

<P>已知点ptStart,ptEnd 为一条直线L的两个端点,坐标为(x1,y1),(x2,y2) <BR>从点pt(x0,y0) 做到直线L 的垂线,求垂足的坐标</P>
<P>谢谢</P>

sjgau4311 发表于 2006-7-12 11:48:00

我以前用 AutoLISP 写过这个程式,很简单的。<BR>你 要不要 自己试试看。<BR><BR>

yinzhiw 发表于 2006-7-12 14:04:00

<P>就是因为没写出来才到这求助的啊</P>
<P>最好用vba</P>

sjgau4311 发表于 2006-7-12 14:06:00

我没有使用过 VBA, 我用 LISP 写,你自己转 如何?<br>

mkhsj928 发表于 2006-7-12 14:28:00

Public Function m_ptCD(m_pt1() As Double, m_pt2() As Double, m_pt3() As Double, m_pt4() As Double)<BR>'给定空间三点pt1,pt2 pt3,求出pt3到直线pt1-pt2的垂足点pt4<BR>&nbsp;&nbsp;&nbsp; Dim m_a As Double, m_b As Double<BR>&nbsp;&nbsp;&nbsp; m_a = Sqr((m_pt2(0) - m_pt1(0)) * (m_pt2(0) - m_pt1(0)) + _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (m_pt2(1) - m_pt1(1)) * (m_pt2(1) - m_pt1(1)) + _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (m_pt2(2) - m_pt1(2)) * (m_pt2(2) - m_pt1(2)))<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; m_b = (m_pt2(0) - m_pt1(0)) * (m_pt3(0) - m_pt1(0)) + _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (m_pt2(1) - m_pt1(1)) * (m_pt3(1) - m_pt1(1)) + _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (m_pt2(2) - m_pt1(2)) * (m_pt3(2) - m_pt1(2))<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; m_a = m_b / (m_a * m_a)<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; m_pt4(0) = m_pt1(0) + (m_pt2(0) - m_pt1(0)) * m_a<BR>&nbsp;&nbsp;&nbsp; m_pt4(1) = m_pt1(1) + (m_pt2(1) - m_pt1(1)) * m_a<BR>&nbsp;&nbsp;&nbsp; m_pt4(2) = m_pt1(2) + (m_pt2(2) - m_pt1(2)) * m_a<BR>End Function

sjgau4311 发表于 2006-7-12 14:50:00

台湾这边 不流行 AutoCAD VBA, 看来 大陆那边的 程度不错。<br>推!<br>

yinzhiw 发表于 2006-7-17 20:31:00

<P>看来版主是台湾的啊</P>
<P>谢谢了</P>

sjgau4311 发表于 2006-7-18 10:31:00

回复:(yinzhiw)看来版主是台湾的啊 ...

五百年前是 一家,同文 同种,不用客气。<BR>最近 比较忙,要到 八月下旬以后才比较 有空,<BR>到时候,会让大家 刮目相看。<BR><BR>

zxq651007z 发表于 2006-7-25 15:19:00

<P>好像不用这么麻烦,捕捉到PT后,直接作垂足就可以了,这样做出来的能保证集合精度</P>

ll_j 发表于 2006-7-27 19:34:00

<P>(defun it(pt0 pts pte)</P>
<P>&nbsp; &nbsp;(inters pt0 (polar pt0 (+ (angle pts pte) (/ pi 2)) 1.0) pts pte nil)</P>
<P>)</P>
页: [1] 2
查看完整版本: 求垂足坐标题