Skip to main content
frankmaherae
Inspiring
January 25, 2023
Answered

wiggle position within confines of a circle

  • January 25, 2023
  • 1 reply
  • 486 views

Hi there,

I'm trying to wiggle the position of a layer within the area of a circle to try to mimic an electron in an atomic orbital. I'm not very adept at expressions yet and am not sure where to start with this if anyone could help?

Thanks so much,

Frank

This topic has been closed for replies.
Correct answer Dan Ebberts

You could play around with something like this:

period = .1;
radius = 100;
n = Math.floor(time/period);
phase = time%period;
seedRandom(n,true);
r1 = random(radius);
a1 = random(Math.PI*2);
p1 = r1*([Math.cos(a1),Math.sin(a1)]);
seedRandom(n+1,true);
r2 = random(radius);
a2 = random(Math.PI*2);
p2 = r2*([Math.cos(a2),Math.sin(a2)]);
offset = ease(phase,0,period,p1,p2);
value + offset

 

 

1 reply

Mylenium
Legend
January 25, 2023

wiggle() operates additively, so if you have a suitable base motion like the electron sweeping around in circles you don't need to do anything but figure out the amplitude value so it doesn't go outside the layer boundary. The specifics will really depend, even more so since electrons don't really move in fixed orbits.

 

Mylenium

frankmaherae
Inspiring
January 25, 2023

You're quite right Mylenium, they don't. In fact that's what I'm trying to illustrate. I don't want the electron to move in an orbit and be disturbed from it, I want it to almost flicker within a defined area of an s-orbital (I might wiggle scale also in addition to this to give a sense of depth hopefully for the sperical orbital) so I want the wiggle to be random but never going beyond the area of the circle. Is there a simple way to illustrate that maybe? 

Thanks for your help,

f

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
January 25, 2023

You could play around with something like this:

period = .1;
radius = 100;
n = Math.floor(time/period);
phase = time%period;
seedRandom(n,true);
r1 = random(radius);
a1 = random(Math.PI*2);
p1 = r1*([Math.cos(a1),Math.sin(a1)]);
seedRandom(n+1,true);
r2 = random(radius);
a2 = random(Math.PI*2);
p2 = r2*([Math.cos(a2),Math.sin(a2)]);
offset = ease(phase,0,period,p1,p2);
value + offset