📄 wall2d.vb
字号:
'// Desc: class to create and render 2D walls. Defined as the two
'// vectors A - B with a perpendicular normal.
Imports SteeringVB.Transformations
Public Class Wall2D
Dim m_vA As New Vector2D
Dim m_vB As New Vector2D
Dim m_vN As New Vector2D
Protected Sub CalculateNormal()
Dim temp As Vector2D = Vector2D.Vec2DNormalize(m_vB.Minus(m_vA))
m_vN.x = -temp.y
m_vN.y = temp.x
End Sub
Public Sub New(ByVal A As Vector2D, ByVal B As Vector2D)
m_vA = A
m_vB = B
CalculateNormal()
End Sub
Public Sub New(ByVal A As Vector2D, ByVal B As Vector2D, ByVal N As Vector2D)
m_vA = A
m_vB = B
m_vN = N
End Sub
'Wall2D(std::ifstream& in){Read(in);}
Public Overridable Sub Render(ByVal g As Graphics, ByVal RenderNormals As Boolean)
g.DrawLine(Pens.Blue, New Point(m_vA.x, m_vA.y), New Point(m_vB.x, m_vB.y))
If RenderNormals Then
Dim MidX As Integer = ((m_vA.x + m_vB.x) / 2)
Dim MidY As Integer = ((m_vA.y + m_vB.y) / 2)
g.DrawLine(Pens.Blue, MidX, MidY, MidX + CInt(m_vN.x * 5), MidY + CInt(m_vN.y * 5))
End If
End Sub
Public Property From()
Get
Return m_vA
End Get
Set(ByVal Value)
m_vA = Value
End Set
End Property
Public Property ToB()
Get
Return m_vB
End Get
Set(ByVal Value)
m_vB = Value
End Set
End Property
Public Property Normal()
Get
Return m_vN
End Get
Set(ByVal Value)
m_vN = Value
End Set
End Property
Public ReadOnly Property Center() As Vector2D
Get
Return (m_vA.Plus(m_vB)).Divided(2.0)
End Get
End Property
'std::ostream& Wall2D::Write(std::ostream& os)const
'{
'os << std::endl;
'os << From() << ",";
'os << To() << ",";
'os << Normal();
'return os;
'}
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -