返回列表 回复 发帖
可能如柳烟老师说的,和z的初始位置有关系。
在as.ufm中,柳老师能把这个代码给彻底简化一下吗(只要留下放倒的M集的变换,越简单越好,那些判断函数与函数都不要,我想它能否邦助解决原扫描线扫描3D图形):
Deviation-Mandelbrot {
;Thanks to Gilles Nadeau for the rotation.
;Andrea Spinozzi(July2005)
;v_Beta1.2

Init:

  complex z=c1=c2=(0.0,0.0)
  complex z1=z2=z5=(0.0,0.0)
  rotx=@rotx
  roty=@roty
  rotz=@rotz
  rotw=@rotw

  if (@mode == "Mandelbrot")
    complex z1=real(@start)
    complex z2=imag(@start)
    complex c1=real(pixel)
    complex c2=imag(pixel)
  elseif (@mode == "Julia")
    complex z1=real(pixel)
    complex z2=imag(pixel)
    complex c1=real(@seed)
    complex c2=imag(@seed)
  endif

    z=z1+flip(z2)
    c=c1+flip(c2)

    ry=imag(z)*cos(pi*rotx/180)-real(c)*sin(pi*rotx/180)
    rz=imag(z)*sin(pi*rotx/180)+real(c)*cos(pi*rotx/180)
    z=real(z)+ry*1i
    c=rz+imag(c)*1i

    rx=real(c)*sin(pi*roty/180)+real(z)*cos(pi*roty/180)
    rz=real(c)*cos(pi*roty/180)-real(z)*sin(pi*roty/180)
    z=rx+imag(z)*1i
    c=rz+imag(c)*1i

    ry=real(z)*cos(pi*rotz/180)-imag(c)*sin(pi*rotz/180)
    rw=real(z)*sin(pi*rotz/180)+imag(c)*cos(pi*rotz/180)
    z=ry+imag(z)*1i
    c=real(c)+rw*1i

    rx=imag(c)*sin(pi*rotw/180)+imag(z)*cos(pi*rotw/180)
    rw=imag(c)*cos(pi*rotw/180)-imag(z)*sin(pi*rotw/180)
    z=real(z)+rx*1i
    c=real(c)+rw*1i

    z1=real(z)
    z2=imag(z)
    c1=real(c)
    c2=imag(c)

Loop:

  a=z1*z1
  b=z2*z2
  d=z1*z2

  a=@fn5(a+flip(real(p4)))^@p6
  b=@fn6(b+flip(imag(p4)))^@p7
  d=@fn7(d+flip(real(@p8)))^@p10

  z3=(a*p5-b*@p9)*p2
  z4=d*p1

  if (@op==0)
   z5=b*p3
  elseif (@op==1)
   z5=d*p3
  elseif (@op==2)
   z5=d+b*p3
  elseif (@op==3)
   z5=d-b*p3
  elseif (@op==4)
   z5=d*b*p3
  elseif (@op==5)
   z5=d+a*p3
  elseif (@op==6)
   z5=d-a*p3
  elseif (@op==7)
   z5=d*a*p3
  elseif (@op==8)
   z5=a*p3
  elseif (@op==9)
   z5=a+b*p3
  elseif (@op==10)
   z5=a-b*p3
  elseif (@op==11)
   z5=b-a*p3
  elseif (@op==12)
   z5=b*a*p3
  elseif (@op==13)
   z5=a-d*p3
  elseif (@op==14)
   z5=b-d*p3
  endif

   z5=(z5+flip(imag(@p8)))

  if (@op2==0)
  if (@op1==0)
   z1=fn1(z3-z5)+fn3(c1)
   z2=fn2(z4-z5)+fn3(c2)
  elseif (@op1==1)
   z1=fn1(z3+z5)+fn3(c1)
   z2=fn2(z4-z5)+fn3(c2)
  elseif (@op1==2)
   z1=fn1(z3-z5)+fn3(c1)
   z2=fn2(z4+z5)+fn3(c2)
  elseif (@op1==3)
   z1=fn1(z3+z5)+fn3(c1)
   z2=fn2(z4+z5)+fn3(c2)
  endif
  elseif (@op2==1)
  if (@op1==0)
   z1=fn1(z3-z5)+fn3(c1)
   z2=fn2(z4-z5)-fn3(c2)
  elseif (@op1==1)
   z1=fn1(z3+z5)+fn3(c1)
   z2=fn2(z4-z5)-fn3(c2)
  elseif (@op1==2)
   z1=fn1(z3-z5)+fn3(c1)
   z2=fn2(z4+z5)-fn3(c2)
  elseif (@op1==3)
   z1=fn1(z3+z5)+fn3(c1)
   z2=fn2(z4+z5)-fn3(c2)
  endif
  elseif (@op2==2)
  if (@op1==0)
   z1=fn1(z3-z5)*fn3(c1)
   z2=fn2(z4-z5)+fn3(c2)
  elseif (@op1==1)
   z1=fn1(z3+z5)*fn3(c1)
   z2=fn2(z4-z5)+fn3(c2)
  elseif (@op1==2)
   z1=fn1(z3-z5)*fn3(c1)
   z2=fn2(z4+z5)+fn3(c2)
  elseif (@op1==3)
   z1=fn1(z3+z5)*fn3(c1)
   z2=fn2(z4+z5)+fn3(c2)
  endif
  elseif (@op2==3)
  if (@op1==0)
   z1=fn1(z3-z5)+fn3(c1)
   z2=fn2(z4-z5)*fn3(c2)
  elseif (@op1==1)
   z1=fn1(z3+z5)+fn3(c1)
   z2=fn2(z4-z5)*fn3(c2)
  elseif (@op1==2)
   z1=fn1(z3-z5)+fn3(c1)
   z2=fn2(z4+z5)*fn3(c2)
  elseif (@op1==3)
   z1=fn1(z3+z5)+fn3(c1)
   z2=fn2(z4+z5)*fn3(c2)
  endif
  endif

  if (@flavor==0)
   z=fn4(z1)-flip(z2)
  elseif (@flavor==1)
   z=fn4(z1)+flip(z2)
  endif

Bailout:

  |z1|+|z2|<=@bailout

Default:

title="Deviation-Mandelbrot"
method=multipass
periodicity=0
maxiter=1000

Heading
  caption="Mandelbrot Mode"
  visible=@mode==0
Endheading
Heading
  caption="Julia Mode"
  visible=@mode==1
Endheading
param mode
  caption="current Mode"
  default=0
  enum="Mandelbrot" "Julia"
  visible=false
endparam
param switchMode
  caption="Switch Mode"
  default=1
  enum="Mandelbrot" "Julia"
  visible=false
endparam


param bailout
  caption="Bailout Value"
  default=128.0
endparam
param flavor
  caption="Flavor"
  enum="1""2"
  default=0
endparam
func fn4
  caption="Function Flavor"
  default=ident()
endfunc
param rotx
  caption="Rotation x"
  default=0.0
endparam
param roty
  caption="Rotation y"
  default=0.0
endparam
param rotz
  caption="Rotation z"
  default=0.0
endparam
param rotw
  caption="Rotation w"
  default=0.0
endparam


Heading
  caption="Formula Parameters"
Endheading
param start
  caption="Start z"
  default=(0.0,0.0)
  visible=(@mode=="Mandelbrot")
endparam
param seed
  caption="Seed Value"
  default=(0.0,0.0)
  visible=(@mode=="Julia")
endparam
param op
  caption="Operator 1"
  enum="1""2""3""4""5""6""7""8""9""10""11""12""13""14""15"
  default=0
endparam
param op1
  caption="Operator 2"
  enum="1""2""3""4"
  default=0
endparam
param op2
  caption="Operator 3"
  enum="1""2""3""4"
  default=0
endparam
param p4
  caption="Parameter 1"
  default=(0.0,0.0)
endparam
param p8
  caption="Parameter 2"
  default=(0.0,0.0)
endparam
param p1
  caption="Multiply 1"
  default=(2.0,0.0)
endparam
param p2
  caption="Multiply 2"
  default=(1.0,0.0)
endparam
param p3
  caption="Multiply 3"
  default=(1.0,0.0)
endparam
param p5
  caption="Multiply 4"
  default=(1.0,0.0)
endparam
param p9
  caption="Multiply 5"
  default=(1.0,0.0)
endparam
param p6
  caption="Exponent 1"
  default=(1.0,0.0)
endparam
param p7
  caption="Exponent 2"
  default=(1.0,0.0)
endparam
param p10
  caption="Exponent 3"
  default=(1.0,0.0)
endparam


Heading
  caption="Functions"
Endheading
func fn1
  caption="Function 1"
  default=ident()
endfunc
func fn2
  caption="Function 2"
  default=ident()
endfunc
func fn5
  caption="Function 3"
  default=ident()
endfunc
func fn6
  caption="Function 4"
  default=ident()
endfunc
func fn7
  caption="Function 5"
  default=ident()
endfunc
func fn3
  caption="Function C"
  default=ident()
endfunc
param version
  caption="Version"
  default=1.2
  visible=false
endparam


Switch:

type="Deviation-Mandelbrot"
bailout=@bailout
seed=#pixel
op=@op
op1=@op1
op2=@op2
flavor=@flavor
p1=@p1
p2=@p2
p3=@p3
p4=@p4
p5=@p5
p6=@p6
p7=@p7
p8=@p8
p9=@p9
p10=@p10
rotx=@rotx
roty=@roty
rotz=@rotz
rotw=@rotw
fn1=@fn1
fn2=@fn2
fn3=@fn3
fn4=@fn4
fn5=@fn5
fn6=@fn6
fn7=@fn7
mode=@switchmode
switchmode=@mode
version=@version

}

捕获.JPG (27.72 KB)

捕获.JPG

我可以试试,简化代码要花时间,因为误删一句或一个字符,可能导致扫不出图。我整出后,将代码帖在此,等待……
缩水成这样了,不知是不是你要的效果:
Deviation-Mandelbrot {

Init:

  rotx=@rotx
  roty=@roty
  rotz=@rotz
  rotw=@rotw

    complex z1=real(@start)
    complex z2=imag(@start)
    complex c1=real(pixel)
    complex c2=imag(pixel)

    z=z1+flip(z2)
    c=c1+flip(c2)

    ry=imag(z)*cos(pi*rotx/180)-real(c)*sin(pi*rotx/180)
    rz=imag(z)*sin(pi*rotx/180)+real(c)*cos(pi*rotx/180)
    z=real(z)+ry*1i
    c=rz+imag(c)*1i

    rx=real(c)*sin(pi*roty/180)+real(z)*cos(pi*roty/180)
    rz=real(c)*cos(pi*roty/180)-real(z)*sin(pi*roty/180)
    z=rx+imag(z)*1i
    c=rz+imag(c)*1i

    ry=real(z)*cos(pi*rotz/180)-imag(c)*sin(pi*rotz/180)
    rw=real(z)*sin(pi*rotz/180)+imag(c)*cos(pi*rotz/180)
    z=ry+imag(z)*1i
    c=real(c)+rw*1i

    rx=imag(c)*sin(pi*rotw/180)+imag(z)*cos(pi*rotw/180)
    rw=imag(c)*cos(pi*rotw/180)-imag(z)*sin(pi*rotw/180)
    z=real(z)+rx*1i
    c=real(c)+rw*1i

    z1=real(z)
    z2=imag(z)
    c1=real(c)
    c2=imag(c)

Loop:

  a=z1*z1
  b=z2*z2
  d=z1*z2

  a=(a+flip(real(p4)))^@p6
  b=(b+flip(imag(p4)))^@p7
  d=(d+flip(real(@p8)))^@p10

  z3=(a*p5-b*@p9)*p2
  z4=d*p1
  z5=b*p3


   z1=z3-z5+c1
   z2=z4-z5+c2

   z=z1-z2

Bailout:

  |z1|+|z2|<=@bailout

Default:

title="Deviation-Mandelbrot"
method=multipass
periodicity=0
maxiter=1000

param bailout
  caption="Bailout Value"
  default=128.0
endparam

param rotx
  caption="Rotation x"
  default=0.0
endparam
param roty
  caption="Rotation y"
  default=0.0
endparam
param rotz
  caption="Rotation z"
  default=0.0
endparam
param rotw
  caption="Rotation w"
  default=0.0
endparam

param start
  caption="Start z"
  default=(0.0,0.0)
endparam

param p4
  caption="Parameter 1"
  default=(0.0,0.0)
endparam
param p8
  caption="Parameter 2"
  default=(0.0,0.0)
endparam
param p1
  caption="Multiply 1"
  default=(2.0,0.0)
endparam
param p2
  caption="Multiply 2"
  default=(1.0,0.0)
endparam
param p3
  caption="Multiply 3"
  default=(1.0,0.0)
endparam
param p5
  caption="Multiply 4"
  default=(1.0,0.0)
endparam
param p9
  caption="Multiply 5"
  default=(1.0,0.0)
endparam
param p6
  caption="Exponent 1"
  default=(1.0,0.0)
endparam
param p7
  caption="Exponent 2"
  default=(1.0,0.0)
endparam
param p10
  caption="Exponent 3"
  default=(1.0,0.0)
endparam
param version
  caption="Version"
  default=1.2
  visible=false
endparam

}
215# 柳烟


再认真看一下代码,好象又不是一个通过变换实现放倒M集。那些旋转量都是0是什么意思呢?那些复杂的计算能再化简吗?
我把这些代码都删了,图形还是一样的:
ry=imag(z)*cos(pi*rotx/180)-real(c)*sin(pi*rotx/180)
    rz=imag(z)*sin(pi*rotx/180)+real(c)*cos(pi*rotx/180)
    z=real(z)+ry*1i
    c=rz+imag(c)*1i

    rx=real(c)*sin(pi*roty/180)+real(z)*cos(pi*roty/180)
    rz=real(c)*cos(pi*roty/180)-real(z)*sin(pi*roty/180)
    z=rx+imag(z)*1i
    c=rz+imag(c)*1i

    ry=real(z)*cos(pi*rotz/180)-imag(c)*sin(pi*rotz/180)
    rw=real(z)*sin(pi*rotz/180)+imag(c)*cos(pi*rotz/180)
    z=ry+imag(z)*1i
    c=real(c)+rw*1i

    rx=imag(c)*sin(pi*rotw/180)+imag(z)*cos(pi*rotw/180)
    rw=imag(c)*cos(pi*rotw/180)-imag(z)*sin(pi*rotw/180)
    z=real(z)+rx*1i
    c=real(c)+rw*1i
删掉后,我看了,确实一样。那些旋转量好象是将放倒的M集起扯裂的作用,价值好象不大。
205# 榕坚


终于找到了:

4.JPG (64.17 KB)

4.JPG

请问一下,这M集是不是在网站所给的解析式后加上一个c的M集?z的初始值定位于何处?
220# 柳烟


是的,Z的定位是导函数的零点。
返回列表