Changeset 67
 Timestamp:
 Jan 17, 2007, 4:38:41 AM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Include/abgl.ab
r63 r67 4 4 #include <GL/gl.sbp> 5 5 #include <GL/glu.sbp> 6 7 Type XY_FLOAT 8 x As GLfloat 9 y As GLfloat 10 End Type 11 12 Type XY_DOUBLE 13 x As GLdouble 14 y As GLdouble 15 End Type 16 17 Class Vector2f 18 Public /* constructor */ 19 Sub Vector2f(x As GLfloat, y As GLfloat) 20 This.X=x 21 This.Y=y 22 End Sub 23 24 Public /* destructor */ 25 Sub ~Vector2f() 26 End Sub 27 28 Public /* property */ 29 Function X() As GLfloat 30 Return xy.x 31 End Function 32 Function Y() As GLfloat 33 Return xy.y 34 End Function 35 Sub X(x As GLfloat) 36 xy.x=x 37 End Sub 38 Sub Y(y As GLfloat) 39 xy.y=y 40 End Sub 41 42 Public /* operator */ 43 Sub Operator = (vec As Vector2f) 44 This.X=vec.X 45 This.Y=vec.Y 46 End Sub 47 Function Operator + (vec1 As Vector2f, vec2 As Vector2f) As Vector2f 48 Return Add(vec1,vec2) 49 End Function 50 Function Operator  (vec1 As Vector2f, vec2 As Vector2f) As Vector2f 51 Return Substract(vec1,vec2) 52 End Function 53 /* Function Operator * (vec1 As Vector2f, vec2 As Vector2f) As Vector2f 54 Return Dot(vec1,vec2) 55 End Function 56 */ 57 Function Operator * (vec As Vector2f, sca As GLfloat) As Vector2f 58 Dim ret As Vector2f(vec.X*sca,vec.Y*sca) 59 Return ret 60 End Function 61 Function Operator / (vec As Vector2f, sca As GLfloat) As Vector2f 62 Dim ret As Vector2f(vec.X/sca,vec.Y/sca) 63 Return ret 64 End Function 65 66 67 Public /* method */ 68 Function Add(vec1 As Vector2f, vec2 As Vector2f) As Vector2f 69 Dim ret As Vector2f(vec1.X+vec2.X,vec1.Y+vec2.Y) 70 Return ret 71 End Function 72 Function Distance(vec1 As Vector2f, vec2 As Vector2f) As GLfloat 73 Dim ret As Vector2f 74 ret=vec1vec2 75 Return ret.Magnitude 76 End Function 77 Function Dot(vec1 As Vector2f, vec2 As Vector2f) As GLfloat 78 Return vec1.X*vec2.X+vec1.Y*vec2.Y 79 End Function 80 Function Magnitude() As GLfloat 81 Return Math.Sqrt(This.X^2+This.Y^2) As GLfloat 82 End Function 83 Sub Normalize() 84 Dim ret As Vector2f(This.X/This.Magnitude,This.Y/This.Magnitude) 85 This = ret 86 End Sub 87 Function NormalizedVector() As Vector2f 88 Dim ret As Vector2f(This.X/This.Magnitude,This.Y/This.Magnitude) 89 Return ret 90 End Function 91 Function Substract(vec1 As Vector2f, vec2 As Vector2f) As Vector2f 92 Dim ret As Vector2f(vec1.Xvec2.X,vec1.Yvec2.Y) 93 Return ret 94 End Function 95 Sub Reverse() 96 Dim ret As Vector2f(This.X,This.Y) 97 This = ret 98 End Sub 99 Function ReversedVector() As Vector2f 100 Dim ret As Vector2f(This.X,This.Y) 101 Return ret 102 End Function 103 104 Protected 105 xy As XY_FLOAT 106 End Class 107 108 Class Vector2d 109 Public /* constructor */ 110 Sub Vector2d(x As GLdouble, y As GLdouble) 111 xy.x=x 112 xy.y=y 113 End Sub 114 115 Public /* destructor */ 116 Sub ~Vector2d() 117 End Sub 118 119 Public /* property */ 120 Function X() As GLdouble 121 Return xy.x 122 End Function 123 Function Y() As GLdouble 124 Return xy.y 125 End Function 126 Sub X(x As GLdouble) 127 xy.x=x 128 End Sub 129 Sub Y(y As GLdouble) 130 xy.y=y 131 End Sub 132 133 Public /* operator */ 134 Sub Operator = (vec As Vector2d) 135 This.X=vec.X 136 This.Y=vec.Y 137 End Sub 138 Function Operator + (vec1 As Vector2d, vec2 As Vector2d) As Vector2d 139 Return Add(vec1,vec2) 140 End Function 141 Function Operator  (vec1 As Vector2d, vec2 As Vector2d) As Vector2d 142 Return Substract(vec1,vec2) 143 End Function 144 /* Function Operator * (vec1 As Vector2d, vec2 As Vector2d) As Vector2d 145 Return Dot(vec1,vec2) 146 End Function 147 */ 148 Function Operator * (vec As Vector2d, sca As GLfloat) As Vector2d 149 Dim ret As Vector2d(vec.X*sca,vec.Y*sca) 150 Return ret 151 End Function 152 Function Operator / (vec As Vector2d, sca As GLfloat) As Vector2d 153 Dim ret As Vector2d(vec.X/sca,vec.Y/sca) 154 Return ret 155 End Function 156 157 158 Public /* method */ 159 Function Add(vec1 As Vector2d, vec2 As Vector2d) As Vector2d 160 Dim ret As Vector2d(vec1.X+vec2.X,vec1.Y+vec2.Y) 161 Return ret 162 End Function 163 Function Distance(vec1 As Vector2d, vec2 As Vector2d) As GLfloat 164 Dim ret As Vector2d 165 ret=vec1vec2 166 Return ret.Magnitude 167 End Function 168 Function Dot(vec1 As Vector2d, vec2 As Vector2d) As GLfloat 169 Return vec1.X*vec2.X+vec1.Y*vec2.Y 170 End Function 171 Function Magnitude() As GLfloat 172 Return Math.Sqrt(This.X^2+This.Y^2) As GLfloat 173 End Function 174 Sub Normalize() 175 Dim ret As Vector2d(This.X/This.Magnitude,This.Y/This.Magnitude) 176 This = ret 177 End Sub 178 Function NormalizedVector() As Vector2d 179 Dim ret As Vector2d(This.X/This.Magnitude,This.Y/This.Magnitude) 180 Return ret 181 End Function 182 Function Substract(vec1 As Vector2d, vec2 As Vector2d) As Vector2d 183 Dim ret As Vector2d(vec1.Xvec2.X,vec1.Yvec2.Y) 184 Return ret 185 End Function 186 Sub Reverse() 187 Dim ret As Vector2d(This.X,This.Y) 188 This = ret 189 End Sub 190 Function ReversedVector() As Vector2d 191 Dim ret As Vector2d(This.X,This.Y) 192 Return ret 193 End Function 194 195 Protected 196 xz As XY_DOUBLE 197 End Class 198 6 199 7 200 Type XYZ_FLOAT … … 88 281 xyz As XYZ_DOUBLE 89 282 End Class 283 90 284 91 285 Type RGB_FLOAT
Note: See TracChangeset
for help on using the changeset viewer.