Buchempfehlung
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
"Der" Petzold, das über 1000 Seiten starke Standardwerk zum Win32-API - besonders nützlich u. a. bei der GUI-Programmierung in FreeBASIC! [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

vectorverwaltung, oop, UND operatoren

Uploader:Mitgliedcsde_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