fb:porticula NoPaste
vectorverwaltung, oop, UND operatoren
Uploader: | csde_rats |
Datum/Zeit: | 23.11.2007 17:16:07 |
Type Vector2D
Declare Property x() As Integer
Declare Property x(i As Integer)
Declare Property y() As Integer
Declare Property y(i As Integer)
Declare Sub xy(i1 As Integer, i2 As Integer)
Private:
_x As Integer
_y As Integer
End Type
Property Vector2D.x() As Integer
Return this._x
End Property
Property Vector2D.x(i As Integer)
this._x = i
End Property
Property Vector2D.y(i As Integer)
this._y = i
End Property
Property Vector2D.y() As Integer
Return this._y
End Property
Sub Vector2D.xy(i1 As Integer, i2 As Integer)
this._x = i1
this._y = i2
End Sub
Type Vector3D
Declare Property x() As Integer
Declare Property x(i As Integer)
Declare Property y() As Integer
Declare Property y(i As Integer)
Declare Property z() As Integer
Declare Property z(i As Integer)
Declare Sub xyz(i1 As Integer, i2 As Integer, i3 As Integer)
Private:
_x As Integer
_y As Integer
_z As Integer
End Type
Property Vector3D.x() As Integer
Return this._x
End Property
Property Vector3D.x(i As Integer)
this._x = i
End Property
Property Vector3D.y(i As Integer)
this._y = i
End Property
Property Vector3D.y() As Integer
Return this._y
End Property
Property Vector3D.z(i As Integer)
this._z = i
End Property
Property Vector3D.z() As Integer
Return this._z
End Property
Sub Vector3D.xyz(i1 As Integer, i2 As Integer, i3 As Integer)
this._x = i1
this._y = i2
this._z = i3
End Sub
Operator +(s1_v2d As Vector2D, s2_v2d As Vector2D) As Vector2D
Dim obj As Vector2D
obj.xy(s1_v2d.x+s2_v2d.x, s1_v2d.y+s2_v2d.y)
Return obj
End Operator
Operator +(s1_v3d As Vector3D, s2_v3d As Vector3D) As Vector3D
Dim obj As Vector3D
obj.xyz(s1_v3d.x+s2_v3d.x, s1_v3d.y+s2_v3d.y, s1_v3d.z+s2_v3d.z)
Return obj
End Operator
Operator -(s1_v2d As Vector2D, s2_v2d As Vector2D) As Vector2D
Dim obj As Vector2D
obj.xy(s1_v2d.x-s2_v2d.x, s1_v2d.y-s2_v2d.y)
Return obj
End Operator
Operator -(s1_v3d As Vector3D, s2_v3d As Vector3D) As Vector3D
Dim obj As Vector3D
obj.xyz(s1_v3d.x-s2_v3d.x, s1_v3d.y-s2_v3d.y, s1_v3d.z-s2_v3d.z)
Return obj
End Operator