Last active
January 1, 2018 21:42
-
-
Save pavelvasev/e76d42be38739f1a0600a953ee02409f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import components.creative_points 1.0 | |
Scene { | |
CreativePoints { | |
positions: fn() | |
radius: 2 | |
id: pts | |
colors: palet.output | |
} | |
Param { | |
min: 0.1; max: 10; step: 0.05; value: 1 | |
id: sigmap | |
text: "sigma" | |
} | |
Param { | |
text: "масштаб оси Z" | |
id: zscalep | |
min: 1; max: 100; value: 10 | |
} | |
Param { | |
text: "Половина квадрата:" | |
min: 2; max: 100; value: 16 | |
id: squarenp | |
} | |
property var n: squarenp.value | |
function fn() { var res = []; | |
var ps=1; | |
var nn=2*n+1; | |
var sigma = sigmap.value; | |
var ic = n; | |
var zscale = zscalep.value; | |
for (var y=0; y<nn;y++) | |
for (var x=0; x<nn;x++) { | |
res.push( x*ps ); | |
res.push( y*ps ); | |
res.push( valN( sigma, x,y, ic ) * zscale ); | |
} | |
return res; | |
} | |
function valN( sigma, i,j, ic ) { | |
return (1.0 / (2 * Math.PI * sigma * sigma )) * Math.exp( (-1.0 / 2) * ( (i-ic)*(i-ic) + (j-ic)*(j-ic) ) / (sigma * sigma ) ); | |
} | |
/// | |
PlaneX{ | |
VisibleParam{ text: "плоскость"; checked: false } | |
} | |
/// раскраска | |
property var scalardata: { // вытащим данные по Z | |
if (!pts.positions) return []; | |
var res = []; | |
for (var i=0; i<pts.positions.length; i+=3) | |
res.push( pts.positions[i+2] ); | |
return res; | |
} | |
Paletter { | |
input: scalardata | |
id: palet | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment