我正在使用F#绘制f(x) = x^3 - 1的牛顿分形图时遇到了问题。我的程序似乎只绘制了分形图的右下角1/4,什么都没有。由于实际绘制的区域是正确的,我认为问题可能出在表单上位图的表示方式上。
这是我得到的图片链接: https://imgur.com/a/YPSYIk9 迄今为止我想出来的代码:
这是我得到的图片链接: https://imgur.com/a/YPSYIk9 迄今为止我想出来的代码:
open System
open System.Drawing
open System.Windows.Forms
open System.Numerics
let pi = 3.14159265359
let MaxCount = 50
let multCol = 15
let Tol = 0.5
let r1 = Complex(1.0, 0.0)
let r2 = Complex(-0.5, sin(0.66*pi))
let r3 = Complex(-0.5, -sin(0.66 * pi))
let createImage () =
let image = new Bitmap (800, 800,System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
let graphics = Graphics.FromImage(image)
let mutable maxMod = 0.0
for x = 0 to image.Width - 1 do
for y = 0 to image.Height - 1 do
let mutable z = Complex(float x , float y)
let mutable count = 0
while (count < MaxCount && Complex.Abs(z - r1) >= Tol && Complex.Abs(z - r2) >= Tol && Complex.Abs(z - r3) >= Tol) do
if(Complex.Abs(z) > 0.0) then
z <- z - (z*z*z - Complex(1.0,0.0))/(Complex(3.0,0.0) * z * z)
if(Complex.Abs(z) > maxMod) then
maxMod <- Complex.Abs(z)
count <- count + 1
let temp1 = Complex.Abs(z - r1)
let temp2 = Complex.Abs(z - r2)
let temp3 = Complex.Abs(z - r3)
if(Complex.Abs(z - r1) <= Tol) then
let Brush = new System.Drawing.SolidBrush(System.Drawing.Color.Red)
graphics.FillRectangle(Brush, new Rectangle(x,y,1,1))
if(Complex.Abs(z - r2) <= Tol) then
let Brush = new System.Drawing.SolidBrush(System.Drawing.Color.Blue)
graphics.FillRectangle(Brush, new Rectangle(x,y,1,1))
if(Complex.Abs(z - r3) <= Tol) then
let Brush = new System.Drawing.SolidBrush(System.Drawing.Color.Green)
graphics.FillRectangle(Brush, new Rectangle(x,y,1,1))
image.Save("redacted.png")
createImage()
有没有人能给我一些提示,关于问题可能出现的具体情况?