Changeset 72
 Timestamp:
 Jan 20, 2007, 5:09:10 AM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Include/abgl.ab
r67 r72 144 144 /* Function Operator * (vec1 As Vector2d, vec2 As Vector2d) As Vector2d 145 145 Return Dot(vec1,vec2) 146 End Function 147 */ 146 End Function*/ 147 148 148 Function Operator * (vec As Vector2d, sca As GLfloat) As Vector2d 149 149 Dim ret As Vector2d(vec.X*sca,vec.Y*sca) … … 161 161 Return ret 162 162 End Function 163 Function Distance(vec1 As Vector2d, vec2 As Vector2d) As GL float163 Function Distance(vec1 As Vector2d, vec2 As Vector2d) As GLdouble 164 164 Dim ret As Vector2d 165 165 ret=vec1vec2 166 166 Return ret.Magnitude 167 167 End Function 168 Function Dot(vec1 As Vector2d, vec2 As Vector2d) As GL float168 Function Dot(vec1 As Vector2d, vec2 As Vector2d) As GLdouble 169 169 Return vec1.X*vec2.X+vec1.Y*vec2.Y 170 170 End Function 171 Function Magnitude() As GL float172 Return Math.Sqrt(This.X^2+This.Y^2) As GL float171 Function Magnitude() As GLdouble 172 Return Math.Sqrt(This.X^2+This.Y^2) As GLdouble 173 173 End Function 174 174 Sub Normalize() … … 242 242 End Sub 243 243 244 Public /* operator */ 245 Sub Operator = (vec As Vector3f) 246 This.X=vec.X 247 This.Y=vec.Y 248 End Sub 249 Function Operator + (vec1 As Vector3f, vec2 As Vector3f) As Vector3f 250 Return Add(vec1,vec2) 251 End Function 252 Function Operator  (vec1 As Vector3f, vec2 As Vector3f) As Vector3f 253 Return Substract(vec1,vec2) 254 End Function 255 /* Function Operator * (vec1 As Vector3f, vec2 As Vector3f) As Vector3f 256 Return Dot(vec1,vec2) 257 End Function*/ 258 Function Operator ^ (vec1 As Vector3f, vec2 As Vector3f) As Vector3f 259 Return Cross(vec1,vec2) 260 End Function 261 262 Function Operator * (vec As Vector3f, sca As GLfloat) As Vector3f 263 Dim ret As Vector3f(vec.X*sca,vec.Y*sca) 264 Return ret 265 End Function 266 Function Operator / (vec As Vector3f, sca As GLfloat) As Vector3f 267 Dim ret As Vector3f(vec.X/sca,vec.Y/sca) 268 Return ret 269 End Function 270 271 272 Public /* method */ 273 Function Add(vec1 As Vector3f, vec2 As Vector3f) As Vector3f 274 Dim ret As Vector3f(vec1.X+vec2.X,vec1.Y+vec2.Y,vec1.Zvec2.Z) 275 Return ret 276 End Function 277 Function Cross(vec1 As Vector3f, vec2 As Vector3f) As Vector3f 278 Dim ret As Vector3f(vec1.Y*vec2.Zvec1.Z*vec2.Y,vec1.Z*vec2.Xvec1.X*vec2.Z,vec1.X*vec2.Yvec1.Y*vec2.X) 279 Return ret 280 End Function 281 Function Distance(vec1 As Vector3f, vec2 As Vector3f) As GLfloat 282 Dim ret As Vector3f 283 ret=vec1vec2 284 Return ret.Magnitude 285 End Function 286 Function Dot(vec1 As Vector3f, vec2 As Vector3f) As GLfloat 287 Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z 288 End Function 289 Function Magnitude() As GLfloat 290 Return Math.Sqrt(This.X^2+This.Y^2+This.Z^2) As GLfloat 291 End Function 292 Sub Normalize() 293 Dim ret As Vector3f(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude) 294 This = ret 295 End Sub 296 Function NormalizedVector() As Vector3f 297 Dim ret As Vector3f(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude) 298 Return ret 299 End Function 300 Function Substract(vec1 As Vector3f, vec2 As Vector3f) As Vector3f 301 Dim ret As Vector3f(vec1.Xvec2.X,vec1.Yvec2.Y,vec1.Zvec2.Z) 302 Return ret 303 End Function 304 Sub Reverse() 305 Dim ret As Vector3f(This.X,This.Y,This.Z) 306 This = ret 307 End Sub 308 Function ReversedVector() As Vector3f 309 Dim ret As Vector3f(This.X,This.Y,This.Z) 310 Return ret 311 End Function 312 244 313 Protected 245 314 xyz As XYZ_FLOAT … … 258 327 End Sub 259 328 329 260 330 Public /* property */ 261 331 Function X() As GLdouble … … 277 347 xyz.z=z 278 348 End Sub 349 350 351 Public /* operator */ 352 Sub Operator = (vec As Vector3d) 353 This.X=vec.X 354 This.Y=vec.Y 355 End Sub 356 Function Operator + (vec1 As Vector3d, vec2 As Vector3d) As Vector3d 357 Return Add(vec1,vec2) 358 End Function 359 Function Operator  (vec1 As Vector3d, vec2 As Vector3d) As Vector3d 360 Return Substract(vec1,vec2) 361 End Function 362 /* Function Operator * (vec1 As Vector3d, vec2 As Vector3d) As Vector3d 363 Return Dot(vec1,vec2) 364 End Function*/ 365 Function Operator ^ (vec1 As Vector3d, vec2 As Vector3d) As Vector3d 366 Return Cross(vec1,vec2) 367 End Function 368 369 Function Operator * (vec As Vector3d, sca As GLdouble) As Vector3d 370 Dim ret As Vector3d(vec.X*sca,vec.Y*sca) 371 Return ret 372 End Function 373 Function Operator / (vec As Vector3d, sca As GLdouble) As Vector3d 374 Dim ret As Vector3d(vec.X/sca,vec.Y/sca) 375 Return ret 376 End Function 377 378 379 Public /* method */ 380 Function Add(vec1 As Vector3d, vec2 As Vector3d) As Vector3d 381 Dim ret As Vector3d(vec1.X+vec2.X,vec1.Y+vec2.Y,vec1.Zvec2.Z) 382 Return ret 383 End Function 384 Function Cross(vec1 As Vector3d, vec2 As Vector3d) As Vector3d 385 Dim ret As Vector3d(vec1.Y*vec2.Zvec1.Z*vec2.Y,vec1.Z*vec2.Xvec1.X*vec2.Z,vec1.X*vec2.Yvec1.Y*vec2.X) 386 Return ret 387 End Function 388 Function Distance(vec1 As Vector3d, vec2 As Vector3d) As GLdouble 389 Dim ret As Vector3d 390 ret=vec1vec2 391 Return ret.Magnitude 392 End Function 393 Function Dot(vec1 As Vector3d, vec2 As Vector3d) As GLdouble 394 Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z 395 End Function 396 Function Magnitude() As GLdouble 397 Return Math.Sqrt(This.X^2+This.Y^2+This.Z^2) As GLdouble 398 End Function 399 Sub Normalize() 400 Dim ret As Vector3d(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude) 401 This = ret 402 End Sub 403 Function NormalizedVector() As Vector3d 404 Dim ret As Vector3d(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude) 405 Return ret 406 End Function 407 Function Substract(vec1 As Vector3d, vec2 As Vector3d) As Vector3d 408 Dim ret As Vector3d(vec1.Xvec2.X,vec1.Yvec2.Y,vec1.Zvec2.Z) 409 Return ret 410 End Function 411 Sub Reverse() 412 Dim ret As Vector3d(This.X,This.Y,This.Z) 413 This = ret 414 End Sub 415 Function ReversedVector() As Vector3d 416 Dim ret As Vector3d(This.X,This.Y,This.Z) 417 Return ret 418 End Function 419 279 420 280 421 Protected … … 327 468 End Sub 328 469 470 Public /* operator */ 471 472 ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした 473 ' Drawwing\Color.abをさらに参考にしました。 474 Function GetHue() As GLfloat 475 Dim max As GLfloat, min As GLfloat, d As GLfloat 476 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b) 477 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b) 478 d = max  min 479 If rgb.g = max Then 480 Return ((rgb.b  rgb.r) As Double / d * 1.0*_System_PI/3.0 + 2.0*_System_PI/3.0) As GLfloat 481 ElseIf rgb.b = max Then 482 Return ((rgb.r  rgb.g) As Double / d * 1.0*_System_PI/3.0 + 4.0*_System_PI/3.0) As GLfloat 483 ElseIf rgb.g < rgb.b Then 484 Return ((rgb.g  rgb.b) As Double / d * 1.0*_System_PI/3.0 + 6.0*_System_PI/3.0) As GLfloat 485 Else 486 Return ((rgb.g  rgb.b) As Double / d * 1.0*_System_PI/3.0) As GLfloat 487 EndIf 488 End Function 489 490 Function GetSaturation() As GLfloat 491 Dim max As GLfloat, min As GLfloat 492 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b) 493 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b) 494 Return (max  min) / max 495 End Function 496 497 Function GetBrightness() As GLfloat 498 Dim max As GLfloat 499 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b) 500 Return max 501 End Function 329 502 Protected 330 503 rgb As RGB_FLOAT
Note: See TracChangeset
for help on using the changeset viewer.