标题:
巧用对称性,一个陷阱四个球
[打印本页]
作者:
lnszdzg
时间:
2014-5-30 20:57
标题:
巧用对称性,一个陷阱四个球
以往做相切球陷阱时,两个球得做两个陷阱,计算两次,设两个判断;4个球得做4个陷阱,计算4次,设4个判断;8个球得做8个陷阱,计算8次,设8个判断......;计算量很大,速度当然就比较慢。那么能否简化?
可以!利用对称性!
由于做分形目前基本上是用直角坐标系,这就可以利用直角坐标系的对称性简化计算了。
我们知道:点(a,b)关于x轴的对称点是(a,-b),关于y轴的对称点是(-a,b),关于原点的对称点是(-a,-b),
这四个点可以简化成(|a|,|b|),这样四个陷阱:
#1=|(x,y)-(a,b)|,
#2=|(x,y)-(a,b)|,
#3=|(x,y)-(a,b)|,
#4=|(x,y)-(a,b)|,
可以简化为#=|(|x|,|y|)-(a,b)|,这样一个计算可以产生四个球,就是着色不好处理啊。
作者:
lnszdzg
时间:
2014-5-30 21:01
Mathcad下的图形
下载
(34.12 KB)
2014-7-9 10:33
程序
下载
(33.26 KB)
2014-5-30 21:01
图片附件:
New.jpg
(2014-7-9 10:33, 34.12 KB) / 下载次数 2184
http://inrm3d.cn/attachment.php?aid=21764&k=bfc39879ec6e298ca95031b0ae7e8eb1&t=1732397508&sid=ryr61w
图片附件:
捕获141.PNG
(2014-5-30 21:01, 33.26 KB) / 下载次数 2215
http://inrm3d.cn/attachment.php?aid=21765&k=143499a432346153aad97b65e0a0382a&t=1732397508&sid=ryr61w
作者:
lnszdzg
时间:
2014-5-30 21:05
这四个点可以简化成(|a|,|b|),这样四个陷阱:(原帖出现失误,更正再次,抱歉,请原谅)
#1=|(x,y)-(a,b)|,
#2=|(x,y)-(-a,b)|,
#3=|(x,y)-(a,-b)|,
#4=|(x,y)-(-a,-b)|,
作者:
柳烟
时间:
2014-5-30 21:22
UF中的八切球就是用的老兄这个办法
作者:
柳烟
时间:
2014-5-30 21:34
1#
lnszdzg
UF中作色是这样干的,陷阱照老兄这样简化。作色时,设置能把这些球区分开来的判断,并根据这些不同的判断,将这些球进行编号,按编好的号赋于不同的色彩。这在画板中,实现起来也甚易。
作者:
lnszdzg
时间:
2014-5-30 21:56
柳老师,UF中的这个在那个中啊?我想学一下着色。
作者:
lnszdzg
时间:
2014-6-3 09:30
下载
(61.29 KB)
2014-7-9 10:34
图片附件:
New.jpg
(2014-7-9 10:34, 61.29 KB) / 下载次数 2477
http://inrm3d.cn/attachment.php?aid=21804&k=6d19bf44d97068a595b378e4589d9ada&t=1732397508&sid=ryr61w
作者:
lnszdzg
时间:
2014-6-3 09:31
中间好像少了一些啥,可是我加不上。
作者:
guxiaoping
时间:
2014-6-3 09:42
8#
lnszdzg
中问叠加—个M集感觉挺不错的
作者:
柳烟
时间:
2014-6-3 10:26
6#
lnszdzg
下载
(47.82 KB)
2014-6-3 10:26
图片附件:
未命名.JPG
(2014-6-3 10:26, 47.82 KB) / 下载次数 2206
http://inrm3d.cn/attachment.php?aid=21805&k=46117a367e669906765ecd3ab225af93&t=1732397508&sid=ryr61w
作者:
lnszdzg
时间:
2014-6-3 20:25
谢谢柳老师,找到了。我更具Mathcad中的方法改写了一下,基本上保持了原来的结构,但只用了2个陷阱,产生了8个圆.
UF代码
8Circles {
init:
int iter = 0
float rangemun = 0
float num = 4
float Xabs = 0
float Yabs = 0
float Dsgd0 = 0
float Dsgd1 = 0
float Circle = 0
float ZtoPsqd = 0
float Rc = @r
float Phi = #pi * 0.125
float Rm = Rc * sin(Phi)
float RcSqd = Rm^2
bool Trapped = false
loop:
iter = iter + 1
if iter > @skip && !Trapped
Xabs = abs(real(#z))
Yabs = abs(imag(#z))
Dsgd0 = (Xabs-Rc*sin(phi))^2 + (Yabs - Rc*cos(phi))^2
Dsgd1 = (Xabs-Rc*sin(3*phi))^2 + (Yabs - Rc*cos(3*phi))^2
if Dsgd0 < RcSqd
Trapped = true
ZtoPsqd= Dsgd0
Circle = iter
elseif Dsgd1 < RcSqd
Trapped = true
ZtoPsqd= Dsgd1
Circle = iter
endif
endif
final:
if !trapped
#solid = true
else
Circle = ((Circle + @off) % num)/(num-1)
float Ratio = sqrt(ZtoPsqd/Rcsqd)
float ColorIndex = 115 * Ratio + Circle * 140
#index = (ColorIndex + 1) % 256 /256
endif
default:
title = "8 Circles"
param r
caption = "Circle radius"
default = 0.4
endparam
param skip
caption = "Iters to skip"
default = 0
hint = "Iterations to skip."
endparam
param off
caption = "Hue cycle"
default = 0
min = 0
max = 7
hint = "This rotates the coloring order of the balls."
endparam
}
UF效果
下载
(23.09 KB)
2014-7-9 10:34
图片附件:
New.jpg
(2014-7-9 10:34, 23.09 KB) / 下载次数 1344
http://inrm3d.cn/attachment.php?aid=21811&k=2a9e2593e0a53ab3eafb57bc6c046d5c&t=1732397508&sid=ryr61w
作者:
柳烟
时间:
2014-6-3 23:28
老兄改得秒,造这八切圆陷阱更加简单,长了见识,谢谢。
两个陷阱,仅限于这些球关于坐标轴对称情况下,减少成两个陷阱。但如何对各球进行编号,让八个球按编号赋于不同色呢?
作者:
lnszdzg
时间:
2014-6-4 15:04
可以仿照原来的弄。
8Circles2 {
init:
int iter = 0
float rangemun = 0
float x = 0
float y = 0
float num = 8
float Xabs = 0
float Yabs = 0
float Dsgd0 = 0
float Dsgd1 = 0
float Circle = 0
float ZtoPsqd = 0
float Rc = @r
float Phi = #pi * 0.125
float Rm = Rc * sin(Phi)
float RcSqd = Rm^2
bool Trapped = false
loop:
iter = iter + 1
x = real(#z)
y = imag(#z)
if iter > @skip && !Trapped
Xabs = abs(real(#z))
Yabs = abs(imag(#z))
Dsgd0 = (Xabs-Rc*sin(phi))^2 + (Yabs - Rc*cos(phi))^2
Dsgd1 = (Xabs-Rc*sin(3*phi))^2 + (Yabs - Rc*cos(3*phi))^2
if Dsgd0 < RcSqd
Trapped = true
ZtoPsqd= Dsgd0
if Y > 0&& x > 0
Circle = 1
elseif y < 0 && x > 0
Circle = 0
elseif y < 0 && x < 0
Circle = 5
else
Circle = 4
endif
elseif Dsgd1 < RcSqd
Trapped = true
ZtoPsqd= Dsgd1
if Y > 0&& x > 0
Circle = 2
elseif y < 0 && x > 0
Circle = 3
elseif y < 0 && x < 0
Circle = 6
else
Circle = 7
endif
endif
endif
final:
if !trapped
#solid = true
else
Circle = ((Circle + @off) % num)/(num-1)
float Ratio = sqrt(ZtoPsqd/Rcsqd)
float ColorIndex = 120 * Ratio + Circle * 100
#index = (ColorIndex + 1) % 256 /256
endif
default:
title = "8 Circles2"
param r
caption = "Circle radius"
default = 0.4
endparam
param skip
caption = "Iters to skip"
default = 0
hint = "Iterations to skip."
endparam
param off
caption = "Hue cycle"
default = 0
min = 0
max = 7
hint = "This rotates the coloring order of the balls."
endparam
}
下载
(25.09 KB)
2014-7-9 10:35
图片附件:
New.jpg
(2014-7-9 10:35, 25.09 KB) / 下载次数 1380
http://inrm3d.cn/attachment.php?aid=21816&k=188bdf6b140e8548642d41eeb1da3b35&t=1732397508&sid=ryr61w
作者:
lnszdzg
时间:
2014-6-4 15:41
将上文件稍作修改,可以得到:
代码:
8Circles2 {
init:
int iter = 0
float rangemun = 0
float x = 0
float y = 0
float num = 10
float Xabs = 0
float Yabs = 0
float Dsgd0 = 0
float Dsgd1 = 0
float Dsgd2 = 0
float Ratio = 0
float Circle = 0
float ZtoPsqd = 0
float Rc = @r
float Phi = #pi /12
float Rm = Rc * sin(Phi)
float RcSqd = Rm^2
bool Trapped = false
loop:
iter = iter + 1
x = real(#z)
y = imag(#z)
if iter > @skip && !Trapped
Xabs = abs(real(#z))
Yabs = abs(imag(#z))
Dsgd0 = (Xabs-Rc*sin(phi))^2 + (Yabs - Rc*cos(phi))^2
Dsgd1 = (Xabs-Rc*sin(5*phi))^2 + (Yabs - Rc*cos(5*phi))^2
Dsgd2 = abs(abs(x)-abs(y))
if Dsgd0 < RcSqd
Trapped = true
ZtoPsqd= Dsgd0
if Y > 0&& x > 0
Circle = 1
elseif y < 0 && x > 0
Circle = 0
elseif y < 0 && x < 0
Circle = 5
else
Circle = 4
endif
Ratio = sqrt(ZtoPsqd/Rcsqd)
elseif Dsgd1 < RcSqd
Trapped = true
ZtoPsqd= Dsgd1
if Y > 0&& x > 0
Circle = 2
elseif y < 0 && x > 0
Circle = 3
elseif y < 0 && x < 0
Circle = 6
else
Circle = 7
endif
Ratio = sqrt(ZtoPsqd/Rcsqd)
elseif Dsgd2 < 4*RcSqd
trapped = true
ZtoPsqd = 4*Dsgd2
if x > 0
Circle = 9
else
Circle = 8
endif
Ratio = sqrt(0.15*ZtoPsqd/Rcsqd)
endif
endif
final:
if !trapped
#solid = true
else
Circle = ((Circle + @off) % num)/(num-0)
float ColorIndex = 120 * Ratio + Circle * 100
#index = (ColorIndex + 1) % 256 /256
endif
default:
title = "8 Circles2"
param r
caption = "Circle radius"
default = 0.4
endparam
param skip
caption = "Iters to skip"
default = 0
hint = "Iterations to skip."
endparam
param off
caption = "Hue cycle"
default = 0
min = 0
max = 7
hint = "This rotates the coloring order of the balls."
endparam
}
作者:
lnszdzg
时间:
2014-6-4 15:43
标题:
RE: 巧用对称性,一个陷阱四个球
[local]1[/local]
作者:
lnszdzg
时间:
2014-6-4 15:46
下载
(88.44 KB)
2014-6-4 15:46
就是我不会着色,没有蓝色和绿色,不太好看
图片附件:
捕获uf3.jpg
(2014-6-4 15:46, 88.44 KB) / 下载次数 1458
http://inrm3d.cn/attachment.php?aid=21817&k=88f275ab917c698a8960ca24008e43a5&t=1732397508&sid=ryr61w
作者:
lnszdzg
时间:
2014-6-6 16:51
下载
(52.65 KB)
2014-7-9 10:36
下载
(49.28 KB)
2014-7-9 10:37
图片附件:
New.jpg
(2014-7-9 10:36, 52.65 KB) / 下载次数 1400
http://inrm3d.cn/attachment.php?aid=21835&k=9e3143bb6393ed79a7dbb359b3d5b240&t=1732397508&sid=ryr61w
图片附件:
New.jpg
(2014-7-9 10:37, 49.28 KB) / 下载次数 1272
http://inrm3d.cn/attachment.php?aid=21836&k=e867b91119346a5753bd2752c11ada79&t=1732397508&sid=ryr61w
欢迎光临 inRm3D: 画板论坛 (http://inrm3d.cn/)
Powered by Discuz! 7.0.0