фикс Golang
This commit is contained in:
7
main.go
7
main.go
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/cmplx"
|
"math/cmplx"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -32,7 +33,7 @@ func fractal(size int, depth int, g2 complex128, g3 complex128) string {
|
|||||||
var yi float64 = -2
|
var yi float64 = -2
|
||||||
var xi float64 = -2
|
var xi float64 = -2
|
||||||
|
|
||||||
var code string
|
var code strings.Builder
|
||||||
|
|
||||||
for y := 0; y < size; y++ {
|
for y := 0; y < size; y++ {
|
||||||
zy = float64(y)*(yf-yi)/float64(size-1) + yi
|
zy = float64(y)*(yf-yi)/float64(size-1) + yi
|
||||||
@@ -41,12 +42,12 @@ func fractal(size int, depth int, g2 complex128, g3 complex128) string {
|
|||||||
z = complex(zx, zy)
|
z = complex(zx, zy)
|
||||||
for i := 0; i < depth; i++ {
|
for i := 0; i < depth; i++ {
|
||||||
if cmplx.Abs(z) > 2 {
|
if cmplx.Abs(z) > 2 {
|
||||||
code += strconv.FormatInt(int64(i), 10)
|
code.WriteString(strconv.FormatInt(int64(i), 10))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
z = (cmplx.Pow(z, 4) + g2*cmplx.Pow(z, 2)/2 + 2*g3*z + cmplx.Pow(g2, 2)/16) / (4*cmplx.Pow(z, 3) - g2*z - g3)
|
z = (cmplx.Pow(z, 4) + g2*cmplx.Pow(z, 2)/2 + 2*g3*z + cmplx.Pow(g2, 2)/16) / (4*cmplx.Pow(z, 3) - g2*z - g3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return code
|
return code.String()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user