fractal: Gosper curve

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
neorobin
Posts: 47
Joined: 01 May 2012 12:18

fractal: Gosper curve

#1 Post by neorobin » 09 May 2017 07:36

Image

Code: Select all

@echo off & setlocal enableDelayedExpansion

set "SIN=(t-t*t/1875*t/320000+t*t/1875*t/15625*t/16000*t/2560000-t*t/1875*t/15360*t/15625*t/15625*t/16000*t/44800000)"
set "COS=(10000-t*t/20000+t*t/1875*t/15625*t/819200-t*t/1875*t/15360*t/15625*t/15625*t/10240000+t*t/1875*t/15360*t/15625*t/15625*t/16000*t/15625*t/229376000)"

set /a "p=31416, p2=62832, pn2=-62832, p#2=15708, p3#2=47124, p3#2_=p3#2-1"

REM 角度运算
set /a "EA=EB=0"
set "EL=a+=60,a%%=360"
set "EM=a+=120,a%%=360"
set "ER=a-=60,t=a>>31,a+=(t&360|~t&0),a%%=360"
set "ES=a-=120,t=a>>31,a+=(t&360|~t&0),a%%=360"

set /a "margin=100000, xs=100000, ys=1739896, hei=4759696, wid=4495856"

set "C=A" & echo;C=!C!

set /a "a=90, r1=10000, r2=0"
set /a "iterations=4, imax=4573-1, y=ys, x=xs"

for /L %%i in (1 1 !iterations!) do (

    set "C=!C:A=U!"
    set "C=!C:B=V!"

    set "C=!C:U=ARBSBLAMAALBR!"
    set "C=!C:V=LARBBSBRAMALB!"

    set "C=!C:RL=!"
    set "C=!C:RR=S!"
    set "C=!C:LL=M!"

    echo;C=!C!
)
set "C=!C:B=A!"

<nul >Gosper_curve.htm (

    echo;^<svg height="!hei:~0,-4!" width="!wid:~0,-4!"^>
            set /p "=<polyline points=""

            set /p "=!x:~0,-4!.!x:~-4!,!y:~0,-4!.!y:~-4! "

            for /L %%i in (0 1 !imax!) do (
                for %%m in ("!C:~%%i,1!") do (

                    set /a "!E%%~m!"

                    if not "%%~m"=="A" (

                        set /a "t=a*p/180"
                        set /a "s1=(t-p#2^t-p3#2)>>31, s3=p3#2_-t>>31, t=(-t&s1)+(t&~s1)+(p&s1)+(pn2&s3), r1=%SIN%"
                        set /a "t=%COS%, r2=(-t&s1)+(t&~s1)"

                    ) else (

                        set /a "y-=r1*8, x+=r2*8"
                        set /p "=!x:~0,-4!.!x:~-4!,!y:~0,-4!.!y:~-4! "

                    )
                )
            )
            echo;"
            set /p "=style="fill:none;stroke:blue;stroke-width:1"/>"
            echo;Sorry, your browser does not support inline SVG.
    echo;^</svg^>
)

start "" Gosper_curve.htm

title any key to exit...
>nul pause

exit /b

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: fractal: Gosper curve

#2 Post by ShadowThief » 09 May 2017 17:30

Ooh

Post Reply