“surface on sphere” by aadebdeb
https://openprocessing.org/sketch/345074
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
CC Attribution ShareAlike
surface on sphere
xxxxxxxxxx
/**
* surface on sphere
*
* @author aa_debdeb
* @date 2016/04/18
*/
float radious = 250;
ArrayList<Particle> particles;
PVector rNoise1, rNoise2;
float nScale = 3.4;
float maxVel = PI / 2048;
float velStep = PI / 20480;
void setup(){
size(640, 640, P3D);
particles = new ArrayList<Particle>();
for(int i = 0; i < 30; i++){
particles.add(new Particle());
}
rNoise1 = new PVector(random(100000), random(100000));
rNoise2 = new PVector(random(100000), random(100000));
background(32);
stroke(0, 0, 255, 60);
}
void draw(){
translate(width / 2, height / 2);
for(Particle particle: particles){
particle.update();
}
}
class Particle{
float r1, r2;
float vr1, vr2;
Particle(){
r1 = random(TWO_PI);
r2 = random(TWO_PI);
vr1 = random(-maxVel, maxVel);
vr2 = random(-maxVel, maxVel);
}
void update(){
vr1 += map(noise(rNoise1.x + cos(r1) * nScale, rNoise1.y + sin(r1) * nScale), 0, 1, -velStep, velStep);
constrain(vr1, -maxVel, maxVel);
float nr1 = r1 + vr1;
if(nr1 < 0){
nr1 += TWO_PI;
} else if(nr1 >= TWO_PI){
nr1 -= TWO_PI;
}
vr2 += map(noise(rNoise2.x + cos(r2) * nScale, rNoise2.y + sin(r2) * nScale), 0, 1, -velStep, velStep);
constrain(vr2, -maxVel, maxVel);
float nr2 = r2 + vr2;
if(nr2 < 0){
nr2 += TWO_PI;
} else if(nr2 >= TWO_PI){
nr2 -= TWO_PI;
}
float x = radious * sin(r1) * cos(r2);
float y = radious * sin(r1) * sin(r2);
float z = radious * cos(r1);
float nx = radious * sin(nr1) * cos(nr2);
float ny = radious * sin(nr1) * sin(nr2);
float nz = radious * cos(nr1);
line(x, y, z, nx, ny, nz);
r1 = nr1;
r2 = nr2;
}
}
See More Shortcuts