空间中任意三点,如何转换坐标系使该三点在新坐标系的XY平面内
空间中任意三点,如何转换坐标系使该三点在新坐标系的XY平面内 本帖最后由 作者 于 2007-12-21 12:17:26 编辑 <br /><br /> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">'</font>给定点<font face="Times New Roman">p1,p2,p3<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim p1(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim p2(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim p3(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">''''''''''''''''''''''''''''<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">''''''''''''''''''''''''''''<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim vx(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim vy(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim vz(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim x(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim y(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim z(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim i As Integer<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">'''<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">'</font>矢量<font face="Times New Roman"> vx , vy</font>由点<font face="Times New Roman">p1,p2,p3</font>决定<p></p></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">for i = 0 To 2<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman"><span style="mso-spacerun: yes;"> vx(i)=p2(i)-p1(i)<p></p></font></span></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman"><span style="mso-spacerun: yes;"> vy(i)=p3(i)-p1(i)<p></p></font></span></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Next<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">'UCS</font>坐标系的<font face="Times New Roman">x</font>轴<p></p></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">for i = 0 To 2<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman"><span style="mso-spacerun: yes;"> x(i)=vx(i) <p></p></font></span></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Next<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">'vz = vx X vy<span style="mso-spacerun: yes;"> (</font></span>矢量的外积运算<font face="Times New Roman">)<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">vz(0) = vx(1) * vy(2) - vx(2) * vy(1)<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">vz(1) = vx(2) * vy(0) - vx(0) * vy(2)<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">vz(2) = vx(0) * vy(1) - vx(1) * vy(0)<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">'UCS</font>坐标系的<font face="Times New Roman">z</font>轴<p></p></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">for i = 0 To 2<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman"><span style="mso-spacerun: yes;"> z(i)=vz(i)<p></p></font></span></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Next<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">'UCS</font>坐标系的<font face="Times New Roman">y</font>轴<font face="Times New Roman"><span style="mso-spacerun: yes;"> <p></p></font></span></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">y(0) = z(1) * x(2) - z(2) * x(1)<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">y(1) = z(2) * x(0) - z(0) * x(2)<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">y(2) = z(0) * x(1) - z(1) * x(0)<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">'</font>则,<font face="Times New Roman">UCS</font>坐标系<p></p></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim ucsObj As AcadUCS<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim ucsx(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Dim ucsy(0 To 2) As Double<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">For i = 0 To 2<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman"><span style="mso-spacerun: yes;"> ucsx(i) = p1(i) + x(i)<p></p></font></span></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman"><span style="mso-spacerun: yes;"> ucsy(i) = p1(i) + y(i)<p></p></font></span></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Next<p></p></font></p><p></p><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt;"><font face="Times New Roman">Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(p1, ucsx, ucsy, "UCSName")</font></p> <p>我的思路是这样的:</p><p>空间中的任意三点p1、p2、p3,一直线L1过p1、p2点,另一条直线L2过p3点与直线L1相垂于p4点,</p><p>以p4点为坐标原点,p1(或p2)、P3点分别为x、y轴上的一点,坐标变换。</p> <p>你的思路很好。</p><p>求垂足的方法本论坛也有不少。也不麻烦。</p>
页:
[1]