我目前正試圖在vb.net上編寫一個3D圖形引擎(yaay ...),但是使用它來做數學的向量(向量)真的很尷尬,以至於有很多觀點使用它有什麼建議嗎?有沒有簡單的方法在vb中使用矢量?
0
A
回答
2
使用谷歌: 「Vector類VB .NET」
然後找到
http://www.codeproject.com/Articles/20385/3D-Geometry-Library-Basic-Classes-and-3D-Drawing-u
+0
這非常有幫助,非常感謝! – Enderbro
-2
Friend Module Func
''' <summary>
''' Program Function
''' </summary>
''' <remarks></remarks>
#Region "Vector3"
Public va, vb, vc, vd As Single
Public VectorDot1, VectorDot2 As Double
Public vectorAngle As Single
Function CalculateVector(ByVal point1 As Drawing.Point, ByVal point2 As Drawing.Point) As Double
Dim v As Single = 0
va = point2.X - point1.X
vb = point2.X - point1.Y
vc = point2.X - point1.X
vd = point2.Y - point1.Y
v = point2.X - point1.X + point2.Y - point1.Y
Return v
End Function
Function CaluclateDotProduct(ByVal pointv1 As Drawing.Point, ByVal pointv2 As Drawing.Point, ByVal pointv3 As Drawing.Point, ByVal pointv4 As Drawing.Point) As Double
Dim v1, v2 As Double
v1 = CalculateVector(pointv1, pointv2)
v2 = CalculateVector(pointv3, pointv4)
v1 = va * vb + vc * vd
v2 = va * vb + vc * vd
VectorDot1 = v1
VectorDot2 = v2
Return v1 And v2
End Function
Function VectorCrossProduct(ByVal point1 As Drawing.Point, ByVal point2 As Drawing.Point) As Double
Dim v1 As Double = CalculateVector(point1, point2)
Dim v2 As Double = CalculateVector(point1, point2)
Return va * vd - vb * vc
End Function
Function ATan2(ByVal opp As Single, ByVal adj As _
Single) As Single
End Function
Function Vector_Angle(ByVal pointv1 As Drawing.Point, ByVal pointv2 As Drawing.Point, ByVal pointv3 As Drawing.Point, ByVal pointv4 As Drawing.Point) As Double
Dim dotproduct As Double = CaluclateDotProduct(pointv1, pointv2, pointv3, pointv4)
Dim crossproduct As Double = VectorCrossProduct(pointv1, pointv2)
vectorAngle = Math.Atan2(crossproduct, dotproduct)
Return vectorAngle
End Function
#End Region
End Module
Public Class Vector3
Dim id As Integer
Dim name As String
Dim _x, _y As Single
Dim result As Double
Dim _length As Double
Dim _vector As Double
Dim _dotProduct As Double
Dim _crossProduct As Double
Dim _angle As Double
Public ReadOnly Property CrossProduct() As Double
Get
Return _dotProduct
End Get
End Property
Public ReadOnly Property DotProduct() As Double
Get
Return _dotProduct
End Get
End Property
Public ReadOnly Property Vector() As Double
Get
Return _vector
End Get
End Property
Public ReadOnly Property Length() As Double
Get
Return Core.vectorAngle
End Get
End Property
Public WriteOnly Property X() As Single
Set(ByVal value As Single)
Core.va = value
End Set
End Property
Public WriteOnly Property Y() As Single
Set(ByVal value As Single)
Core.vb = value
End Set
End Property
Public Property _Angle_() As Double
Get
Return Me._angle
End Get
Set(ByVal value As Double)
Me._angle = value
End Set
End Property
Sub New(ByVal id As Integer, ByVal name As String, ByVal point1 As Drawing.Point, ByVal point2 As Drawing.Point)
Me.id = id
Me.name = name
_vector = Core.CalculateVector(point1, point2)
End Sub
Public Sub VectorCalculate(ByVal point As Point, ByVal point2 As Point)
Core.CalculateVector(point, point2)
End Sub
Public Sub CalculateVectorLength(ByVal point1 As Drawing.Point, ByVal point2 As Drawing.Point)
_length = Core.CalculateVector(point1, point2)
End Sub
Public Sub Dot_Product(ByVal pointv1 As Drawing.Point, ByVal pointv2 As Drawing.Point, ByVal pointv3 As Drawing.Point, ByVal pointv4 As Drawing.Point)
_dotProduct = Core.CaluclateDotProduct(pointv1, pointv2, pointv3, pointv4)
End Sub
Public Sub Cross_Product(ByVal point1 As Drawing.Point, ByVal point2 As Drawing.Point)
_crossProduct = Core.VectorCrossProduct(point1, point2)
End Sub
Public Sub Angle(ByVal pointv1 As Drawing.Point, ByVal pointv2 As Drawing.Point, ByVal pointv3 As Drawing.Point, ByVal pointv4 As Drawing.Point)
_angle = Core.Vector_Angle(pointv1, pointv2, pointv3, pointv4)
End Sub
相關問題
- 1. 有沒有簡單的方法來使用基類的變量?
- 2. 在Open MPI中使用clang有沒有簡單的方法?
- 3. 矢量優化 - 簡單的方法
- 4. 有沒有簡單的方法來在elisp中調用函數?
- 5. 簡單的VB代碼沒有運行
- 6. 有沒有簡單的方法來使用Facebook的C#SDK?
- 7. 有沒有簡單的方法來使用Common Lisp的Python庫?
- 8. 有沒有更簡單的方法來分配這些變量?
- 9. 有沒有簡單的方法開始使用Twitter Bootstrap?
- 10. 有沒有簡單的方法來使用F#可變結構
- 11. 有沒有什麼簡單的方法來「使用sfFacebookConnect
- 12. 有沒有簡單的方法使用Node.js發送POST請求?
- 13. 有沒有簡單的方法使用zend_pdf打印文本?
- 14. 有沒有簡單的方法使用String.toLowerCase()爲9種語言?
- 15. 有沒有一種簡單的方法使用django禿鷲?
- 16. 有沒有簡單的方法使用Python GAE上
- 17. 有沒有簡單的方法開始使用basscss?
- 18. 有沒有簡單的方法來使用jQuery和Simile Timeplots?
- 19. 有沒有簡單的方法來寫在JavaScript中的Object.defineProperty
- 20. 有沒有簡單的方法在代碼中使用ffmpeg的x264預設?
- 21. 有沒有簡單的方法來獲取li:gt(-1)在jquery中?
- 22. 在Python中,有沒有簡單的方法來編輯xml?
- 23. 有沒有一種簡單的方法在Python中編寫它?
- 24. 有沒有簡單的方法來在java中播放rtmp流?
- 25. 有沒有簡單的方法在JSF中實現路由?
- 26. 有沒有簡單的方法在love2d中繪製漸變?
- 27. 有沒有一個簡單的方法來使用oAuth2沒有AccountManager?
- 28. 有沒有簡單的方法在拉撒路代碼中使用FTP功能
- 29. 在Gnuplot中調整矢量的簡單方法?
- 30. 有沒有簡單的方法來動畫ScrollableControl.ScrollControlIntoView方法?
你可以添加你所使用的代碼的例子嗎? – Sean
是的,當然,我將不得不在現在後發佈我無法訪問我的家用電腦。 – Enderbro
好的,在編輯完成後留下另一條評論,我會收到通知回來看看。 – Sean