fb:porticula NoPaste
Für Achsenmodel_06 Hilfsfunktionen
Uploader: | Volta |
Datum/Zeit: | 24.11.2011 19:21:55 |
'Hilfsfunktionen
'liefern Entfernung 2er Ortsvektoren nach Pythagoras
Function GetDistance(b As vector, d As vector) As Single
'dim as single dx,dy
'dx=d.x - b.x
'dy=d.y - b.y
'function=sqr(dx*dx + dy*dy)
Asm
mov eax, dword Ptr [d]
mov ebx, dword Ptr [b]
fld dword Ptr [eax]
fsub dword Ptr [ebx]
fmul ST(0), ST(0)
fld dword Ptr [eax+4]
fsub dword Ptr [ebx+4]
fmul ST(0), ST(0)
faddp
fsqrt
fstp dword Ptr [Function]
End Asm
End Function
'liefert die globale Richtung(in Bogenmaß) eines Punktes v vom Standpunkt b aus gesehen
Function GetArcus(b As vector,v As vector) As Single
Dim As Single arcus
'Dim As vector d
'd.x= v.x - b.x
'd.y= v.y - b.y
'arcus=ATan2(d.y,d.x)
Asm
mov eax, dword Ptr [v]
mov ebx, dword Ptr [b]
fld dword Ptr [eax+4]
fsub dword Ptr [ebx+4]
fld dword Ptr [eax]
fsub dword Ptr [ebx]
fpatan
fstp dword Ptr [arcus]
End Asm
If Sgn(arcus)=-1 Then arcus= doublepi + arcus
Function=arcus
End Function
'liefert eine Richtung (in Bogenmaß) als Richtungsvektor
Function GetVector(arcus As Single) As vector
Dim As vector v
If arcus>=doublepi Then arcus=arcus-doublepi
If arcus<0 Then arcus=doublepi+arcus
'v.x=Cos(arcus)
'v.y=Sin(arcus)
Asm
fld dword Ptr [arcus]
fsincos 'compute sin AND cos
fstp dword Ptr [v] 'cos -> v.x
fstp dword Ptr [v+4] 'sin -> v.y
End Asm
Function=v
End Function
'******************************************************************************