Privacy Policy Cookie Policy Terms and Conditions Image:Cardinal Spline Example.png - Wikipedia, the free encyclopedia

Image:Cardinal Spline Example.png

From Wikipedia, the free encyclopedia

Cardinal_Spline_Example.png (6KB, MIME type: image/png)

[edit] Summary

This image is a graphical representation of a Cardinal Spline. It is drawn on a 720x480 canvas and the curve has 10 control points. The tension is set to 0.1.

The red squares repesent the posistion of the control points, and the red line represents the path of the curve.

The image was created with the following perl script:

use strict;
use Image::Magick;
use Math::Matrix;
use Math::Gradient qw(gradient);

my $rate        = 500;
my $tension     = 0.1;
my(@coords)     = (
                   [ 23, 24],     [123, 64],     [167,200],     [212,285],     [293,297],
                   [552,205],     [537, 71],     [358,122],     [262,130],     [238, 24]
                  );

my $image       = Image::Magick->new;           # Create new image
$image          ->Set(size=>'720x480');         # Set size
$image          ->ReadImage('xc:white');        # Make it all white
foreach my $ra_coord (@coords)                  # For every set of coords in the list
  {
  my($x,$y)     = @{$ra_coord}[0,1];            # Get the x and y
  $image        ->Draw  (
                         primitive      => 'rectangle',
                         points         => (($x-3).','.($y-3).' '.($x+3).','.($y+3)),
                         fill           => 'red'
                        );                      # Draw a small rectangle at each coord
  }
while (scalar(@coords) >= 4)                    # While there are atleast 4 entries in the list
  {
  for my $u (gradient(0,1,$rate))               # iterate from 0 to 1 in 500 steps
    {
    my($x,$y)   = &EvaluateCardinal2D(\@coords, $tension, $u);      # Hand paramaters to formula
    $image      ->Set("pixel\[$x,$y\]"=>'red'); # Set that pixel red
    }
  shift(@coords);                               # Remove the first entry of the list
  }
$image          ->Write("Cardinal_Spline_Example.png"); # Save image

sub EvaluateCardinal2D
  {
  my($ra_coords,$T,$u)          = @_;
  my $s                         = (1-$T)/2;
  my $u_matrix                  = new Math::Matrix      # 4 x 1
        (                               # Matrix based off the point in the curve
         [($u ** 3),    ($u ** 2),      ($u),           (1)             ]
        );
  my $cardinal_matrix           = new Math::Matrix      # 4 x 4
        (                               # Guts of the Cardinal Spline formula
         [(-1 * $s),    (2 - $s),       ($s - 2),       ($s)            ],
         [(2 * $s),     ($s - 3),       (3-(2 * $s)),   (-1 * $s)       ],
         [(-1 * $s),    (0),            ($s),           (0)             ],
         [(0),          (1),            (0),            (0)             ],
        );
  my $x_matrix                  = new Math::Matrix      # 1 x 4
        (                               # X coords for point:
         [${${$ra_coords}[0]}[0]],      # 1
         [${${$ra_coords}[1]}[0]],      # 2
         [${${$ra_coords}[2]}[0]],      # 3
         [${${$ra_coords}[3]}[0]]       # 4
        );
  my $y_matrix                  = new Math::Matrix      # 1 x 4
        (                               # Y coords for point:
         [${${$ra_coords}[0]}[1]],      # 1
         [${${$ra_coords}[1]}[1]],      # 2
         [${${$ra_coords}[2]}[1]],      # 3
         [${${$ra_coords}[3]}[1]]       # 4
        );
  my $xt        = int ($u_matrix * $cardinal_matrix * $x_matrix); # Compute for X
  my $yt        = int ($u_matrix * $cardinal_matrix * $y_matrix); # Compute for Y
  return($xt,$yt);
  }

[edit] Licensing

Public domain

I, the creator of this work, hereby release it into the public domain. This applies worldwide.
In case this is not legally possible,
I grant any entity the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

The above source code is released under the same conditions as the image itself. (PD by owner)

File history

Legend: (cur) = this is the current file, (del) = delete this old version, (rev) = revert to this old version.
Click on date to download the file or see the image uploaded on that date.

  • (del) (cur) 04:35, 17 October 2006 . . HighInBC (Talk | contribs) . . 720×480 (5,963 bytes) (== Summary == This image is a graphical representation of a ''Cardinal Spline''. It is drawn on a 720x480 canvas and the curve has 10 control points. The tension is set to ''0.1''. The red squares repesent the posistion of the control points, and the red)

The following pages on the English Wikipedia link to this file (pages on other projects are not listed):

THIS WEB:

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - be - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - closed_zh_tw - co - cr - cs - csb - cu - cv - cy - da - de - diq - dv - dz - ee - el - eml - en - eo - es - et - eu - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gd - gl - glk - gn - got - gu - gv - ha - haw - he - hi - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mg - mh - mi - mk - ml - mn - mo - mr - ms - mt - mus - my - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - rm - rmy - rn - ro - roa_rup - roa_tara - ru - ru_sib - rw - sa - sc - scn - sco - sd - se - searchcom - sg - sh - si - simple - sk - sl - sm - sn - so - sq - sr - ss - st - su - sv - sw - ta - te - test - tet - tg - th - ti - tk - tl - tlh - tn - to - tokipona - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu

Static Wikipedia 2008 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2007:

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - be - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - closed_zh_tw - co - cr - cs - csb - cu - cv - cy - da - de - diq - dv - dz - ee - el - eml - en - eo - es - et - eu - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gd - gl - glk - gn - got - gu - gv - ha - haw - he - hi - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mg - mh - mi - mk - ml - mn - mo - mr - ms - mt - mus - my - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - rm - rmy - rn - ro - roa_rup - roa_tara - ru - ru_sib - rw - sa - sc - scn - sco - sd - se - searchcom - sg - sh - si - simple - sk - sl - sm - sn - so - sq - sr - ss - st - su - sv - sw - ta - te - test - tet - tg - th - ti - tk - tl - tlh - tn - to - tokipona - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu

Static Wikipedia 2006:

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - be - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - closed_zh_tw - co - cr - cs - csb - cu - cv - cy - da - de - diq - dv - dz - ee - el - eml - en - eo - es - et - eu - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gd - gl - glk - gn - got - gu - gv - ha - haw - he - hi - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mg - mh - mi - mk - ml - mn - mo - mr - ms - mt - mus - my - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - rm - rmy - rn - ro - roa_rup - roa_tara - ru - ru_sib - rw - sa - sc - scn - sco - sd - se - searchcom - sg - sh - si - simple - sk - sl - sm - sn - so - sq - sr - ss - st - su - sv - sw - ta - te - test - tet - tg - th - ti - tk - tl - tlh - tn - to - tokipona - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu