5-himmelblau-plot

1. load package

配置 ssao

Code
  using GLMakie
  GLMakie.activate!(ssao=true)
  GLMakie.closeall() 
  fig = Figure(resolution = (800, 800))
  ssao = Makie.SSAO(radius = 5.0, blur = 3)
  ax = LScene(fig[1, 1], scenekw = (ssao=ssao,),show_axis=false)
  ax.scene.ssao.bias[] = 0.025
0.025

2 define bio-variate funciton

2.1 配置函数

  1. make_cubic: plot 小立方体函数
  2. mack_z : 根据传入函数的(x,y)坐标返回值, 即 z坐标值
Code
  make_cubic(;x=0,y=0,h,w)=Rect3f(Vec3f(x,y,0), Vec3f(w,w,h))

  function make_z(func)
   return (x,y)->func(x,y)
  end
make_z (generic function with 1 method)

2.2 二元函数

不限于此

Code
  f(x,y)=cos(x) * sin(y)
f (generic function with 1 method)

3 plot

  1. 可以改变 xs,ys step的值, 增加后, 立方体会变小
  2. box_width=0.19 设置比xs,ys 的间隔小一点, 留出空隙
Code
    xs=range(0,15,50)
    ys=range(0,15,50) 
    box_width=0.19
    function plot_double_integ(funcz)
      local box = [make_cubic(;x=x,y=y,h=funcz(x,y),w=box_width) for x in xs  for y in ys]
      local zs=  [funcz(x,y) for x in xs , y in ys]
      for  i in eachindex(box)
      mesh!(ax, box[i], ssao=true,color=:lightblue)
      wireframe!(ax, box[i]; color = :black, transparency=true)
    end

    #wireframe!(ax,xs,ys,zs,color=(:red,0.8),linewidth=1)
    fig
  end

  make_z(f)|>plot_double_integ