Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 26 lines (21 sloc) 0.596 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
use v6;
BEGIN { @*INC.push: 'lib' };

use Math::Model;


my $m = Math::Model.new(
    derivatives => {
        velocity => 'height',
        acceleration => 'velocity',
    },
    variables => {
        acceleration => { $:force / $:mass },
        mass => { 1 },
        force => { - $:height - 0.2 * $:velocity * abs($:velocity)},
    },
    initials => {
        height => 1,
        velocity => 0,
    },
    captures => <height>,
);

$m.integrate(:from(0), :to(20), :min-resolution(1));
$m.render-svg('spring.svg', :title('Spring with damping'));
Something went wrong with that request. Please try again.