乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: Bryco

圆范数

[复制链接]

69

主题

875

帖子

15

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1146
发表于 2008-1-2 19:30:10 | 显示全部楼层
谢谢Bryco,我'我来试试,看看进展如何。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2008-1-2 19:32:17 | 显示全部楼层
至于矩阵。您可以使用ucs,因为GetVar已更新
  1. Function UcsM() As Variant
  2.     Dim M(3, 3) As Double
  3.     Dim Orig As Variant
  4.     Orig = ThisDrawing.GetVariable("Ucsorg")
  5.     Dim x, Y, Z
  6.     x = ThisDrawing.GetVariable("UCSXDIR")
  7.     Y = ThisDrawing.GetVariable("UCSYDIR")
  8.     Z = Crossproduct(x, Y)
  9.     M(0, 0) = x(0): M(0, 1) = Y(0): M(0, 2) = Z(0): M(0, 3) = Orig(0)
  10.     M(1, 0) = x(1): M(1, 1) = Y(1): M(1, 2) = Z(1): M(1, 3) = Orig(1)
  11.     M(2, 0) = x(2): M(2, 1) = Y(2): M(2, 2) = Z(2): M(2, 3) = Orig(2)
  12.     M(3, 0) = 0: M(3, 1) = 0: M(3, 2) = 0: M(3, 3) = 1
  13.    
  14.     UcsM = M
  15.    
  16. End Function
  17. 'Vectors
  18. Function XYZ(x As Double, Y As Double, Z As Double) As Variant
  19.     Dim P(2) As Double
  20.     P(0) = x: P(1) = Y: P(2) = Z
  21.     XYZ = P
  22. End Function
  23. Function AddVectors(v1, v2) As Variant
  24.     Dim V3(2) As Double
  25.     V3(0) = v1(0) + v2(0)
  26.     V3(1) = v1(1) + v2(1)
  27.     V3(2) = v1(2) + v2(2)
  28.     AddVectors = V3
  29. End Function
  30. Function SubtractVectors(v1, v2) As Variant
  31.     Dim V3(2) As Double
  32.     V3(0) = v1(0) - v2(0)
  33.     V3(1) = v1(1) - v2(1)
  34.     V3(2) = v1(2) - v2(2)
  35.     SubtractVectors = V3
  36. End Function
  37. Function DotProduct(v1, v2)
  38.     Dim V3(2) As Double
  39.     V3(0) = v1(0) * v2(0)
  40.     V3(1) = v1(1) * v2(1)
  41.     V3(2) = v1(2) * v2(2)
  42.     DotProduct = V3
  43. End Function
  44. Function Crossproduct(A, b) As Variant
  45.     Dim Ax As Double, Ay As Double, Az As Double
  46.     Dim Bx As Double, By As Double, Bz As Double
  47.     Dim Unit As Double
  48.     Dim c(2) As Double
  49.     'get CrossProduct
  50.     Ax = A(0): Ay = A(1): Az = A(2)
  51.     Bx = b(0): By = b(1): Bz = b(2)
  52.    
  53.     c(0) = Ay * Bz - Az * By
  54.     c(1) = Az * Bx - Ax * Bz
  55.     c(2) = Ax * By - Ay * Bx
  56.    
  57.     'Convert to unit normal
  58.     Unit = Sqr(c(0) * c(0) + c(1) * c(1) + c(2) * c(2))
  59.     c(0) = c(0) / Unit: c(1) = c(1) / Unit: c(2) = c(2) / Unit
  60.     Crossproduct = c
  61. End Function
  62. Function NormaliseVector(V As Variant) As Variant
  63.     Dim Unit As Double
  64.     Dim Vn(2) As Double
  65.     Unit = Sqr(V(0) * V(0) + V(1) * V(1) + V(2) * V(2))
  66.     Vn(0) = V(0) / Unit: Vn(1) = V(1) / Unit: Vn(2) = V(2) / Unit
  67.     NormaliseVector = Vn
  68. End Function
米克那里'文本文件中有一些矩阵
逆矩阵很方便,因为它很容易写
回复

使用道具 举报

69

主题

875

帖子

15

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1146
发表于 2008-1-2 19:42:01 | 显示全部楼层
代码不错Bryco!肯定会派上用场的
再次感谢。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2008-1-2 20:00:57 | 显示全部楼层
没有无赖Mick;我想我还是欠你的。
回复

使用道具 举报

69

主题

875

帖子

15

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1146
发表于 2008-1-2 21:42:29 | 显示全部楼层
我不知道'我不知道,但我知道UCS是vba中的一头猪
所有I'我试图做的是保存当前ucs,将ucs设置为world,执行我的魔咒,然后将其设置回。我怎样拥有它#039;应#039;工作,但如果用户选择ucs,我仍然会得到奇怪的结果#039;s矢量与标准ucs…奇怪
  1. Dim ucs As AcadUCS
  2. Set ucs = GetActiveUcs
  3. SetOrthoUCS
  4. ent.TransformBy (ThisDrawing.ActiveUCS.GetUCSMatrix)
  5. ThisDrawing.ActiveUCS = ucs
设置正交ucs将ucs设置为'顶部#039;默认情况下,它应该是#039;世界#039;同时,它也会照顾到它所处的任何环境
It'这没什么大不了的,我可以忍受,只是很烦人。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-5 13:54 , Processed in 0.866113 second(s), 71 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表