• API
• FAQ
• Tools
• Archive
daily pastebin goal
34%
SHARE
TWEET

# Untitled

a guest Oct 11th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. function dist(x,y,z){
2.  return Math.pow(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2),0.5);
3. }
4.
5. function max(a,b){
6.   if(a>b){
7.     return a;
8.   }else{
9.     return b;
10.   }
11. }
12.
13. function min(a,b){
14.   if(a<b){
15.     return a;
16.   } else {
17.     return b;
18.   }
19. }
20.
21. function bulge(cx,cy,cz,stddev,amp,func){
22.   return function(x,y,z){
23.     //distance from point to center
24.     var dd = (dist(x-cx,y-cy,z-cz));
25.
26.     //normal vector from point to center
27.     var ux = (cx-x)/dd;
28.     var uy = (cy-y)/dd;
29.     var uz = (cz-z)/dd;
30.
31.     var indraw=amp*(Math.exp(-Math.pow(dd/stddev,2)));
32.     indraw = min(dd,indraw);
33.
34.     var xp = x+indraw*ux;
35.     var yp = y+indraw*uy;
36.     var zp = z+indraw*uz;
37.
38.     return func(xp,yp,zp);
39.   }
40. }
41.
42. function makesphere(r){
43.   return function(x,y,z){
44.     return Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2) < Math.pow(r,2);
45.   }
46. }
47.
48. emit( bulge(99,0,0,62,100,
49.         makesphere(100)
50.       ) );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top