心形图案[一]
本帖最后由 jiujiukeji 于 2018-8-21 10:45 编辑<?php
$str = [".",":","-","=","+","*","#","%","@"];
//一个有3d效果的爱心
function f($x, $y, $z) {
$a = $x * $x + 9 / 4 * $y * $y + $z * $z - 1;
return $a * $a * $a - $x * $x * $z * $z * $z - 9 / 80 * $y * $y * $z * $z * $z;
}
function h($x, $z) {
for ($y = 1; $y >= 0; $y -= 0.001)
if (f($x, $y, $z) <= 0)
return $y;
return 0;
}
for ($z = 1.5; $z > -1.5; $z -= 0.05) {
for ($x = -1.5; $x < 1.5; $x += 0.025) {
$v = f($x, 0, $z);
if ($v <= 0) {
$y0 = h($x, $z);
$ny = 0.01;
$nx = h($x + $ny, $z) - $y0;
$nz = h($x, $z + $ny) - $y0;
$nd = 1 / sqrt($nx * $nx + $ny * $ny + $nz * $nz);
$d = ($nx + $ny - $nz) * $nd * 0.5 + 0.5;
echo ($str[(int) ($d * 5)]);
} else
echo ' ';
}
echo "\n";
}
保存成php文件运行,之后鼠标邮件查看源代码
效果图:
能不能写个MATLAB的新型代码{:1_927:} 大神牛逼! 厉害厉害 半只拖鞋 发表于 2018-8-21 10:53
能不能写个MATLAB的新型代码
没学过这个语言 看不懂 心形吸引力不大~弄个S型美女 论坛有你更精彩! 不行呀 每次都打不开
页:
[1]
2