Skip to content

RadialWave

Cargo featurefeatures = ["physics"]

Circular waves from every point of sources, amplitude sin(k r - ω t) each, summed where they meet. In 2D the crests are rings and the troughs dashed rings, clipped to x_range by y_range; where the rings of two sources cross, the waves add up. With front (the default) the rings leave the sources on the figure’s clock. displacement(x, y, t) gives the height. With the 3d feature the same wave goes into a ThreeDView as a surface (resolution pieces a side, amplitude high); only enter applies there. Gallery scenes: RadialWave, and RadialWave3D with the gallery’s three-d feature (on by default).

RadialWave demo, first frame
RadialWave 4 s
RadialWave3D demo, first frame
RadialWave3D 2.5 s
use fframes_kit::prelude::*;
fn figure<'a>(ui: &mut Ui<'a, '_, '_>) -> Svgr<'a> {
ui.show(RadialWave {
sources: vec![(-1.6, 0.0), (1.6, 0.0)],
wavelength: 1.1,
speed: 1.6,
x_range: (-7.0, 7.0),
y_range: (-4.0, 4.0),
..ui.defaults()
})
}

Components are plain structs. Set the fields you need and fill the rest with ..ui.defaults(): the defaults below come from the current theme (theme. values are fields of Theme).

Field Type Default Description
sources Vec<(f64, f64)> vec![(0.0, 0.0)] The points the waves spread from, in units of ui.space.
wavelength f64 1.0 Units of ui.space between two crests.
speed f64 1.0 Speed of the rings in units of ui.space per second.
amplitude f64 0.3 Largest height of one wave in units of ui.space; it sets the height of the 3D surface.
front bool true The water is at rest at the start and the rings leave the sources on the clock; off fills the area from the start.
x_range (f64, f64) (-7.0, 7.0) Left and right edges of the area the rings are drawn in, in units of ui.space.
y_range (f64, f64) (-4.0, 4.0) Bottom and top edges of the area the rings are drawn in, in units of ui.space.
troughs bool true Draws the troughs as dashed rings, a quarter wavelength from the crests.
show_sources bool true Draws a dot at each source.
resolution usize 96 Pieces along each side of the 3D surface; ignored in 2D.
delay f32 0.0 Seconds after the container’s start before the waves begin.
time_scale f32 1.0 Speed of the motion over local time; 2 runs twice as fast, 1 is real time.
color Color theme.colors.accent Colour of the crest rings.
trough_color Color theme.colors.muted Colour of the trough rings.
source_color Color theme.colors.highlight Colour of the source dots.
stroke_width f32 theme.stroke.regular Width of the crest rings in pixels; troughs use the theme’s thin width.
enter Option<FadeIn> None Fade in at the start; None for none.
exit Option<FadeOut> None Fade out before the end; None for none.

Methods:

  • fn displacement(&self, x: f64, y: f64, t: f64) -> f64: The height of the water at (x, y) after t seconds: the sum over the sources of amplitude sin(k r - ω t), without the sources the front has not reached yet.

Feature physics · Source