明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1024|回复: 1

[基础] 为什么这两个点会用不同的坐标转换矩阵?

[复制链接]
发表于 2011-8-16 21:04 | 显示全部楼层 |阅读模式
本帖最后由 ywlm 于 2011-8-16 21:05 编辑

注释中第一个矩阵和第二个矩阵必须选择代码中的转换矩阵才行,如果两个都选ed.CurrentUserCoordinateSystem或都选Matrix3d.Identity就不行,这是为什么?
  1.     ''' <summary>
  2.     ''' 由起点和中点绘制直线
  3.     ''' </summary>
  4.     ''' <remarks></remarks>
  5.     Public Class DrawJig_Line
  6.         Inherits DrawJig
  7.         Private ent As Line
  8.         Private sPt As Point3d
  9.         Private ePt As Point3d
  10.         Private funCount As Integer = 1
  11.         <CommandMethod("ll")> _
  12.         Sub DrawLine()
  13.             Dim optFirstPoint As New PromptPointOptions(vbCrLf & "指定中点 或<指定端点>:")
  14.             With optFirstPoint
  15.                 .AllowNone = True
  16.             End With
  17.             Dim resFirstPoint As PromptPointResult = ed.GetPoint(optFirstPoint)
  18.             If resFirstPoint.Status = PromptStatus.None Then
  19.                 optFirstPoint.Message = "指定端点:"
  20.                 resFirstPoint = ed.GetPoint(optFirstPoint)
  21.                 funCount = 2
  22.             End If
  23.             If resFirstPoint.Status <> PromptStatus.OK Then Return
  24.             sPt = resFirstPoint.Value
  25.             sPt = sPt.TransformBy(ed.CurrentUserCoordinateSystem)'===第一个矩阵===
  26.             ePt = sPt
  27.             ent = New Line(sPt, ePt)

  28.             Dim resJigPoint As PromptResult = ed.Drag(Me)
  29.             If resJigPoint.Status = PromptStatus.OK Then
  30.                 AppendEntity(ent)
  31.             End If
  32.             ent.Dispose()
  33.             funCount = 1
  34.         End Sub

  35.         Protected Overrides Function Sampler(ByVal prompts As Autodesk.AutoCAD.EditorInput.JigPrompts) As Autodesk.AutoCAD.EditorInput.SamplerStatus
  36.             Dim Message As String = IIf(funCount = 1, "指定端点:", "指定中点:")
  37.             Dim optJigPoint As New JigPromptPointOptions(vbCrLf & Message)
  38.             With optJigPoint
  39.                 .BasePoint = sPt
  40.                 .UseBasePoint = True
  41.                 .UserInputControls = UserInputControls.Accept3dCoordinates
  42.             End With
  43.             Dim resJigPoint As PromptPointResult = prompts.AcquirePoint(optJigPoint)
  44.             If resJigPoint.Status <> PromptStatus.OK Then Return SamplerStatus.Cancel
  45.             ePt = resJigPoint.Value
  46.             ePt = ePt.TransformBy(Matrix3d.Identity)'===第二个矩阵===

  47.             If sPt = ePt Then Return SamplerStatus.NoChange
  48.             If funCount = 1 Then
  49.                 ent.EndPoint = ePt
  50.                 ent.StartPoint = sPt + (sPt - ePt)
  51.             Else
  52.                 ent.StartPoint = sPt
  53.                 ent.EndPoint = sPt + 2 * (ePt - sPt)
  54.             End If
  55.             Return SamplerStatus.OK
  56.         End Function

  57.         Protected Overrides Function WorldDraw(ByVal draw As Autodesk.AutoCAD.GraphicsInterface.WorldDraw) As Boolean
  58.             draw.Geometry.Draw(ent)
  59.             Return True
  60.         End Function
  61.     End Class

 楼主| 发表于 2011-8-16 21:13 | 显示全部楼层
原来第二个矩阵处的这行代码可以取消,没意义的。
是否可以这样理解:ed.GetPoint获得的是UCS坐标,而prompts.AcquirePoint获得的是WCS坐标?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-3 12:20 , Processed in 0.330130 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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