The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: Farabi on March 11, 2005, 06:34:40 AM

Title: 3D rotation.
Post by: Farabi on March 11, 2005, 06:34:40 AM
Can someone make this function done? I dont understand how to do it.  :dazzled:



RotatingXYZ proc x:dword,y:dword,z:dword,xAng:dword,yAng:dword,zAng:dword
LOCAL xt,yt,zt:dword
LOCAL xt2,yt2,zt2:dword
LOCAL xt3,yt3,zt3:dword




;        Rotate around x-axis                                                  ;
;        YT = Y * COS(xang) - Z * SIN(xang) / 256                              ;
;        ZT = Y * SIN(xang) + Z * COS(xang) / 256                              ;
;        Y = YT                                                                ;
;        Z = ZT                                                                ;
;                                                                              ;


invoke UMGetPosRound,y,xAng
mov yt,edx
invoke UMGetPosRound,z,xAng
sub eax,yt
mov yt,eax

invoke UMGetPosRound,y,xAng
mov zt,eax
invoke UMGetPosRound,z,xAng
add edx,zt
mov zt,edx

;        Rotate around y-axis                                                  ;
;        XT = X * COS(yang) - Z * SIN(yang) / 256                              ;
;        ZT = X * SIN(yang) + Z * COS(yang) / 256                              ;
;        X = XT                                                                ;
;        Z = ZT                                                                ;
;                                                                              ;


invoke UMGetPosRound,x,yAng
mov xt2,edx
invoke UMGetPosRound,z,yAng
sub eax,xt
mov xt2,eax

invoke UMGetPosRound,x,yAng
mov zt2,eax
invoke UMGetPosRound,z,yAng
add edx,zt2
mov zt2,edx

;        Rotate around z-axis                                                  ;
;        XT = X * COS(zang) - Y * SIN(zang) / 256                              ;
;        YT = X * SIN(zang) + Y * COS(zang) / 256                              ;
;        X = XT                                                                ;
;        Y = YT                                                                ;


invoke UMGetPosRound,x,zAng
mov xt3,edx
invoke UMGetPosRound,y,zAng
sub eax,xt3
mov xt3,eax

invoke UMGetPosRound,x,zAng
mov yt3,eax
invoke UMGetPosRound,y,zAng
add edx,yt3
mov yt3,edx


mov edx,xt3
; add edx,xt2

mov eax,yt3
; add eax,yt



xor ecx,ecx
add ecx,500


ret
RotatingXYZ endp