File:Sierpinski-Curve-2.png

From testwiki
Jump to navigation Jump to search
    Original file (512 × 512 pixels, file size: 2 KB, MIME type: image/png)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Description
    English: Sierpinski Curves (fractals) of orders 1 and 2. Drawn by a Java program I did myself.
    Date
    Source Own work
    Author User:Nol Aders

    Pseudocode

    points = [] // Array dels punts
    max_order = 8 // Nombre d'ordres a avaluar
    
    // Punts inicials
    points <- Point.new(0, -1, :top) // Amunt
    points <- Point.new(1, 0, :right) // Dreta
    points <- Point.new(0, 1, :bottom) // Avall
    points <- Point.new(-1, 0, :left) // Esquerra
    
    // Crear cada ordre a partir dels punts de l'anterior
    for order in 1..max_order
     // Els punts actuals ja no surten al nou ordre
     current = points.clone
     points.clear
     // La distància depèn de l'ordre
     d = sd = 0.5 / (2 ** (order - 1))
     // Crear punt nou a partir de cada punt de l'ordre anterior
     for point in corrent
     px = point.x
     py = point.y
     case point.type
     when :top // Amunt
     points <- Point.new(px - d - sd, py - sd, :top)
     points <- Point.new(px - d, py, :right)
     points <- Point.new(px + d, py, :left)
     points <- Point.new(px + d + sd, py - sd, :top)
     when :right // Dreta
     points <- Point.new(px + sd, py - d - sd, :right)
     points <- Point.new(px, py - d, :bottom)
     points <- Point.new(px, py + d, :top)
     points <- Point.new(px + sd, py + d + sd, :right)
     when :bottom // Avall
     points <- Point.new(px + d + sd, py + sd, :bottom)
     points <- Point.new(px + d, py, :left)
     points <- Point.new(px - d, py, :right)
     points <- Point.new(px - d - sd, py + sd, :bottom)
     when :left // Esquerra
     points <- Point.new(px - sd, py + d + sd, :left)
     points <- Point.new(px, py + d, :top)
     points <- Point.new(px, py - d, :bottom)
     points <- Point.new(px - sd, py - d - sd, :left)
     end
     end
    end
    


    Pascal src code

    uses GraphABC;
    
    procedure RLine(x, y, x1, y1: real) := Line(Round(x), Round(y), Round(x1), Round(y1)); 
    
    function GetAngle(x, y, x2, y2: real): real;
    begin
      var angle := Abs(RadToDeg(ArcTan((y2 - y) / (x2 - x))));
      if (x2 = x) and (y2 = y) then
        Result := 0
      else
        if x2 > x then
          if y2 > y then Result := angle else Result := 360 - angle
        else
          if y2 > y then Result := 180 - angle else Result := 180 + angle;
    end;
    
    procedure Draw(x, y, x1, y1: real; inverted: boolean);
    begin
      var angle := GetAngle(x, y, x1, y1);
      var s := 1 - 2 * Ord(inverted);
      var r := Sqrt(Sqr(x1 - x) + Sqr(y1 - y)) / 2;
      
      var ang1 := DegToRad(angle - 60 * s);
      var xA := x + r * Cos(ang1);
      var yA := y + r * Sin(ang1);
      
      var ang2 := DegToRad(angle - 120 * s);
      var xB := x1 + r * Cos(ang2);
      var yB := y1 + r * Sin(ang2);
      
      if 2 * r < 8 then
      begin
        RLine(x, y, xA, yA);
        RLine(xA, yA, xB, yB);
        RLine(xB, yB, x1, y1);
      end
      else
      begin
        Draw(x, y, xA, yA, not inverted);
        Draw(xA, yA, xB, yB, inverted);
        Draw(xB, yB, x1, y1, not inverted);
      end;
    end;
    
    begin
      Draw(100, 100, 400, 450, false);
    end.
    


    File:Sierpinski-Curve-2.svg is a vector version of this file. It should be used in place of this PNG file when not inferior.

    File:Sierpinski-Curve-2.png → File:Sierpinski-Curve-2.svg

    For more information, see Help:SVG.

    In other languages
    Alemannisch ∙ العربية ∙ беларуская (тарашкевіца) ∙ български ∙ বাংলা ∙ català ∙ нохчийн ∙ čeština ∙ dansk ∙ Deutsch ∙ Ελληνικά ∙ English ∙ British English ∙ Esperanto ∙ español ∙ eesti ∙ euskara ∙ فارسی ∙ suomi ∙ français ∙ Frysk ∙ galego ∙ Alemannisch ∙ עברית ∙ हिन्दी ∙ hrvatski ∙ magyar ∙ հայերեն ∙ Bahasa Indonesia ∙ Ido ∙ italiano ∙ 日本語 ∙ ქართული ∙ 한국어 ∙ lietuvių ∙ македонски ∙ മലയാളം ∙ Bahasa Melayu ∙ မြန်မာဘာသာ ∙ norsk bokmål ∙ Plattdüütsch ∙ Nederlands ∙ norsk nynorsk ∙ norsk ∙ occitan ∙ polski ∙ prūsiskan ∙ português ∙ português do Brasil ∙ română ∙ русский ∙ sicilianu ∙ Scots ∙ slovenčina ∙ slovenščina ∙ српски / srpski ∙ svenska ∙ தமிழ் ∙ ไทย ∙ Türkçe ∙ татарча / tatarça ∙ українська ∙ vèneto ∙ Tiếng Việt ∙ 中文 ∙ 中文(中国大陆) ∙ 中文(简体) ∙ 中文(繁體) ∙ 中文(马来西亚) ∙ 中文(新加坡) ∙ 中文(臺灣) ∙ +/−
    New SVG image

    GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
    w:en:Creative Commons
    attribution share alike
    This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
    You are free:
    • to share – to copy, distribute and transmit the work
    • to remix – to adapt the work
    Under the following conditions:
    • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
    • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
    This licensing tag was added to this file as part of the GFDL licensing update.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    July 2005

    image/png

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current16:39, 9 January 2007Thumbnail for version as of 16:39, 9 January 2007512 × 512 (2 KB)wikimediacommons>Dbc334cleared and compressed

    There are no pages that use this file.