; "Roslers Attractor", an example of Chaos
; Solves the differential equations:
; dx/dt = -(y + z)
; dy/dt = x + (y/5)
; dz/dt = 1/5 + z*(x-5.7)
; These equations are integrated numerically by the finite
; increment method. i.e
; x(n)=x(n-1)+dt*x'(n-1); y(n)=y(n-1)+dt*y'(n-1); z(n)=z(n-1)+dt*z'(n-1)
; where x',y' and z' are the x,y & z derivatives and dt is a small time
; increment.
; x,y & z are the 3 orthogonal dimensions. t is time
; Ron Thomas Ron_Thom@Compuserve.com 15/5/99
;---------------------------------------------
;The Rosler Attractor
;This is graphical demo which reproduces the clasic "Rosler Attractor". It solves three
;differential equations to compute the orbit created by the chaotic attractor.
;Try resizing the window and you will see a completely different orbit each time !
;Enjoy
;Ron Thomas
;Ron_Thom@Compuserve.com
;www.rbthomas.freeserve.co.uk
;15/5/99
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;以上是原作者的说明,
;这是我从国外(俄国)的一个网站下载的。
;本文是关于混沌学的。
;第一次运行本程序,在上方与右方有的地方会显示不出来,改变窗口的大小后会显示正常。
;这个程序我存放半年多了,特放出来与需要的人共享。
;QQ:112426112
;Email:leguanyuan at 126 dot com
;Homepage:http://correy.webs.com
;以下是我改编的代码:
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
include gdi32.inc
includelib gdi32.lib
.code
hInstance dd 0
hWinMain dd 0
szClassName db "made by correy",0
pwndclassex dd 48,3,offset liuchunli,0,0,0,0,0,6,0,offset szClassName,0
stMsg MSG <>
cxClient DD ?
cyClient DD ?
npoints DD 64000 ; No of points in orbit
xx DD ? ; Coordinates of point to be plotted
yy DD ?
x_offset DD ? ; Screen offsets
y_offset DD ?
scaleX DD ? ; Scaling factors
scaleY DD ?
h real4 0.005 ;Time step
x real4 -10.0
y real4 -1.0
z real4 -1.0
x_new real4 ? ; New orbit coords (F.P values)
y_new real4 ? ;
z_new real4 ? ;
five real4 5.0
fiveP7 real4 5.7
fifth real4 0.2
liuchunli proc uses ebx edi esi,hWnd,uMsg,wParam,lParam
LOCAL hdc:HDC, ps:PAINTSTRUCT
.if uMsg == WM_CLOSE;放置后面会反应更快点。
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,0
.elseif uMsg == WM_SIZE
mov eax,lParam
and eax,0FFFFh
mov cxClient,eax
shr eax,1
mov x_offset,eax ; Compute offset
mov ecx,24 ; Compute scaling factor
mov eax,cxClient
mov edx,0
div ecx
mov scaleX,eax
mov ebx,lParam
shr ebx,16
mov cyClient,ebx
shr ebx,1
mov y_offset,ebx
mov ecx,22 ; Compute scaling factor
mov eax,cyClient
mov edx,0
div ecx
mov scaleY,eax
.elseif uMsg == WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
finit ;Initialise the coprocessor
mov esi,0
.WHILE esi < npoints
fld y ;Y
fadd z ;Y + Z
fchs ;-(y+z)
fmul h
fadd x ;x + h*(-(y+z))
fstp x_new ;
fld y
fdiv five ; y/5
fadd x ; x+(y/5)
fmul h
fadd y ;Y+H*(x+(y/5))
fstp y_new
fld x
fsub fiveP7 ; x-5.7
fmul z ; z(x-5.7)
fadd fifth ; 1/5 +z(x-5.7)
fmul h ; h*(1/5+z(x-5.7))
fadd z ;
fstp z_new ;
fld x_new
fst x ;Update X
fimul scaleX
fiadd x_offset
fistp xx ;Convert to integer
fld y_new
fst y ;Update Y
fimul scaleY
fiadd y_offset
fistp yy
fld z_new
fstp z ;Update Z
invoke SetPixel, hdc, xx, yy, 255 ;Plot orbit in red pixels @ coords xx,yy
inc esi
.ENDW
invoke EndPaint,hWnd, ADDR ps
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret;不能去掉。
.endif
xor eax,eax;这两行可以去掉?
ret
liuchunli endp
start: invoke GetModuleHandle,0
mov hInstance,eax
mov pwndclassex+20,eax
invoke LoadCursor,0,32512;加载箭头鼠标。
mov pwndclassex+28,eax
invoke RegisterClassEx,addr pwndclassex
invoke CreateWindowEx,200h,offset szClassName,offset szClassName,0Cf0000h,80000000h,80000000h,710,530,0,0,hInstance,0;0Ca0000h
mov hWinMain,eax
invoke ShowWindow,hWinMain,1;若不想显示,此行也可以去掉。
again:invoke GetMessage,addr stMsg,0,0,0
cmp eax,0
je exit
invoke DispatchMessage,addr stMsg
jmp again
exit:invoke ExitProcess,0
end start
;made at 2011.09.24
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; "Roslers Attractor", an example of Chaos, presented as a pseudo 3D display.
; Solves the differential equations:
; dx/dt = -(y + z)
; dy/dt = x + (y/5)
; dz/dt = 1/5 + z*(x-8.0) ; Force periodicity in attractor by using
; 8.0 in place of the classic value of 5.7
; where x,y & z are the 3 orthogonal dimensions. t is time
; These equations are integrated numerically by the finite
; increment method. i.e
; x(n)=x(n-1)+dt*x'(n-1); y(n)=y(n-1)+dt*y'(n-1); z(n)=z(n-1)+dt*z'(n-1)
; where x',y' and z' are the x,y & z derivatives and dt is a small time
; increment.
; x,y & z are the 3 orthogonal dimensions. t is time
; Ron Thomas Ron_Thom@Compuserve.com 15/5/99
;---------------------------------------------
;The Rosler Attractor
;This is graphical demo which reproduces the clasic "Rosler Attractor". It solves three
;differential equations to compute the orbit created by the chaotic attractor.
;Try resizing the window and you will see a completely different orbit each time !
;Enjoy
;Ron Thomas
;Ron_Thom@Compuserve.com
;www.rbthomas.freeserve.co.uk
;15/5/99
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;以上是原作者的说明,
;这是我从国外(俄国)的一个网站下载的。
;注意这个程序太耗cpu,可以按任意键停止高速运行。
;这个程序我存放半年多了,特放出来与需要的人共享。
;QQ:112426112
;Email:leguanyuan at 126 dot com
;Homepage:http://correy.webs.com
;以下是我改编的代码:
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
include gdi32.inc
includelib gdi32.lib
.code
hInstance dd 0
hWinMain dd 0
szClassName db "made by correy",0
pwndclassex dd 48,3,offset liuchunli,0,0,0,0,0,6,0,offset szClassName,0
stMsg MSG <>
cxClient DD ?
cyClient DD ?
npoints DD 64000 ; No of points in orbit
colour DD ? ; Pixel colour
xx DD ? ; Coordinates of point to be plotted
yy DD ?
x_offset DD ? ; Screen offsets
y_offset DD ?
scaleX DD ? ; Scaling factors
scaleY DD ?
count db 0
delta real4 0.005 ;Time step
x real4 -10.0
y real4 -1.0
z real4 -1.0
x_new real4 ? ; New orbit coords (F.P values)
y_new real4 ? ;
z_new real4 ? ;
C1 real4 8.0 ; Constant to force periodic oscillation
five real4 5.0
fifth real4 0.2
x2 DD ?
y2 DD ?
RGB MACRO red, green, blue ;; Get composite number from red green and blue bytes
mov al,blue ;; ,,,blue
shl eax,8 ;; ,,blue,
add al,green ;; ,,blue,green
shl eax,8 ;; ,blue,green,
add al,red ;; ,blue,green,red
and eax,0FFFFFFh ;; Mask out top byte to complete COLORREF dword
ENDM
liuchunli proc uses ebx edi esi,hWnd,uMsg,wParam,lParam
LOCAL hdc:HDC, ps:PAINTSTRUCT, msg:MSG
.if uMsg == WM_CLOSE;放置后面会反应更快点。
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,0
.elseif uMsg == WM_SIZE
mov eax,lParam
and eax,0FFFFh
mov cxClient,eax
shr eax,1
mov x_offset,eax ; Compute offset
mov ecx,80 ; Compute scaling factor
mov eax,cxClient
mov edx,0
div ecx
mov scaleX,eax
mov ebx,lParam
shr ebx,16
mov cyClient,ebx
shr ebx,2
mov y_offset,ebx
mov ecx,80 ; Compute scaling factor
mov eax,cyClient
mov edx,0
div ecx
mov scaleY,eax
RGB 255,0,0
mov colour,eax
.elseif uMsg == WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
finit ;Initialise the coprocessor
.WHILE TRUE ; Loop until breakout
mov esi,0
.WHILE esi < npoints
fld y ;Y
fadd z ;Y + Z
fchs ;-(y+z)
fmul delta
fadd x ;x + delta*(-(y+z))
fstp x_new ;
fld y
fdiv five ; y/5
fadd x ; x+(y/5)
fmul delta
fadd y ;Y+delta*(x+(y/5))
fstp y_new
fld x
fsub C1 ; x-C
fmul z ; z(x-C)
fadd fifth ; 1/5 +z(x-C)
fmul delta ; delta*(1/5+z(x-C))
fadd z ;
fstp z_new ;
fld x_new
fst x ;Update X
fimul scaleX ;Make a bigger image
fiadd x_offset
fistp xx ;Convert to integer
fld y_new
fst y ;Update Y
fadd z ; Lump together to give a simulated
; view of the attractor from an angle
; of 45 degrees
fimul scaleY
fiadd y_offset
fistp yy
fld z_new
fstp z ;Update Z
invoke SetPixel, hdc, xx, yy, colour ;Plot orbit in red pixels @ coords xx,yy
inc esi
.IF count==16 ; Change pixel colour every 16 pixels plotted
inc colour
mov count,0
.ELSE
inc count
.ENDIF
.ENDW
shl colour,8
invoke PeekMessage, ADDR msg, hWnd, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE
.IF eax!=0
.BREAK ; Escape loop if we detect a keypress
.ENDIF
.ENDW
invoke EndPaint,hWnd, ADDR ps
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret;不能去掉。
.endif
xor eax,eax;这两行可以去掉?
ret
liuchunli endp
start: invoke GetModuleHandle,0
mov hInstance,eax
mov pwndclassex+20,eax
invoke LoadCursor,0,32512;加载箭头鼠标。
mov pwndclassex+28,eax
invoke RegisterClassEx,addr pwndclassex
invoke CreateWindowEx,200h,offset szClassName,offset szClassName,0Cf0000h,80000000h,80000000h,710,530,0,0,hInstance,0;0Ca0000h
mov hWinMain,eax
invoke ShowWindow,hWinMain,1;若不想显示,此行也可以去掉。
again:invoke GetMessage,addr stMsg,0,0,0
cmp eax,0
je exit
invoke DispatchMessage,addr stMsg
jmp again
exit:invoke ExitProcess,0
end start
;made at 2011.09.24
没有评论:
发表评论