FbCadCam
#1
FbCadCam
http://fbcadcam.com

Originally called FbCad - a freebasic.net project.

Renamed a few years later shortly after I decided to start a web site for it, which of course was when i realized fbcad d o t c o m was not available. fbcadcam dot com, net and org were all available and was a good name to use because i did want to add cam functionality to the project eventually, which by the way is still pending to this day (8-29-2017.)

Over time the look and feel of the program change from this:
[Image: old-screen-shot.PNG]
to this:
[Image: fbcadcam-gtk_screenshot_2017_04_10_0932.png]
the difference being:
I used gtk3 for its gui functionality while retaining the original older version's fb graphics native drawing commands. In simpler words, i did not use any gtk drawing routines for that drawing itself (drawing of the house) but only its gui functionality for drawing buttons, check boxes, scroll bars, etc...

any how, this program has quite the history of development but sadly i'm pretty much the sole programmer for the project.
http://fbcadcam.com/fbcadcam_history.html
Reply
#2
@owen

Like you, I really love the look and feel of the second one.  It looks more professional, cleaner, and way more user friendly. I love the soft colors you used on the GUI system on the left side. You don't want them too loud (the first things users sees), but you want them to know they are there.

In my notebook of applications I want to make some year down the road, I have one that I have been wanting to make for a very long time (since the DOS days). What I wanted to do is create an application where I can draw blueprints for houses using predefined objects, like windows, walls, stairs, furniture, and so forth, and export it to a format that I could load in a game.

However, there have been many of those apps made over the years, but not for games. I still would like to make such an app one day just for fun, but I wanted to purchase some of the cheaper apps that do similar things so I can get some ideas from them.

This brings me to my question, what is the main purpose of you CAD program? Is it to make games, or are you trying to create a marketable product? Just curious.


Walter Whitman
The Joyful Programmer
Dedicated to empowering computer programming hobbyists, tinkerers, amateurs, and enthusiasts.
profile for Walter Whitman at Stack Overflow, Q&A for professional and enthusiast programmers


Reply
#3
The main purpose?
Well aside from my initial four points, there is no real main purpose. It was and still is a "just for the fun of it" project. In the future, once I get my own custom (very basic) 3 axis cnc machine built, I will continue developing the cam functionality and actually be able to turn my drawings into real stuff.

A cad program developed by freebasic programmers written in Freebasic for the pupose of :
1. Learning how to code in Freebasic
2. Creating a free basic cad program for all to use (freely)
3. Learning and understanding math
4. Inspiring Creativity.


I hope it inspires you to make your own drawing program and export your drawings for use in your games. The idea of creating a drawing by adding pre-drawn things like windows and doors, etc... well these are called blocks. In a cad program (such as fbcad, qcad, autocad), creating, adding, modifying... blocks is the one thing that makes a cad program a cad program.

say for example you have a table with 4 chairs and you want to make a subtle change to the four chairs. because you saved the chair as a block, you make a subtle change to the chair's master block and bada bing bada boom, all of the four chairs are updated in the drawing.

here is an old video i made demonstrating this idea. i draw a stick figure, save the stick figure as a block, copy and paste it around a circle, then edit the master block, giving the stick figure a happy face and all of the stick figures are update with a smile.
https://youtu.be/-rFNL2LVE-4
Reply
#4
Quote:and export it to a format that I could load in a game.

because fbcad is open source, you could add an export routine to it to save the drawing in what ever format your games need.

at the moment, there is no export. just save.
it saves drawing information in a format called dxf which can be opened or imported by other cad programs.

fbcad is just 2d and very very basic. it only utilizes lines, circles and ellipses. if all you're looking to do is save the information that represents a line for example, then after drawing some lines situated to your liking, your export data could look something like:
0,0,100,100
10,20,100,200
etc...
Reply
#5
updated fbcadcam to save drawing data in a format that can be ran in a program
Code:
'this program is for waltersmind @ www.thejoyfulprogrammer.com
'how it works:
'draw something in fbcadcam and save it.
'along with the saved drawing (dxf file) will be a file called entities.dat
'entities.dat is just a normal text file which contains the data
'representation of the drawing in a format
'that can be used in a freebasic.net program such as this program.
'entities.dat can be found in the same folder as fbcadcam.exe

Declare Sub plotellipse(ex1 As Double,ey1 As Double,ez1 As Double,er1 As Double,ecolor As Integer,estart As Double,eend As Double,er2 As Double,eangle As Double)
Const pi As double = 4 * Atn(1)

ScreenRes 600,600
Window (0,0)-(600,600)

'find entity data. it is saved in file entities.dat
'note: no block data is saved in entities.dat.
'      only (non block) lines, circles and ellipses are saved in entities.dat

'copy and paste entities.dat - insert entities data here then complie and run.
'------------------------

'example from initial test:
Line ( 34, 419)-( 39, 445)
LINE ( 39, 445)-( 134, 448)
LINE ( 134, 448)-( 152, 557)
LINE ( 152, 557)-( 415, 553)
LINE ( 415, 553)-( 422, 459)
LINE ( 422, 459)-( 525, 454)
LINE ( 525, 454)-( 526, 415)
LINE ( 34, 419)-( 526, 415)
CIRCLE ( 224, 355), 40.24922359499622
CIRCLE ( 336, 360), 41.59326868617085
plotellipse( 281, 285, 0, 40.11234224026316, 15, 0, 360, 16.1245154965971, 274.289153328819)
plotellipse( 284, 230, 0, 103.0776406404415, 15, 162.2797980725094, 30.1610206876898, 55.36244214266564, 357.7760387596145)
plotellipse( 282, 291, 0, 204.1984329028996, 15, 229.3619702837845, 125.5841538358857, 172.4180964980185, 272.5261169116196)

'------------------------

Sleep
End

Sub plotellipse(ex1 As Double,ey1 As Double,ez1 As Double,er1 As Double,ecolor As Integer,estart As Double,eend As Double,er2 As Double,eangle As Double)
    '1x,2y,3z,4r,5color,6start,7end,8aspect,9=1(circle)2(arc)3(ellips)4(ellipticalarc),10group
    Dim As Double i,x1p,y1p
    Dim As Double eplotx,eploty,eplotxp,eplotyp,easpect,eresolution,elength
    Dim As BOOLEAN eplot
    If estart>eend Then
        elength=360+eend
    Else
        elength=eend
    EndIf
    eplot=FALSE
    eresolution=1
    'plotellipse
    For i = estart To elength Step eresolution
        'Sleep 1
        'x1p=Cos(i*pi/180)*er1
        'y1p=Sin(i*pi/180)*er2
        eplotx=Cos(i*pi/180)*er1*Cos(eangle*pi/180) - Sin(i*pi/180)*er2*Sin(eangle*pi/180)+ex1
        eploty=Cos(i*pi/180)*er1*Sin(eangle*pi/180) + Sin(i*pi/180)*er2*Cos(eangle*pi/180)+ey1

        If eplot=false Then
            eplot=TRUE
        Else
            Line(eplotx,eploty)-(eplotxp,eplotyp),ecolor
        EndIf
        eplotxp=eplotx
        eplotyp=eploty
    Next

    x1p=Cos(eend*pi/180)*er1
    y1p=Sin(eend*pi/180)*er2
    eplotx=x1p*Cos(eangle*pi/180) - y1p*Sin(eangle*pi/180)+ex1
    eploty=y1p*Cos(eangle*pi/180) + x1p*Sin(eangle*pi/180)+ey1
    Line(eplotx,eploty)-(eplotxp,eplotyp),ecolor
End Sub
Reply
#6
take a tour through my house
Code:
'this program is for waltersmind @ www.thejoyfulprogrammer.com
'how it works:
'draw something in fbcadcam and save it.
'along with the saved drawing (dxf file) will be a file called entities.dat
'entities.dat is just a normal text file which contains the data
'representation of the drawing in a format
'that can be used in a freebasic.net program such as this program.
'entities.dat can be found in the same folder as fbcadcam.exe

Declare Sub plotellipse(ex1 As Double,ey1 As Double,ez1 As Double,er1 As Double,ecolor As Integer,estart As Double,eend As Double,er2 As Double,eangle As Double)
Declare Sub draw_entities()
Declare Sub draw_you()
Const pi As double = 4 * Atn(1)
Dim Shared As Integer sw,sh,wx1,wy1,wx2,wy2,you_x,you_y
sw=600
sh=600
ScreenRes sw,sh
wx1=0
wy1=0
wx2=sw
wy2=sh

you_x=300
you_y=300

draw_entities
draw_you

Do
    Select Case InKey
        Case Chr(27)
            Exit Do
        Case Chr(255)+"H"'up
            wy1+=5
            wy2+=5
            you_y+=5
            draw_entities
            draw_you

        Case Chr(255)+"P"'down
            wy1-=5
            wy2-=5
            you_y-=5
            draw_entities
            draw_you

        Case Chr(255)+"K"'left
            wx1-=5
            wx2-=5
            you_x-=5
            draw_entities
            draw_you

        Case Chr(255)+"M"'right
            wx1+=5
            wx2+=5
            you_x+=5
            draw_entities
            draw_you

        Case "a"
Line ( 130, 448)-( 204, 495)
LINE ( 204, 495)-( 259, 447)
CIRCLE ( 198, 401), 48.01041553663121
CIRCLE ( 193, 403), 28.84441020371191, ,4.998440422102008, 2.321725389192838
plotellipse( 213, 242, 0, 87.00574693662483, 15, 0, 360, 50.63595560468865, 359.3414568224364)
plotellipse( 358, 345, 0, 49.16299421312742, 15, 39.847345563864, 323.5467687835224, 31.14482300479487, 355.333141628561)
    End Select
    Sleep 1
Loop

End

Sub draw_entities()
    Cls
    Window (wx1,wy1)-(wx2,wy2)
'find entity data. it is saved in file entities.dat
'note: no block data is saved in entities.dat.
'      only (non block) lines, circles and ellipses are saved in entities.dat

'copy and paste entities.dat - insert entities data here then complie and run.
'------------------------

'example from initial test:
Line ( 1940.5, 1068.625)-( 1940.5, 960.75)
LINE ( 1781.875, 1058.000000000001)-( 1781.875, 836.125)
LINE ( 1760.625, 857.375)-( 1760.625, 1058.000000000001)
LINE ( 2578.75, 1079.250000000001)-( 2578.75, 923.75)
LINE ( 2557.5, 1058.000000000001)-( 2557.5, 923.75)
LINE ( 1652.875, 956.7500000000014)-( 1652.875, 1004.25)
LINE ( 2585, 1085.5)-( 2585, 152.375)
LINE ( 2551.25, 1051.750000000001)-( 2551.25, 186.125)
LINE ( 1206.625, 1058.000000000001)-( 1206.625, 985)
LINE ( 1192.375, 985)-( 1192.375, 1058.000000000001)
LINE ( 605.125, 1083.375)-( 605.125, 610.2500000000014)
LINE ( 6.25, 1574.500000000001)-( 6.25, 6.25)
LINE ( 590.875, 865.75)-( 590.875, 1184.875)
LINE ( 0, 0)-( 0, 1580.750000000001)
LINE ( 33.75, 33.75)-( 33.75000000000182, 1547.000000000001)
LINE ( 1315.25, 1068.625)-( 1315.25, 954.3125)
LINE ( 1543.875, 1068.625)-( 1543.875, 954.3125)
LINE ( 27.5, 27.5)-( 27.50000000000182, 1553.250000000001)
LINE ( 1591.375, 169.25)-( 1248.5, 169.25)
LINE ( 1642.25, 179.875)-( 1192.375, 179.875)
LINE ( 1213.625, 158.625)-( 2578.75, 158.625)
LINE ( 1192.375, 186.125)-( 2551.25, 186.125)
LINE ( 1219.875, 152.375)-( 2585, 152.375)
LINE ( 241.875, 27.5)-( 1192.375, 27.5)
LINE ( 241.875, 6.249999999999091)-( 1213.625, 6.25)
LINE ( 590.875, 851.5000000000014)-( 536.875, 851.5)
LINE ( 605.125, 610.2500000000014)-( 522.625, 610.2500000000014)
LINE ( 536.875, 624.5000000000014)-( 590.875, 624.5000000000014)
LINE ( 590.875, 865.75)-( 511.5625, 865.75)
LINE ( 1219.875, 0)-( 0, 0)
LINE ( 33.75, 33.75)-( 1186.125, 33.75)
LINE ( 178.25, 610.2500000000014)-( 178.25, 235.625)
LINE ( 27.5, 702.6250000000014)-( 27.5, 221.375)
LINE ( 164, 221.375)-( 164, 702.6250000000014)
LINE ( 164, 624.5000000000014)-( 164, 221.375)
LINE ( 164, 393.2500000000014)-( 27.5, 393.2500000000014)
LINE ( 164, 358.875)-( 27.5, 358.875)
LINE ( 164, 324.5)-( 27.5, 324.5)
LINE ( 164, 290.1250000000014)-( 27.5, 290.1250000000014)
LINE ( 164, 255.7500000000014)-( 27.5, 255.7500000000014)
LINE ( 164, 221.375)-( 27.5, 221.375)
LINE ( 126.875, 16.875)-( 241.875, 16.875)
LINE ( 126.875, 16.875)-( 126.875, 131.875)
LINE ( 6.25, 6.25)-( 126.875, 6.249999999999091)
LINE ( 27.5, 27.5)-( 126.875, 27.5)
LINE ( 126.875, 27.5)-( 126.875, 6.25)
LINE ( 121.875, 27.5)-( 126.875, 27.5)
LINE ( 121.875, 6.25)-( 121.875, 27.5)
LINE ( 77.5, 27.5)-( 77.5, 6.25)
LINE ( 77.5, 16.875)-( 121.875, 16.875)
LINE ( 269.5, 140.375)-( 269.5, 38.875)
LINE ( 269.5, 38.875)-( 371, 38.875)
LINE ( 241.875, 6.25)-( 241.875, 27.5)
LINE ( 276.625, 38.875)-( 262.375, 38.875)
LINE ( 262.375, 38.875)-( 262.375, 27.5)
LINE ( 276.625, 38.875)-( 276.625, 27.5)
LINE ( 178.25, 235.625)-( 276.625, 235.625)
LINE ( 164, 221.375)-( 262.375, 221.375)
LINE ( 276.625, 140.375)-( 262.375, 140.375)
LINE ( 276.625, 235.625)-( 276.625, 140.375)
LINE ( 262.375, 221.375)-( 262.375, 140.375)
LINE ( 276.625, 235.625)-( 276.625, 140.375)
LINE ( 103.625, 858.625)-( 179.75, 858.625)
LINE ( 164, 633.875)-( 27.5, 633.875)
LINE ( 164, 599.5000000000014)-( 27.5, 599.5000000000014)
LINE ( 164, 565.125)-( 27.5, 565.125)
LINE ( 164, 530.75)-( 27.5, 530.75)
LINE ( 164, 702.6250000000014)-( 27.5, 702.6250000000014)
LINE ( 164, 668.2500000000014)-( 27.5, 668.2500000000014)
LINE ( 164, 496.3750000000014)-( 27.5, 496.3750000000014)
LINE ( 164, 462.0000000000014)-( 27.5, 462.0000000000014)
LINE ( 164, 427.625)-( 27.5, 427.625)
LINE ( 103.625, 865.75)-( 27.5, 865.75)
LINE ( 103.625, 851.5)-( 27.5, 851.5000000000014)
LINE ( 103.625, 851.5000000000014)-( 103.625, 865.75)
LINE ( 103.625, 858.625)-( 103.625, 934.75)
LINE ( 529.75, 730.8750000000014)-( 529.75, 679.3125000000014)
LINE ( 393.9375, 762.625)-( 393.9375, 689.625)
LINE ( 270.375, 851.5000000000014)-( 270.3750000000018, 624.5000000000014)
LINE ( 256.125, 851.5000000000014)-( 256.125, 624.5000000000014)
LINE ( 389.5625, 689.625)-( 389.5625, 762.625)
LINE ( 384.625, 624.5000000000014)-( 270.3750000000018, 624.5000000000014)
LINE ( 398.875, 610.2500000000014)-( 178.25, 610.2500000000014)
LINE ( 256.125, 624.5000000000014)-( 164, 624.5000000000014)
LINE ( 398.875, 689.6250000000014)-( 398.875, 610.2500000000014)
LINE ( 384.625, 689.6250000000014)-( 384.625, 624.5000000000014)
LINE ( 384.625, 689.625)-( 398.875, 689.625)
LINE ( 393.9375, 689.625)-( 389.5625, 689.625)
LINE ( 522.625, 627.7500000000014)-( 536.875, 627.7500000000014)
LINE ( 536.875, 624.5000000000014)-( 536.875, 627.7500000000014)
LINE ( 529.75, 679.3125000000014)-( 529.75, 627.7500000000014)
LINE ( 478.1875, 627.7500000000014)-( 529.75, 627.7500000000014)
LINE ( 522.625, 627.7500000000014)-( 522.625, 610.2500000000014)
LINE ( 409.9375, 865.75)-( 179.75, 865.75)
LINE ( 270.375, 851.5000000000014)-( 384.625, 851.5000000000014)
LINE ( 270.375, 782.75)-( 384.625, 782.75)
LINE ( 318.125, 846.6094609739203)-( 336.875, 846.6094609739203)
LINE ( 327.5, 829.1094609739203)-( 324.375, 829.1094609739203)
LINE ( 324.375, 829.1094609739203)-( 324.375, 841.6094609739203)
LINE ( 324.375, 841.6094609739203)-( 320.0052672219808, 841.6094609739203)
LINE ( 330.625, 829.1094609739203)-( 330.625, 841.6094609739203)
LINE ( 327.5, 829.1094609739203)-( 330.625, 829.1094609739203)
LINE ( 330.625, 841.6094609739203)-( 334.9947327780192, 841.6094609739203)
LINE ( 318.125, 846.6094609739203)-( 320.0052672219808, 841.6094609739203)
LINE ( 336.875, 846.6094609739203)-( 334.9947327780192, 841.6094609739203)
LINE ( 256.125, 851.5000000000014)-( 179.75, 851.5)
LINE ( 179.75, 851.5000000000014)-( 179.75, 865.75)
LINE ( 522.625, 851.5000000000014)-( 522.625, 834.0000000000014)
LINE ( 536.875, 851.5)-( 536.875, 834.0000000000014)
LINE ( 384.625, 851.5000000000014)-( 384.625, 762.625)
LINE ( 398.875, 851.5000000000014)-( 398.875, 762.6250000000014)
LINE ( 384.625, 762.625)-( 398.875, 762.625)
LINE ( 389.5625, 762.625)-( 393.9375, 762.625)
LINE ( 388.3125, 762.625)-( 388.3125, 835.625)
LINE ( 395.1875, 835.625)-( 395.1875, 762.625)
LINE ( 388.3125, 835.625)-( 395.1875, 835.625)
LINE ( 522.625, 834.0000000000014)-( 536.875, 834.0000000000014)
LINE ( 529.75, 834.0000000000014)-( 529.75, 782.4375000000014)
LINE ( 529.75, 782.4375000000014)-( 529.75, 730.8750000000014)
LINE ( 478.1875, 834.0000000000014)-( 529.75, 834.0000000000014)
LINE ( 409.9375, 858.625)-( 511.5625, 858.625)
LINE ( 409.9375, 851.5000000000014)-( 409.9375, 865.75)
LINE ( 398.875, 851.5000000000014)-( 409.9375, 851.5)
LINE ( 511.5625, 851.5)-( 522.625, 851.5000000000014)
LINE ( 511.5625, 851.5000000000014)-( 511.5625, 865.75)
LINE ( 511.5625, 858.625)-( 511.5625, 960.25)
LINE ( 1192.375, 832.6250000000014)-( 1192.375, 179.875)
LINE ( 1206.625, 832.6250000000014)-( 1206.625, 179.875)
LINE ( 969.125, 16.875)-( 626.25, 16.875)
LINE ( 626.25, 6.25)-( 626.25, 27.5)
LINE ( 1213.625, 158.625)-( 1213.625, 6.25)
LINE ( 1192.375, 179.875)-( 1192.375, 27.5)
LINE ( 1219.875, 0)-( 1219.875, 152.375)
LINE ( 1186.125, 186.125)-( 1186.125, 33.75)
LINE ( 969.125, 6.25)-( 969.125, 27.5)
LINE ( 1248.5, 179.875)-( 1248.5, 158.625)
LINE ( 1192.375, 186.125)-( 1186.125, 186.125)
LINE ( 590.875, 624.5000000000014)-( 590.875, 851.5000000000014)
LINE ( 590.875, 610.2500000000014)-( 605.125, 610.2500000000014)
LINE ( 1206.625, 832.6250000000014)-( 1192.375, 832.6250000000014)
LINE ( 1206.625, 985)-( 1192.375, 985)
LINE ( 2557.5, 179.875)-( 1663.5, 179.875)
LINE ( 1663.5, 421.5)-( 1663.5, 179.875)
LINE ( 1642.25, 442.75)-( 1642.25, 179.875)
LINE ( 1591.375, 179.875)-( 1591.375, 158.625)
LINE ( 1959.625, 169.25)-( 1839, 169.25)
LINE ( 1839, 179.875)-( 1839, 158.625)
LINE ( 1959.625, 179.875)-( 1959.625, 158.625)
LINE ( 1663.5, 857.375)-( 1760.625, 857.375)
LINE ( 1781.875, 836.125)-( 1663.5, 836.125)
LINE ( 1663.5, 836.125)-( 1663.5, 535.75)
LINE ( 1642.25, 861.75)-( 1642.25, 514.5)
LINE ( 1642.25, 514.5)-( 1713.5, 514.5)
LINE ( 1642.25, 442.75)-( 1713.5, 442.75)
LINE ( 1663.5, 535.75)-( 1734.75, 535.75)
LINE ( 1713.5, 421.5)-( 1734.75, 421.5)
LINE ( 1734.75, 421.5)-( 1663.5, 421.5)
LINE ( 1734.75, 535.75)-( 1734.75, 421.5)
LINE ( 1713.5, 442.75)-( 1713.5, 514.5)
LINE ( 1663.5, 861.75)-( 1642.25, 861.75)
LINE ( 1605.375, 861.75)-( 1652.875, 861.75)
LINE ( 1663.5, 861.75)-( 1663.5, 857.375)
LINE ( 1652.875, 861.75)-( 1652.875, 909.25)
LINE ( 1652.875, 909.25)-( 1652.875, 956.7500000000014)
LINE ( 2568.125, 923.75)-( 2568.125, 314.125)
LINE ( 2296.875, 923.75)-( 2296.875, 314.125)
LINE ( 2568.125, 314.125)-( 2296.875, 314.125)
LINE ( 2372.375, 169.25)-( 2251.75, 169.25)
LINE ( 2251.75, 179.875)-( 2251.75, 158.625)
LINE ( 2372.375, 179.875)-( 2372.375, 158.625)
LINE ( 2578.75, 314.125)-( 2578.75, 158.625)
LINE ( 2557.5, 314.125)-( 2557.5, 179.875)
LINE ( 2557.5, 314.125)-( 2578.75, 314.125)
LINE ( 2568.125, 923.75)-( 2296.875, 923.75)
LINE ( 2557.5, 923.75)-( 2578.75, 923.75)
LINE ( 1219.875, 1530.062500000001)-( 1378.625, 1530.062500000001)
LINE ( 1315.25, 1068.625)-( 1429.5625, 1068.625)
LINE ( 1740.625, 1536.375000000001)-( 1213.625, 1536.375000000001)
LINE ( 1213.625, 1523.750000000001)-( 1728, 1523.750000000001)
LINE ( 2551.25, 1051.750000000001)-( 1186.125, 1051.750000000001)
LINE ( 2585, 1085.5)-( 1219.875, 1085.5)
LINE ( 6.25, 1574.500000000001)-( 1213.625, 1574.500000000001)
LINE ( 27.50000000000182, 1553.250000000001)-( 1192.375, 1553.250000000001)
LINE ( 0, 1580.750000000001)-( 1219.875, 1580.750000000001)
LINE ( 33.75000000000182, 1547.000000000001)-( 1186.125, 1547.000000000001)
LINE ( 350.125, 1553.250000000001)-( 350.125, 1574.500000000001)
LINE ( 178.75, 1574.500000000001)-( 178.75, 1553.250000000001)
LINE ( 350.125, 1563.875000000001)-( 178.75, 1563.875000000001)
LINE ( 1099.375, 1574.500000000001)-( 1099.375, 1553.250000000001)
LINE ( 1213.625, 1574.500000000001)-( 1213.625, 1079.250000000001)
LINE ( 1219.875, 1580.750000000001)-( 1219.875, 1085.5)
LINE ( 928, 1574.500000000001)-( 928, 1553.250000000001)
LINE ( 698.25, 1574.500000000001)-( 698.25, 1553.250000000001)
LINE ( 618.25, 1574.500000000001)-( 618.25, 1553.250000000001)
LINE ( 954.25, 1093.937500000001)-( 882.8125, 1093.937500000015)
LINE ( 882.8124999999982, 1087.062500000015)-( 954.25, 1087.062500000001)
LINE ( 923.375, 1108.250000000001)-( 1000.375, 1108.250000000001)
LINE ( 1099.375, 1563.875000000001)-( 928, 1563.875000000001)
LINE ( 934.375, 1473.250000000001)-( 1112.375, 1473.250000000001)
LINE ( 854.375, 1097.625)-( 954.25, 1097.625)
LINE ( 605.125, 1083.375)-( 954.25, 1083.375)
LINE ( 590.875, 1261.124999999999)-( 590.875, 1553.250000000001)
LINE ( 817.7344609739193, 1277)-( 817.7344609739193, 1280.125)
LINE ( 835.2344609739193, 1286.375000000001)-( 835.2344609739193, 1267.625)
LINE ( 840.125, 1097.625)-( 840.125, 1334.125000000001)
LINE ( 840.125, 1097.625)-( 840.125, 1334.125000000001)
LINE ( 771.375, 1097.625)-( 771.375, 1334.125000000001)
LINE ( 605.125, 1334.125000000001)-( 605.125, 1261.124999999999)
LINE ( 854.375, 1553.250000000001)-( 854.375, 1097.625)
LINE ( 840.125, 1097.625)-( 605.125, 1097.625)
LINE ( 605.125, 1184.875)-( 605.125, 1097.625)
LINE ( 598, 1184.875)-( 674.25, 1184.875)
LINE ( 590.875, 1261.125)-( 605.125, 1261.125)
LINE ( 590.875, 1184.875)-( 605.125, 1184.875)
LINE ( 598, 1184.875)-( 598, 1184.875)
LINE ( 598, 1261.125)-( 598, 1184.875)
LINE ( 923.375, 1108.250000000001)-( 923.375, 1185.25)
LINE ( 930.5, 1097.625)-( 930.5, 1108.250000000001)
LINE ( 916.25, 1097.625)-( 916.25, 1108.250000000001)
LINE ( 916.25, 1108.250000000001)-( 930.5, 1108.250000000001)
LINE ( 882.8125, 1093.937500000015)-( 882.8124999999982, 1087.062500000015)
LINE ( 835.2344609739193, 1267.625)-( 830.2344609739193, 1269.50526722198)
LINE ( 830.2344609739193, 1273.875)-( 830.2344609739193, 1269.50526722198)
LINE ( 817.7344609739193, 1277)-( 817.7344609739193, 1273.875)
LINE ( 817.7344609739193, 1273.875)-( 830.2344609739193, 1273.875)
LINE ( 835.2344609739193, 1164.125)-( 835.2344609739193, 1145.375)
LINE ( 830.2344609739193, 1151.625)-( 830.2344609739193, 1147.25526722198)
LINE ( 817.7344609739193, 1154.75)-( 817.7344609739193, 1157.875)
LINE ( 817.7344609739193, 1157.875)-( 830.2344609739193, 1157.875)
LINE ( 830.2344609739193, 1157.875)-( 830.2344609739193, 1162.244732778019)
LINE ( 817.7344609739193, 1151.625)-( 830.2344609739193, 1151.625)
LINE ( 817.7344609739193, 1154.75)-( 817.7344609739193, 1151.625)
LINE ( 835.2344609739193, 1164.125)-( 830.2344609739193, 1162.244732778019)
LINE ( 835.2344609739193, 1145.375)-( 830.2344609739193, 1147.25526722198)
LINE ( 930.5, 1199.5)-( 854.375, 1199.5)
LINE ( 930.5, 1185.25)-( 854.375, 1185.25)
LINE ( 854.375, 1199.5)-( 854.375, 1185.25)
LINE ( 930.5, 1199.5)-( 930.4999999999982, 1185.25)
LINE ( 690.875, 1348.374999999999)-( 840.125, 1348.375000000001)
LINE ( 840.125, 1334.125000000001)-( 690.875, 1334.125000000001)
LINE ( 605.125, 1348.375000000001)-( 605.125, 1553.250000000001)
LINE ( 734.125, 1450.812500000001)-( 734.125, 1348.375000000001)
LINE ( 614.625, 1341.250000000001)-( 690.875, 1341.250000000001)
LINE ( 614.625, 1334.125000000001)-( 605.125, 1334.125000000001)
LINE ( 614.625, 1348.375000000001)-( 614.625, 1334.125000000001)
LINE ( 614.625, 1341.250000000001)-( 614.625, 1417.500000000001)
LINE ( 605.125, 1348.375000000001)-( 614.625, 1348.374999999999)
LINE ( 690.875, 1348.375000000001)-( 690.875, 1334.125000000001)
LINE ( 698.25, 1563.875000000001)-( 618.25, 1563.875000000001)
LINE ( 732.875, 1553.250000000001)-( 732.875, 1450.812500000001)
LINE ( 734.125, 1450.812500000001)-( 734.125, 1553.250000000001)
LINE ( 840.125, 1348.375000000001)-( 840.125, 1553.250000000001)
LINE ( 934.375, 1307.000000000001)-( 934.375, 1473.250000000001)
LINE ( 835.2344609739193, 1286.375000000001)-( 830.2344609739193, 1284.494732778021)
LINE ( 830.2344609739193, 1280.125)-( 830.2344609739193, 1284.494732778021)
LINE ( 817.7344609739193, 1280.125)-( 830.2344609739193, 1280.125)
LINE ( 934.375, 1307.000000000001)-( 854.375, 1307.000000000001)
LINE ( 1181.75, 1273.875)-( 1181.75, 1366.374999999999)
LINE ( 1176.125, 1366.374999999999)-( 1176.125, 1273.875)
LINE ( 1191.125, 1366.374999999999)-( 1191.125, 1273.875)
LINE ( 1111.125, 1273.875)-( 1111.125, 1366.374999999999)
LINE ( 1192.375, 1553.250000000001)-( 1192.375, 1058.000000000001)
LINE ( 1186.125, 1547.000000000001)-( 1186.125, 1051.75)
LINE ( 1097.125, 1083.375)-( 1192.375, 1083.375)
LINE ( 1097.125, 1097.625)-( 1192.375, 1097.625)
LINE ( 1112.375, 1272.625)-( 1192.375, 1272.625)
LINE ( 1191.125, 1273.875)-( 1111.125, 1273.875)
LINE ( 1097.125, 1093.937500000001)-( 1168.5625, 1093.937500000006)
LINE ( 1168.5625, 1087.062500000006)-( 1097.124999999998, 1087.062500000001)
LINE ( 1112.375, 1272.625)-( 1112.375, 1097.625)
LINE ( 1097.125, 1092.6875)-( 1025.6875, 1092.6875)
LINE ( 1025.6875, 1088.3125)-( 1097.125, 1088.3125)
LINE ( 1025.6875, 1092.6875)-( 1025.6875, 1088.3125)
LINE ( 1025.6875, 1092.6875)-( 1025.6875, 1088.3125)
LINE ( 954.25, 1097.625)-( 954.25, 1083.375)
LINE ( 954.25, 1092.6875)-( 954.25, 1088.3125)
LINE ( 954.25, 1092.6875)-( 1025.6875, 1092.6875)
LINE ( 1025.6875, 1088.3125)-( 954.25, 1088.3125)
LINE ( 1097.125, 1097.625)-( 1097.125, 1083.375)
LINE ( 1097.125, 1092.6875)-( 1097.125, 1088.3125)
LINE ( 1315.25, 1058.000000000001)-( 1192.375, 1058.000000000001)
LINE ( 1213.625, 1079.250000000001)-( 1315.25, 1079.250000000001)
LINE ( 1168.5625, 1093.937500000006)-( 1168.5625, 1087.062500000006)
LINE ( 1315.25, 1079.250000000001)-( 1315.25, 1058.000000000001)
LINE ( 1112.375, 1367.625000000001)-( 1192.375, 1367.625000000001)
LINE ( 1111.125, 1366.374999999999)-( 1191.125, 1366.374999999999)
LINE ( 1112.375, 1473.250000000001)-( 1112.375, 1367.624999999998)
LINE ( 1031.5, 1483.875000000001)-( 1064, 1483.875000000001)
LINE ( 1031.5, 1535.749999999998)-( 1064, 1535.749999999998)
LINE ( 972.125, 1548.250000000001)-( 1074.625, 1548.250000000001)
LINE ( 1074.625, 1478.250000000001)-( 972.125, 1478.250000000001)
LINE ( 1039, 1544.500000000001)-( 1039, 1539.500000000001)
LINE ( 1020.016242789363, 1540.055456351737)-( 1021.430456351736, 1538.641242789364)
LINE ( 1025.25, 1490.125000000001)-( 1025.25, 1529.499999999998)
LINE ( 1021.5, 1490.125000000001)-( 1021.5, 1529.499999999998)
LINE ( 1046.355970388562, 1520.786796564404)-( 1044.588203435596, 1519.019029611439)
LINE ( 1026.67724875233, 1541.349401677121)-( 1046.355970388562, 1521.670680040886)
LINE ( 1043.704319959114, 1519.019029611439)-( 1024.02559832288, 1538.697751247669)
LINE ( 1007.75, 1539.500000000001)-( 1007.75, 1544.500000000001)
LINE ( 976.5, 1490.125000000001)-( 976.5, 1529.499999999998)
LINE ( 1015.25, 1483.875000000001)-( 982.75, 1483.875000000001)
LINE ( 1015.25, 1535.749999999998)-( 982.75, 1535.749999999998)
LINE ( 1012.326456543959, 1529.183689590992)-( 1010.558689590993, 1530.951456543959)
LINE ( 1011.619349762772, 1531.658563325145)-( 1013.033563325145, 1530.244349762771)
LINE ( 970.875, 1479.500000000001)-( 970.875, 1547.000000000001)
LINE ( 1009, 1545.750000000001)-( 1037.75, 1545.750000000001)
LINE ( 1037.75, 1538.250000000001)-( 1009, 1538.250000000001)
LINE ( 1010.558689590993, 1532.719223496927)-( 1022.933058261757, 1545.093592167691)
LINE ( 1026.46859216769, 1541.558058261756)-( 1014.094223496924, 1529.183689590992)
LINE ( 1011.619349762772, 1532.542446801629)-( 1019.13235931288, 1540.055456351737)
LINE ( 1013.91744680163, 1530.244349762771)-( 1021.430456351736, 1537.757359312881)
LINE ( 1070.25, 1490.125000000001)-( 1070.25, 1529.499999999998)
LINE ( 1075.875, 1547.000000000001)-( 1075.875, 1479.500000000001)
LINE ( 1219.875, 1536.375000000001)-( 1219.875, 1523.750000000001)
LINE ( 1940.5, 1058.000000000001)-( 2557.5, 1058.000000000001)
LINE ( 1940.5, 1079.25)-( 2578.75, 1079.250000000001)
LINE ( 1543.875, 1079.250000000001)-( 1832.625, 1079.25)
LINE ( 1734.3125, 1276)-( 1842.1875, 1276)
LINE ( 1663.5, 1058.000000000001)-( 1760.625, 1058.000000000001)
LINE ( 1728, 1276)-( 1728, 1523.750000000001)
LINE ( 1740.625, 1276)-( 1740.625, 1279.75)
LINE ( 1740.625, 1536.375000000001)-( 1740.625, 1276)
LINE ( 1642.25, 1058.000000000001)-( 1543.875, 1058.000000000001)
LINE ( 1429.5625, 1068.625)-( 1543.875, 1068.625)
LINE ( 1543.875, 1079.250000000001)-( 1543.875, 1058.000000000001)
LINE ( 1740.625, 1168.125)-( 1740.625, 1079.250000000001)
LINE ( 1734.3125, 1085.5)-( 1734.3125, 1164.375)
LINE ( 1728, 1079.250000000001)-( 1728, 1168.125)
LINE ( 1642.25, 1051.750000000001)-( 1663.5, 1051.750000000001)
LINE ( 1605.375, 1051.750000000001)-( 1652.875, 1051.750000000001)
LINE ( 1642.25, 1058.000000000001)-( 1642.25, 1051.750000000001)
LINE ( 1642.25, 1058.000000000001)-( 1642.25, 1051.750000000001)
LINE ( 1740.625, 1085.5)-( 1728, 1085.5)
LINE ( 1663.5, 1058.000000000001)-( 1663.5, 1051.750000000001)
LINE ( 1652.875, 1004.25)-( 1652.875, 1051.750000000001)
LINE ( 1728, 1276)-( 1740.625, 1276)
LINE ( 1728, 1168.125)-( 1740.625, 1168.125)
LINE ( 1740.625, 1164.375)-( 1728, 1164.375)
LINE ( 1734.3125, 1168.125)-( 1734.3125, 1276)
LINE ( 1556.125, 1523.750000000001)-( 1392.375, 1523.750000000001)
LINE ( 1392.375, 1530.062500000001)-( 1556.125, 1530.062500000001)
LINE ( 1392.375, 1523.750000000001)-( 1392.375, 1536.375000000001)
LINE ( 1378.625, 1536.375000000001)-( 1378.625, 1523.750000000001)
LINE ( 1734.3125, 1379.125000000001)-( 1734.3125, 1523.750000000001)
LINE ( 1728, 1365.375000000001)-( 1740.625, 1365.375000000001)
LINE ( 1740.625, 1365.375000000001)-( 1740.625, 1379.125000000001)
LINE ( 1740.625, 1379.125000000001)-( 1728, 1379.125000000001)
LINE ( 1740.625, 1279.75)-( 1728, 1279.75)
LINE ( 1734.3125, 1279.75)-( 1734.3125, 1365.375000000001)
LINE ( 1569.875, 1530.062500000001)-( 1728, 1530.062500000001)
LINE ( 1569.875, 1523.750000000001)-( 1569.875, 1536.375000000001)
LINE ( 1556.125, 1536.375000000001)-( 1556.125, 1523.750000000001)
LINE ( 1728, 1523.750000000001)-( 1740.625, 1523.750000000001)
LINE ( 1728, 1523.750000000001)-( 1728, 1536.375000000001)
LINE ( 1832.625, 1068.625)-( 1940.5, 1068.625)
LINE ( 1832.625, 1058.000000000001)-( 1832.625, 1079.250000000001)
LINE ( 1781.875, 1058.000000000001)-( 1832.625, 1058.000000000001)
LINE ( 1940.5, 1058.000000000001)-( 1940.5, 1079.250000000001)
LINE ( 624.7024908889252, 1512.867723343562)-( 624.7024908889252, 1537.506459317733)
LINE ( 625.9524908889252, 1511.617723343562)-( 710.4312044627077, 1511.617723343564)
LINE ( 655.033786381915, 1511.617723343562)-( 681.3499089697179, 1511.617723343562)
LINE ( 655.033786381915, 1511.617723343562)-( 643.2713552674759, 1486.633275530141)
LINE ( 693.112340084157, 1486.633275530141)-( 681.3499089697179, 1511.617723343562)
LINE ( 625.9524908889252, 1538.756459317733)-( 710.4312044627077, 1538.756459317733)
LINE ( 711.6812044627077, 1537.506459317733)-( 711.6812044627077, 1512.867723343564)
LINE ( 373.8274908889252, 673.3677233435615)-( 373.8274908889252, 648.7289873693903)
LINE ( 372.5774908889252, 674.6177233435615)-( 288.0987773151428, 674.6177233435601)
LINE ( 343.4961953959355, 674.6177233435615)-( 317.1800728081325, 674.6177233435615)
LINE ( 343.4961953959355, 674.6177233435615)-( 355.2586265103746, 699.6021711569838)
LINE ( 305.4176416936934, 699.6021711569838)-( 317.1800728081325, 674.6177233435615)
LINE ( 372.5774908889252, 647.4789873693903)-( 288.0987773151428, 647.4789873693903)
LINE ( 286.8487773151428, 648.7289873693903)-( 286.8487773151428, 673.3677233435601)
LINE ( 0, 0)-( 600, 0)
CIRCLE ( 1940.5, 1068.625), 107.875, ,3.141592653589793, 4.71238898038469
CIRCLE ( 1315.25, 1068.625), 114.3125, ,4.71238898038469, 0
CIRCLE ( 1543.875, 1068.625), 114.3125, ,3.141592653589793, 4.71238898038469
CIRCLE ( 126.875, 16.875), 115, ,0, 1.570796326794897
CIRCLE ( 269.5, 38.875), 101.5, ,0, 1.570796326794897
CIRCLE ( 103.625, 858.625), 76.125, ,0, 1.570796326794897
CIRCLE ( 529.75, 627.7500000000014), 51.5625, ,1.570796326794897, 3.141592653589793
CIRCLE ( 327.5, 840.2500000000014), 3.125
CIRCLE ( 327.5, 840.2500000000014), 0.625
CIRCLE ( 327.5, 817.125), 3.125
CIRCLE ( 327.5, 840.2500000000014), 3.75
CIRCLE ( 529.75, 834.0000000000014), 51.56249999999954, ,3.141592653589793, 4.71238898038469
CIRCLE ( 511.5625, 858.625), 101.625, ,1.570796326794897, 3.141592653589793
CIRCLE ( 1652.875, 861.75), 47.5, ,1.570796326794897, 3.141592653589793
CIRCLE ( 923.375, 1108.250000000001), 77, ,0, 1.570796326794897
CIRCLE ( 828.875, 1277), 3.75
CIRCLE ( 828.875, 1277), 3.125
CIRCLE ( 805.75, 1277), 3.125
CIRCLE ( 598, 1184.875), 76.25, ,0, 1.570796326794897
CIRCLE ( 828.875, 1277), 0.625
CIRCLE ( 828.875, 1154.75), 3.125
CIRCLE ( 828.875, 1154.75), 0.625
CIRCLE ( 828.875, 1154.75), 3.75
CIRCLE ( 805.75, 1154.75), 3.125
CIRCLE ( 614.625, 1341.250000000001), 76.25, ,0, 1.570796326794897
CIRCLE ( 1160.985334775089, 1341.374999999999), 10.9375
CIRCLE ( 1156.266189782113, 1298.875000000001), 15.625
CIRCLE ( 1130.983810217887, 1341.374999999999), 15.625
CIRCLE ( 1126.264665224926, 1298.875000000001), 10.9375
CIRCLE ( 1037.75, 1544.500000000001), 1.25, ,0, 1.570796326794897
CIRCLE ( 1037.75, 1539.500000000001), 1.25, ,4.71238898038469, 0
CIRCLE ( 1023.375, 1541.999999999998), 3.124999999999545, ,6.141288252574394, 1.712693381400158
CIRCLE ( 1019.574301051121, 1539.613514613495), 0.625, ,0.7853981634000206, 2.356194490189772
CIRCLE ( 1020.988514613495, 1538.199301051122), 0.625, ,5.497787143779563, 0.7853981634000206
CIRCLE ( 1023.375, 1542.000000000001), 3.125
CIRCLE ( 1023.583656584638, 1538.255809509428), 0.625, ,0.7853981634000206, 1.626466833963566
CIRCLE ( 1027.119190490572, 1541.79134341536), 0.625, ,3.085922146417495, 3.926990816989812
CIRCLE ( 1031.5, 1529.499999999998), 6.25, ,1.570796326794897, 3.141592653589793
CIRCLE ( 1031.5, 1490.125000000001), 6.25, ,3.141592653589793, 4.71238898038469
CIRCLE ( 1044.146261697355, 1519.460971349678), 0.625, ,3.926990816989812, 5.497787143779563
CIRCLE ( 1045.914028650321, 1521.228738302646), 0.625, ,5.497787143779563, 0.7853981634000206
CIRCLE ( 972.125, 1547.000000000001), 1.25, ,1.570796326794897, 3.141592653589793
CIRCLE ( 1009, 1544.500000000001), 1.25, ,1.570796326794897, 3.141592653589793
CIRCLE ( 1009, 1539.500000000001), 1.25, ,3.141592653589793, 4.71238898038469
CIRCLE ( 972.125, 1479.500000000001), 1.25, ,3.141592653589793, 4.71238898038469
CIRCLE ( 982.75, 1490.125000000001), 6.25, ,3.141592653589793, 4.71238898038469
CIRCLE ( 982.75, 1529.499999999998), 6.25, ,1.570796326794897, 3.141592653589793
CIRCLE ( 1011.442573067476, 1531.835340020443), 1.25, ,2.356194490189772, 3.926990816989812
CIRCLE ( 1013.210340020443, 1530.067573067475), 1.25, ,3.926990816989812, 5.497787143779563
CIRCLE ( 1012.061291501013, 1532.100505063388), 0.625, ,2.356194490189772, 3.926990816989812
CIRCLE ( 1013.475505063389, 1530.686291501013), 0.625, ,3.926990816989812, 5.497787143779563
CIRCLE ( 1015.25, 1490.125000000001), 6.25, ,4.71238898038469, 0
CIRCLE ( 1015.25, 1529.499999999998), 6.25, ,0, 1.570796326794897
CIRCLE ( 1074.625, 1547.000000000001), 1.25, ,0, 1.570796326794897
CIRCLE ( 1074.625, 1479.500000000001), 1.25, ,4.71238898038469, 0
CIRCLE ( 1064, 1529.499999999998), 6.25, ,0, 1.570796326794897
CIRCLE ( 1064, 1490.125000000001), 6.25, ,4.71238898038469, 0
CIRCLE ( 1734.3125, 1276), 107.875, ,4.71238898038469, 0
CIRCLE ( 1652.875, 1051.750000000001), 47.5, ,3.141592653589793, 4.71238898038469
CIRCLE ( 710.4312044627077, 1537.506459317733), 1.25, ,0, 1.570796326794897
CIRCLE ( 710.4312044627077, 1512.867723343564), 1.25, ,4.71238898038469, 0
CIRCLE ( 625.9524908889252, 1512.867723343562), 1.25, ,3.141592653589793, 4.71238898038469
CIRCLE ( 668.1918476758165, 1474.900953988355), 27.54411571704531
CIRCLE ( 625.9524908889252, 1537.506459317733), 1.25, ,1.570796326794897, 3.141592653589793
CIRCLE ( 288.0987773151428, 648.7289873693903), 1.25, ,3.141592653589793, 4.71238898038469
CIRCLE ( 288.0987773151428, 673.3677233435601), 1.25, ,1.570796326794897, 3.141592653589793
CIRCLE ( 372.5774908889252, 673.3677233435615), 1.25, ,0, 1.570796326794897
CIRCLE ( 330.338134102034, 711.3344926987679), 27.54411571704531
CIRCLE ( 372.5774908889252, 648.7289873693903), 1.25, ,4.71238898038469, 6.283185307179586

'------------------------
End Sub

Sub draw_you()
Line ( 11+you_x, 28.59878053314327+you_y)-( 11+you_x, 14+you_y)
LINE ( 11+you_x, 14+you_y)-( 2+you_x, 3+you_y)
LINE ( 11+you_x, 14+you_y)-( 20+you_x, 3+you_y)
LINE ( 4+you_x, 22+you_y)-( 19+you_x, 21+you_y)
CIRCLE ( 11+you_x, 45+you_y), 16.40121946685673
CIRCLE ( 5+you_x, 50+you_y), 2.82842712474619
CIRCLE ( 17+you_x, 50+you_y), 2.82842712474619
CIRCLE ( 11+you_x, 42+you_y), 2.82842712474619
CIRCLE ( 11+you_x, 42+you_y), 8, ,3.4903636571737, 5.764039192933064
End Sub

Sub plotellipse(ex1 As Double,ey1 As Double,ez1 As Double,er1 As Double,ecolor As Integer,estart As Double,eend As Double,er2 As Double,eangle As Double)
    '1x,2y,3z,4r,5color,6start,7end,8aspect,9=1(circle)2(arc)3(ellips)4(ellipticalarc),10group
    Dim As Double i,x1p,y1p
    Dim As Double eplotx,eploty,eplotxp,eplotyp,easpect,eresolution,elength
    Dim As BOOLEAN eplot
    If estart>eend Then
        elength=360+eend
    Else
        elength=eend
    EndIf
    eplot=FALSE
    eresolution=1
    'plotellipse
    For i = estart To elength Step eresolution
        'Sleep 1
        'x1p=Cos(i*pi/180)*er1
        'y1p=Sin(i*pi/180)*er2
        eplotx=Cos(i*pi/180)*er1*Cos(eangle*pi/180) - Sin(i*pi/180)*er2*Sin(eangle*pi/180)+ex1
        eploty=Cos(i*pi/180)*er1*Sin(eangle*pi/180) + Sin(i*pi/180)*er2*Cos(eangle*pi/180)+ey1

        If eplot=false Then
            eplot=TRUE
        Else
            Line(eplotx,eploty)-(eplotxp,eplotyp),ecolor
        EndIf
        eplotxp=eplotx
        eplotyp=eploty
    Next

    x1p=Cos(eend*pi/180)*er1
    y1p=Sin(eend*pi/180)*er2
    eplotx=x1p*Cos(eangle*pi/180) - y1p*Sin(eangle*pi/180)+ex1
    eploty=y1p*Cos(eangle*pi/180) + x1p*Sin(eangle*pi/180)+ey1
    Line(eplotx,eploty)-(eplotxp,eplotyp),ecolor
End Sub
Reply
#7
updated fbcadcam to save drawing info in 3 formats which can be found in:
1. entities.dat
2. entities-mod.dat
3. entities-data.dat
draw something in fbcadcam and save it. then copy and paste the info from these files into your programs.

entities-mod adds variables in the data such as
Line (12 + x1, 34 + y1)-(56 + x2, 78 + y2)
you can copy and past this info into your editor and pass x1,y1,x2,y2 values

entities-data makes it possible to load arrays with this info so you can move, rotate, etc..

here are the two new support programs: (also included in the down loaded zip)

draw-entities-mod.bas
this example draws a gear which is adjusted from position (0,0) to (0 + x1, 0 + y1)
Code:
'this program is for waltersmind @ www.thejoyfulprogrammer.com
'how it works:
'draw something in fbcadcam and save it.
'along with the saved drawing (dxf file) will be a file called entities.dat
'entities.dat is just a normal text file which contains the data
'representation of the drawing in a format
'that can be used in a freebasic.net program such as this program.
'entities.dat can be found in the same folder as fbcadcam.exe

Declare Sub plotellipse(ex1 As Double,ey1 As Double,ez1 As Double,er1 As Double,ecolor As Integer,estart As Double,eend As Double,er2 As Double,eangle As Double)
Declare Sub draw_entities(x1 As Double,y1 As Double,x2 As Double,y2 As Double,arc_start As Double,arc_end As Double)
Const pi As double = 4 * Atn(1)
ScreenRes 600,600
Window (0,0)-(600,600)

draw_entities 300,300,300,300,0,0

Sleep
End

Sub draw_entities(x1 As Double,y1 As Double,x2 As Double,y2 As Double,arc_start As Double,arc_end As Double)
'find entity data. it is saved in file entities.dat
'note: no block data is saved in entities.dat.
'      only (non block) lines, circles and ellipses are saved in entities.dat

'copy and paste entities.dat - insert entities data here then complie and run.
'------------------------

'example from initial test:

LINE ( 15.53503320174781 + x1, 8.522854111822298 + y1)-( 12.91853338613899 + x2, 7.439064402250423 + y2)
LINE ( 15.53503320174781 + x1, 8.522854111822298 + y1)-( 12.91853338613899 + x2, 7.439064402250423 + y2)
LINE ( 17.01149526044719 + x1, 4.958359385380931 + y1)-( 14.3949954448384 + x2, 3.874569675809056 + y2)
CIRCLE ( 66.68395609140191 + x1,-38.49999999999984 + y1), 77, ,1.570796326794897 + arc_start, 1.832595714594055 + arc_end
CIRCLE ( 19.92906647289419 + x1, 74.37628862425822 + y1), 77, ,5.235987755982984 + arc_start, 5.497787143782143 + arc_end
CIRCLE ( 19.92906647289459 + x1,-74.37628862425812 + y1), 77, ,0.7853981633974483 + arc_start, 1.047197551196606 + arc_end
CIRCLE ( 66.6839560914018 + x1, 38.49999999999994 + y1), 77, ,4.450589592585537 + arc_start, 4.712388980384688 + arc_end
CIRCLE (-38.5 + x1,-66.68395609140174 + y1), 77, ,6.283185307179585 + arc_start, 0.2617993877991512 + arc_end
CIRCLE ( 74.37628862425828 + x1,-19.92906647289404 + y1), 77, ,3.665191429188092 + arc_start, 3.926990816987243 + arc_end
CIRCLE (-74.37628862425825 + x1,-19.92906647289406 + y1), 77, ,5.497787143782136 + arc_start, 5.759586531581292 + arc_end
CIRCLE ( 38.50000000000043 + x1,-66.68395609140154 + y1), 77, ,2.879793265790646 + arc_start, 3.141592653589797 + arc_end
CIRCLE (-66.68395609140185 + x1, 38.49999999999979 + y1), 77, ,4.712388980384688 + arc_start, 4.974188368183844 + arc_end
CIRCLE (-19.92906647289411 + x1,-74.37628862425827 + y1), 77, ,2.094395102393194 + arc_start, 2.35619449019235 + arc_end
CIRCLE (-19.92906647289459 + x1, 74.37628862425811 + y1), 77, ,3.926990816987241 + arc_start, 4.188790204786391 + arc_end
CIRCLE ( 38.50000000000011 + x1, 66.68395609140174 + y1), 77, ,3.141592653589793 + arc_start, 3.403392041388943 + arc_end
CIRCLE (-74.37628862425825 + x1, 19.92906647289398 + y1), 77, ,0.5235987755982988 + arc_start, 0.7853981633974501 + arc_end
CIRCLE ( 74.37628862425828 + x1, 19.92906647289401 + y1), 77, ,2.356194490192343 + arc_start, 2.617993877991498 + arc_end
CIRCLE (-38.50000000000043 + x1, 66.68395609140151 + y1), 77, ,6.021385919380439 + arc_start, 0.00000000000000523598775598298 + arc_end
CIRCLE (-66.68395609140174 + x1,-38.49999999999999 + y1), 77, ,1.308996938995747 + arc_start, 1.570796326794897 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 77.00000000000043, ,0.2617993877991512 + arc_start, 0.5235987755983006 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 77.00000000000001, ,1.047197551196605 + arc_start, 1.308996938995745 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 77, ,1.832595714594048 + arc_start, 2.094395102393195 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 76.99999999999999, ,2.617993877991494 + arc_start, 2.879793265790647 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 77.00000000000031, ,3.403392041388946 + arc_start, 3.665191429188094 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 76.99999999999987, ,4.188790204786396 + arc_start, 4.450589592585541 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 77.00000000000006, ,4.974188368183842 + arc_start, 5.235987755982989 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 77.00000000000006, ,5.759586531581287 + arc_start, 6.021385919380441 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 58.93324858422367, ,6.152285613280021 + arc_start, 0.1308996938995712 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 58.93324858422353, ,0.654498469497877 + arc_start, 0.9162978572970265 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 58.93324858422353, ,1.439896632895324 + arc_start, 1.701696020694471 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 58.93324858422376, ,2.225294796292769 + arc_start, 2.487094184091919 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 58.93324858422432, ,3.010692959690222 + arc_start, 3.272492347489368 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 58.93324858422368, ,3.796091123087672 + arc_start, 4.05789051088682 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 58.93324858422356, ,4.581489286485117 + arc_start, 4.843288674284266 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 58.93324858422367, ,5.366887449882565 + arc_start, 5.628686837681711 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 14.90731981375651, ,0.5224685963219925 + arc_start, 0.2629295670754627 + arc_end
CIRCLE ( 0 + x1, 0 + y1), 17.7193763657419, ,0.2836138735775202 + arc_start, 0.5017842898199351 + arc_end


'------------------------
End Sub

Sub plotellipse(ex1 As Double,ey1 As Double,ez1 As Double,er1 As Double,ecolor As Integer,estart As Double,eend As Double,er2 As Double,eangle As Double)
    '1x,2y,3z,4r,5color,6start,7end,8aspect,9=1(circle)2(arc)3(ellips)4(ellipticalarc),10group
    Dim As Double i,x1p,y1p
    Dim As Double eplotx,eploty,eplotxp,eplotyp,easpect,eresolution,elength
    Dim As BOOLEAN eplot
    If estart>eend Then
        elength=360+eend
    Else
        elength=eend
    EndIf
    eplot=FALSE
    eresolution=1
    'plotellipse
    For i = estart To elength Step eresolution
        'Sleep 1
        'x1p=Cos(i*pi/180)*er1
        'y1p=Sin(i*pi/180)*er2
        eplotx=Cos(i*pi/180)*er1*Cos(eangle*pi/180) - Sin(i*pi/180)*er2*Sin(eangle*pi/180)+ex1
        eploty=Cos(i*pi/180)*er1*Sin(eangle*pi/180) + Sin(i*pi/180)*er2*Cos(eangle*pi/180)+ey1

        If eplot=false Then
            eplot=TRUE
        Else
            Line(eplotx,eploty)-(eplotxp,eplotyp),ecolor
        EndIf
        eplotxp=eplotx
        eplotyp=eploty
    Next

    x1p=Cos(eend*pi/180)*er1
    y1p=Sin(eend*pi/180)*er2
    eplotx=x1p*Cos(eangle*pi/180) - y1p*Sin(eangle*pi/180)+ex1
    eploty=y1p*Cos(eangle*pi/180) + x1p*Sin(eangle*pi/180)+ey1
    Line(eplotx,eploty)-(eplotxp,eplotyp),ecolor
End Sub


draw-entities-data.bas
this example just shows data being read into the arrays using the READ DATA commands
Code:
'this program is for waltersmind @ www.thejoyfulprogrammer.com
'how it works:
'draw something in fbcadcam and save it.
'along with the saved drawing (dxf file) will be a file called entities.dat
'entities.dat is just a normal text file which contains the data
'representation of the drawing in a format
'that can be used in a freebasic.net program such as this program.
'entities.dat can be found in the same folder as fbcadcam.exe

Declare Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
Declare Sub read_entity_data()
Const pi As double = 4 * Atn(1)

Dim Shared As Integer linesc,circlesc
Dim Shared As Double lines()
Dim Shared As Double circles()

Dim As Integer i,j

ScreenRes 600,600
Window (0,0)-(600,600)

linesc=0
circlesc=0

read_entity_data

For i=1 To linesc
    Line(lines(i,1),lines(i,2))-(lines(i,3),lines(i,4))
Next
For i=1 To circlesc
    Select Case circles(i,0)
        Case 1
            Circle(circles(i,1),circles(i,2)),circles(i,3)
        Case 2
            Circle(circles(i,1),circles(i,2)),circles(i,3),,circles(i,4),circles(i,5)
        Case 3
            plotellipse(circles(i,1),circles(i,2),circles(i,3),circles(i,4),circles(i,5),circles(i,6),circles(i,7))
    End Select
Next
Sleep
End

Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
    '1x,2y,3z,4r,5color,6start,7end,8aspect,9=1(circle)2(arc)3(ellips)4(ellipticalarc),10group,11 is ellipse rotation , 12 block
    Dim As Double i,x1p,y1p
    Dim As Double eplotx,eploty,eplotxp,eplotyp,easpect,eresolution,elength
    Dim As BOOLEAN eplot
    If estart>eend Then
        elength=360+eend
    Else
        elength=eend
    EndIf
    eplot=FALSE
    eresolution=1
    'plotellipse
    For i = estart To elength Step eresolution
        'Sleep 1
        'x1p=Cos(i*pi/180)*er1
        'y1p=Sin(i*pi/180)*er2
        eplotx=Cos(i*pi/180)*er1*Cos(eangle*pi/180) - Sin(i*pi/180)*er2*Sin(eangle*pi/180)+ex1
        eploty=Cos(i*pi/180)*er1*Sin(eangle*pi/180) + Sin(i*pi/180)*er2*Cos(eangle*pi/180)+ey1

        If eplot=false Then
            eplot=TRUE
        Else
            Line(eplotx,eploty)-(eplotxp,eplotyp)
        EndIf
        eplotxp=eplotx
        eplotyp=eploty
    Next

    x1p=Cos(eend*pi/180)*er1
    y1p=Sin(eend*pi/180)*er2
    eplotx=x1p*Cos(eangle*pi/180) - y1p*Sin(eangle*pi/180)+ex1
    eploty=y1p*Cos(eangle*pi/180) + x1p*Sin(eangle*pi/180)+ey1
    Line(eplotx,eploty)-(eplotxp,eplotyp)
End Sub

Sub read_entity_data()
    Dim As String entity_type
    Dim As Integer i,j,entity_count
    entity_type=""
    entity_count=0
    Do
        Read entity_type
        Read entity_count
        Select Case entity_type
            Case "ENTITY DATA START"
                'begin filling line and circle arrays
            Case "ENTITY DATA END"
                Exit Do
            Case "LINE"
                'Print "Line"
                linesc+=entity_count
                ReDim Preserve lines(linesc,4)
                For i = 1 To entity_count
                    For j=1 To 4
                        Read lines(i,j)
                        'Print lines(i,j)
                    Next
                Next
            Case "CIRCLE"
                'Print "Circle"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=1
                    For j=1 To 3
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ARC"
                'Print "Arc"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=2
                    For j=1 To 5
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ELLIPSE"
                'Print "Ellipse"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=3
                    For j=1 To 7
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
        End Select
    Loop
End Sub

Data "ENTITY DATA START"
DATA 0
'lines data x1,y1,x2,y2
DATA "LINE", 3
DATA 74, 450, 155, 519
DATA 155, 519, 188, 438
DATA 188, 438, 83, 517
'circles data x1,y1,radius
DATA "CIRCLE", 3
DATA 280, 484, 47.2652091923859
DATA 280, 484, 61.84658438426491
DATA 280, 484, 74.95331880577403
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 2
DATA 125, 322, 51.24451190127583, 0.7524430657831508, 5.650436472177402
DATA 120, 317, 28.63564212655271, 0.7242500007481463, 5.916011473361367
'ellipse data ex1,ey1,er1,estart,eend,er2,eangle
DATA "ELLIPSE", 4
DATA 265, 329, 66.007575322837, 0, 360, 38.05259518088089, 359.1319485502544
DATA 261, 328, 21.02379604162864, 0, 360, 6.708203932499369, 357.2736890060937
DATA 244, 223, 54.3323108288245, 57.5057653062288, 334.6623339123062, 29.06888370749727, 353.6598082540901
DATA 387, 230, 52, 53.1112506642035, 295.2837836590746, 27.01851217221259, 360
DATA "ENTITY DATA END"
DATA 0
Reply
#8
draw-entities-data-move-rotate.bas
this demonstrates the obvious benefit of using the DATA option.
Code:
'this program is for waltersmind @ www.thejoyfulprogrammer.com
'how it works:
'draw something in fbcadcam and save it.
'along with the saved drawing (dxf file) will be a file called entities.dat
'entities.dat is just a normal text file which contains the data
'representation of the drawing in a format
'that can be used in a freebasic.net program such as this program.
'entities.dat can be found in the same folder as fbcadcam.exe

Declare Function mymod(n As Double,m As Integer) As Double
Declare Sub show_entities()
Declare Sub move_entities(move_x As Double, move_y As Double)
Declare Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double)
Declare Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
Declare Sub read_entity_data()
Const pi As double = 4 * Atn(1)

Dim Shared As Integer linesc,circlesc
Dim Shared As Double lines()
Dim Shared As Double circles()

Dim As Integer i,j

ScreenRes 600,600
Window (0,0)-(600,600)

linesc=0
circlesc=0

read_entity_data

show_entities
For i = 1 To 2
    Sleep 1000
    For j=1 To 100
        Cls
        move_entities(1,1)
        show_entities
        Sleep 1
    Next
    For j=1 To 100
        Cls
        move_entities(-1,-1)
        show_entities
        Sleep 1
    Next
    Sleep 500
    For j=1 To 360
        Cls
        rotate_entities(300,300,1)
        show_entities
        Sleep 1
    Next
Next
End

Sub show_entities()
    Dim As Integer i
    For i=1 To linesc
        Line(lines(i,1),lines(i,2))-(lines(i,3),lines(i,4))
    Next
    For i=1 To circlesc
        Select Case circles(i,0)
            Case 1
                Circle(circles(i,1),circles(i,2)),circles(i,3)
            Case 2
                Circle(circles(i,1),circles(i,2)),circles(i,3),,circles(i,4),circles(i,5)
            Case 3
                plotellipse(circles(i,1),circles(i,2),circles(i,3),circles(i,4),circles(i,5),circles(i,6),circles(i,7))
        End Select
    Next
End Sub

Function mymod(n As Double,m As Integer) As Double
    Select Case n
        Case 0
            mymod = 0
        Case CDbl(m)
            mymod = CDbl(m)
        Case Else
            If InStr(Str(n),"e")<>0 Then
                mymod=0
            Else
                If InStr(Str(n),".")<>0 Then
                    mymod=Val(Str(val(Mid(Str(n),1,InStr(Str(n),".")-1)) Mod m)+"."+Mid(Str(n),InStr(Str(n),".")+1))
                Else
                    mymod = (n Mod m)
                EndIf
            End If
    End Select
End Function


Sub move_entities(move_x As Double, move_y As Double)
    Dim As Integer i
    for i = 1 to linesc
        lines(i,1)+=move_x
        lines(i,2)+=move_y
        lines(i,3)+=move_x
        lines(i,4)+=move_y
    Next
    For i = 1 To circlesc
        circles(i,1)+=move_x
        circles(i,2)+=move_y
    Next
End Sub

Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double)
    Dim As Integer i,j
    Dim As Double x1,y1,x2,y2,x1p,y1p,x2p,y2p
    Dim As Double arcangle,arcstart,arcend,arcendpoint1x,arcendpoint1y,arcendpoint2x,arcendpoint2y
    
    for i = 1 to linesc
        x1p=lines(i,1)-pivot_pt_x
        y1p=lines(i,2)-pivot_pt_y
        x2p=lines(i,3)-pivot_pt_x
        y2p=lines(i,4)-pivot_pt_y
        lines(i,1)=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,2)=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        lines(i,3)=x2p*cos(rotation_angle*pi/180) - y2p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,4)=y2p*cos(rotation_angle*pi/180) + x2p*sin(rotation_angle*pi/180)+pivot_pt_y
    Next

    For i = 1 To circlesc
        x1=circles(i,1)
        y1=circles(i,2)
        x1p=x1-pivot_pt_x
        y1p=y1-pivot_pt_y
        x1=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        y1=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        Select Case circles(i,0)
            Case 1
                circles(i,1)=x1
                circles(i,2)=y1
            Case 2
                arcendpoint1x=circles(i,1)+cos(circles(i,4))*circles(i,3)
                arcendpoint1y=circles(i,2)+sin(circles(i,4))*circles(i,3)
                arcendpoint2x=circles(i,1)+cos(circles(i,5))*circles(i,3)
                arcendpoint2y=circles(i,2)+sin(circles(i,5))*circles(i,3)
                x1p=arcendpoint1x-pivot_pt_x
                y1p=arcendpoint1y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcstart=arcangle*PI/180
                x1p=arcendpoint2x-pivot_pt_x
                y1p=arcendpoint2y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcend=arcangle*PI/180
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,4)=arcstart
                circles(i,5)=arcend
            Case 3,4'rotating ellipses
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,7)=mymod(circles(i,7)+rotation_angle,360)
        End Select
    Next

End Sub


Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
    '1x,2y,3z,4r,5color,6start,7end,8aspect,9=1(circle)2(arc)3(ellips)4(ellipticalarc),10group,11 is ellipse rotation , 12 block
    Dim As Double i,x1p,y1p
    Dim As Double eplotx,eploty,eplotxp,eplotyp,easpect,eresolution,elength
    Dim As BOOLEAN eplot
    If estart>eend Then
        elength=360+eend
    Else
        elength=eend
    EndIf
    eplot=FALSE
    eresolution=1
    'plotellipse
    For i = estart To elength Step eresolution
        'Sleep 1
        'x1p=Cos(i*pi/180)*er1
        'y1p=Sin(i*pi/180)*er2
        eplotx=Cos(i*pi/180)*er1*Cos(eangle*pi/180) - Sin(i*pi/180)*er2*Sin(eangle*pi/180)+ex1
        eploty=Cos(i*pi/180)*er1*Sin(eangle*pi/180) + Sin(i*pi/180)*er2*Cos(eangle*pi/180)+ey1

        If eplot=false Then
            eplot=TRUE
        Else
            Line(eplotx,eploty)-(eplotxp,eplotyp)
        EndIf
        eplotxp=eplotx
        eplotyp=eploty
    Next

    x1p=Cos(eend*pi/180)*er1
    y1p=Sin(eend*pi/180)*er2
    eplotx=x1p*Cos(eangle*pi/180) - y1p*Sin(eangle*pi/180)+ex1
    eploty=y1p*Cos(eangle*pi/180) + x1p*Sin(eangle*pi/180)+ey1
    Line(eplotx,eploty)-(eplotxp,eplotyp)
End Sub

Sub read_entity_data()
    Dim As String entity_type
    Dim As Integer i,j,entity_count
    entity_type=""
    entity_count=0
    Do
        Read entity_type
        Read entity_count
        Select Case entity_type
            Case "ENTITY DATA START"
                'begin filling line and circle arrays
            Case "ENTITY DATA END"
                Exit Do
            Case "LINE"
                'Print "Line"
                linesc+=entity_count
                ReDim Preserve lines(linesc,4)
                For i = 1 To entity_count
                    For j=1 To 4
                        Read lines(i,j)
                        'Print lines(i,j)
                    Next
                Next
            Case "CIRCLE"
                'Print "Circle"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=1
                    For j=1 To 3
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ARC"
                'Print "Arc"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=2
                    For j=1 To 5
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ELLIPSE"
                'Print "Ellipse"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=3
                    For j=1 To 7
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
        End Select
    Loop
End Sub

Data "ENTITY DATA START"
DATA 0
'lines data x1,y1,x2,y2
DATA "LINE", 3
DATA 74, 450, 155, 519
DATA 155, 519, 188, 438
DATA 188, 438, 83, 517
'circles data x1,y1,radius
DATA "CIRCLE", 3
DATA 280, 484, 47.2652091923859
DATA 280, 484, 61.84658438426491
DATA 280, 484, 74.95331880577403
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 2
DATA 125, 322, 51.24451190127583, 0.7524430657831508, 5.650436472177402
DATA 120, 317, 28.63564212655271, 0.7242500007481463, 5.916011473361367
'ellipse data ex1,ey1,er1,estart,eend,er2,eangle
DATA "ELLIPSE", 4
DATA 265, 329, 66.007575322837, 0, 360, 38.05259518088089, 359.1319485502544
DATA 261, 328, 21.02379604162864, 0, 360, 6.708203932499369, 357.2736890060937
DATA 244, 223, 54.3323108288245, 57.5057653062288, 334.6623339123062, 29.06888370749727, 353.6598082540901
DATA 387, 230, 52, 53.1112506642035, 295.2837836590746, 27.01851217221259, 360
DATA "ENTITY DATA END"
DATA 0
Reply
#9
two gears rotating
the gear was originally drawn in fbcadcam with its center at (0,0)
after the data is read into the arrays, the array are doubled in size to hold a second copy of the gear.
first i move the two gears to the middle of the screen and rotate the first one so the gears will mesh.
then i rotate the first gear counter clock wise and the second clock wise in a loop.
press escape to exit.
[Image: two-gears.png]
draw-entities-data-move-rotate-gears.bas
Code:
'this program is for waltersmind @ www.thejoyfulprogrammer.com
'how it works:
'draw something in fbcadcam and save it.
'along with the saved drawing (dxf file) will be a file called entities.dat
'entities.dat is just a normal text file which contains the data
'representation of the drawing in a format
'that can be used in a freebasic.net program such as this program.
'entities.dat can be found in the same folder as fbcadcam.exe

Declare Function mymod(n As Double,m As Integer) As Double
Declare Sub show_entities()
Declare Sub move_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
Declare Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
Declare Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
Declare Sub read_entity_data()
Const pi As double = 4 * Atn(1)

Dim Shared As Integer linesc,circlesc
Dim Shared As Double lines()
Dim Shared As Double circles()

Dim As Integer i,j

Dim As Integer gear_1_linesc_start,gear_1_linesc_end,gear_1_circlesc_start,gear_1_circlesc_end
Dim As Integer gear_2_linesc_start,gear_2_linesc_end,gear_2_circlesc_start,gear_2_circlesc_end

ScreenRes 600,600
Window (0,0)-(600,600)

linesc=0
circlesc=0


gear_1_linesc_start=1
gear_1_circlesc_start=1

read_entity_data

gear_1_linesc_end=linesc
gear_1_circlesc_end=circlesc

ReDim Preserve lines(linesc*2,4)
ReDim Preserve circles(circlesc*2,7)

gear_2_linesc_start=linesc+1
gear_2_circlesc_start=circlesc+1
gear_2_linesc_end=linesc*2
gear_2_circlesc_end=circlesc*2

For i = gear_1_linesc_start To gear_1_linesc_end
    linesc+=1
    For j=1 To 4
        lines(linesc,j)=lines(i,j)
    Next
Next

For i = gear_1_circlesc_start To gear_1_circlesc_end
    circlesc+=1
    For j=0 To 7
        circles(circlesc,j)=circles(i,j)
    Next
Next

move_entities(300-60,300,gear_1_linesc_start,gear_1_linesc_end,gear_1_circlesc_start,gear_1_circlesc_end)
move_entities(300+80,300,gear_2_linesc_start,gear_2_linesc_end,gear_2_circlesc_start,gear_2_circlesc_end)
rotate_entities(300-60,300,22,gear_1_linesc_start,gear_1_linesc_end,gear_1_circlesc_start,gear_1_circlesc_end)

Do
    For j=1 To 360
        If InKey=Chr(27) Then Exit Do
        Cls
        rotate_entities(300-60,300,1,gear_1_linesc_start,gear_1_linesc_end,gear_1_circlesc_start,gear_1_circlesc_end)
        rotate_entities(300+80,300,-1,gear_2_linesc_start,gear_2_linesc_end,gear_2_circlesc_start,gear_2_circlesc_end)
        show_entities
        Sleep 1
    Next
Loop
End

Sub show_entities()
    Dim As Integer i
    For i=1 To linesc
        Line(lines(i,1),lines(i,2))-(lines(i,3),lines(i,4))
    Next
    For i=1 To circlesc
        Select Case circles(i,0)
            Case 1
                Circle(circles(i,1),circles(i,2)),circles(i,3)
            Case 2
                Circle(circles(i,1),circles(i,2)),circles(i,3),,circles(i,4),circles(i,5)
            Case 3
                plotellipse(circles(i,1),circles(i,2),circles(i,3),circles(i,4),circles(i,5),circles(i,6),circles(i,7))
        End Select
    Next
End Sub

Function mymod(n As Double,m As Integer) As Double
    Select Case n
        Case 0
            mymod = 0
        Case CDbl(m)
            mymod = CDbl(m)
        Case Else
            If InStr(Str(n),"e")<>0 Then
                mymod=0
            Else
                If InStr(Str(n),".")<>0 Then
                    mymod=Val(Str(val(Mid(Str(n),1,InStr(Str(n),".")-1)) Mod m)+"."+Mid(Str(n),InStr(Str(n),".")+1))
                Else
                    mymod = (n Mod m)
                EndIf
            End If
    End Select
End Function


Sub move_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
    Dim As Integer i
    for i = Ls to Le
        lines(i,1)+=move_x
        lines(i,2)+=move_y
        lines(i,3)+=move_x
        lines(i,4)+=move_y
    Next
    For i = Cs To Ce
        circles(i,1)+=move_x
        circles(i,2)+=move_y
    Next
End Sub

Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
    Dim As Integer i,j
    Dim As Double x1,y1,x2,y2,x1p,y1p,x2p,y2p
    Dim As Double arcangle,arcstart,arcend,arcendpoint1x,arcendpoint1y,arcendpoint2x,arcendpoint2y
    
    for i = Ls to Le
        x1p=lines(i,1)-pivot_pt_x
        y1p=lines(i,2)-pivot_pt_y
        x2p=lines(i,3)-pivot_pt_x
        y2p=lines(i,4)-pivot_pt_y
        lines(i,1)=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,2)=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        lines(i,3)=x2p*cos(rotation_angle*pi/180) - y2p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,4)=y2p*cos(rotation_angle*pi/180) + x2p*sin(rotation_angle*pi/180)+pivot_pt_y
    Next

    For i = Cs To Ce
        x1=circles(i,1)
        y1=circles(i,2)
        x1p=x1-pivot_pt_x
        y1p=y1-pivot_pt_y
        x1=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        y1=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        Select Case circles(i,0)
            Case 1
                circles(i,1)=x1
                circles(i,2)=y1
            Case 2
                arcendpoint1x=circles(i,1)+cos(circles(i,4))*circles(i,3)
                arcendpoint1y=circles(i,2)+sin(circles(i,4))*circles(i,3)
                arcendpoint2x=circles(i,1)+cos(circles(i,5))*circles(i,3)
                arcendpoint2y=circles(i,2)+sin(circles(i,5))*circles(i,3)
                x1p=arcendpoint1x-pivot_pt_x
                y1p=arcendpoint1y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcstart=arcangle*PI/180
                x1p=arcendpoint2x-pivot_pt_x
                y1p=arcendpoint2y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcend=arcangle*PI/180
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,4)=arcstart
                circles(i,5)=arcend
            Case 3,4'rotating ellipses
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,7)=mymod(circles(i,7)+rotation_angle,360)
        End Select
    Next

End Sub


Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
    '1x,2y,3z,4r,5color,6start,7end,8aspect,9=1(circle)2(arc)3(ellips)4(ellipticalarc),10group,11 is ellipse rotation , 12 block
    Dim As Double i,x1p,y1p
    Dim As Double eplotx,eploty,eplotxp,eplotyp,easpect,eresolution,elength
    Dim As BOOLEAN eplot
    If estart>eend Then
        elength=360+eend
    Else
        elength=eend
    EndIf
    eplot=FALSE
    eresolution=1
    'plotellipse
    For i = estart To elength Step eresolution
        'Sleep 1
        'x1p=Cos(i*pi/180)*er1
        'y1p=Sin(i*pi/180)*er2
        eplotx=Cos(i*pi/180)*er1*Cos(eangle*pi/180) - Sin(i*pi/180)*er2*Sin(eangle*pi/180)+ex1
        eploty=Cos(i*pi/180)*er1*Sin(eangle*pi/180) + Sin(i*pi/180)*er2*Cos(eangle*pi/180)+ey1

        If eplot=false Then
            eplot=TRUE
        Else
            Line(eplotx,eploty)-(eplotxp,eplotyp)
        EndIf
        eplotxp=eplotx
        eplotyp=eploty
    Next

    x1p=Cos(eend*pi/180)*er1
    y1p=Sin(eend*pi/180)*er2
    eplotx=x1p*Cos(eangle*pi/180) - y1p*Sin(eangle*pi/180)+ex1
    eploty=y1p*Cos(eangle*pi/180) + x1p*Sin(eangle*pi/180)+ey1
    Line(eplotx,eploty)-(eplotxp,eplotyp)
End Sub

Sub read_entity_data()
    Dim As String entity_type
    Dim As Integer i,j,entity_count
    entity_type=""
    entity_count=0
    Do
        Read entity_type
        Read entity_count
        Select Case entity_type
            Case "ENTITY DATA START"
                'begin filling line and circle arrays
            Case "ENTITY DATA END"
                Exit Do
            Case "LINE"
                'Print "Line"
                linesc+=entity_count
                ReDim Preserve lines(linesc,4)
                For i = 1 To entity_count
                    For j=1 To 4
                        Read lines(i,j)
                        'Print lines(i,j)
                    Next
                Next
            Case "CIRCLE"
                'Print "Circle"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=1
                    For j=1 To 3
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ARC"
                'Print "Arc"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=2
                    For j=1 To 5
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ELLIPSE"
                'Print "Ellipse"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=3
                    For j=1 To 7
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
        End Select
    Loop
End Sub

Data "ENTITY DATA START"
DATA 0
'lines data x1,y1,x2,y2
DATA "LINE", 3
DATA 15.53503320174781, 8.522854111822298, 12.91853338613899, 7.439064402250423
DATA 15.53503320174781, 8.522854111822298, 12.91853338613899, 7.439064402250423
DATA 17.01149526044719, 4.958359385380931, 14.3949954448384, 3.874569675809056
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 34
DATA 66.68395609140191,-38.49999999999984, 77, 1.570796326794897, 1.832595714594055
DATA 19.92906647289419, 74.37628862425822, 77, 5.235987755982984, 5.497787143782143
DATA 19.92906647289459,-74.37628862425812, 77, 0.7853981633974483, 1.047197551196606
DATA 66.6839560914018, 38.49999999999994, 77, 4.450589592585537, 4.712388980384688
DATA-38.5,-66.68395609140174, 77, 6.283185307179585, 0.2617993877991512
DATA 74.37628862425828,-19.92906647289404, 77, 3.665191429188092, 3.926990816987243
DATA-74.37628862425825,-19.92906647289406, 77, 5.497787143782136, 5.759586531581292
DATA 38.50000000000043,-66.68395609140154, 77, 2.879793265790646, 3.141592653589797
DATA-66.68395609140185, 38.49999999999979, 77, 4.712388980384688, 4.974188368183844
DATA-19.92906647289411,-74.37628862425827, 77, 2.094395102393194, 2.35619449019235
DATA-19.92906647289459, 74.37628862425811, 77, 3.926990816987241, 4.188790204786391
DATA 38.50000000000011, 66.68395609140174, 77, 3.141592653589793, 3.403392041388943
DATA-74.37628862425825, 19.92906647289398, 77, 0.5235987755982988, 0.7853981633974501
DATA 74.37628862425828, 19.92906647289401, 77, 2.356194490192343, 2.617993877991498
DATA-38.50000000000043, 66.68395609140151, 77, 6.021385919380439, 0.00000000000000523598775598298
DATA-66.68395609140174,-38.49999999999999, 77, 1.308996938995747, 1.570796326794897
DATA 0, 0, 77.00000000000043, 0.2617993877991512, 0.5235987755983006
DATA 0, 0, 77.00000000000001, 1.047197551196605, 1.308996938995745
DATA 0, 0, 77, 1.832595714594048, 2.094395102393195
DATA 0, 0, 76.99999999999999, 2.617993877991494, 2.879793265790647
DATA 0, 0, 77.00000000000031, 3.403392041388946, 3.665191429188094
DATA 0, 0, 76.99999999999987, 4.188790204786396, 4.450589592585541
DATA 0, 0, 77.00000000000006, 4.974188368183842, 5.235987755982989
DATA 0, 0, 77.00000000000006, 5.759586531581287, 6.021385919380441
DATA 0, 0, 58.93324858422367, 6.152285613280021, 0.1308996938995712
DATA 0, 0, 58.93324858422353, 0.654498469497877, 0.9162978572970265
DATA 0, 0, 58.93324858422353, 1.439896632895324, 1.701696020694471
DATA 0, 0, 58.93324858422376, 2.225294796292769, 2.487094184091919
DATA 0, 0, 58.93324858422432, 3.010692959690222, 3.272492347489368
DATA 0, 0, 58.93324858422368, 3.796091123087672, 4.05789051088682
DATA 0, 0, 58.93324858422356, 4.581489286485117, 4.843288674284266
DATA 0, 0, 58.93324858422367, 5.366887449882565, 5.628686837681711
DATA 0, 0, 14.90731981375651, 0.5224685963219925, 0.2629295670754627
DATA 0, 0, 17.7193763657419, 0.2836138735775202, 0.5017842898199351
DATA "ENTITY DATA END"
DATA 0
Reply
#10
two sprockets and a chain.
for now, only the sprockets are rotating.
next, i'll see if i can get the chain to move with the sprockets.
Code:
Declare Function mymod(n As Double,m As Integer) As Double
Declare Sub show_entities()
Declare Sub move_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
Declare Sub move_circle_entities(move_x As Double, move_y As Double, Cs As Integer, Ce As Integer)
Declare Sub move_line_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer)
Declare Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
Declare Sub rotate_circle_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Cs As Integer, Ce As Integer)
Declare Sub rotate_line_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer)
Declare Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
Declare Sub read_entity_data()
Const pi As double = 4 * Atn(1)

Dim Shared As Integer linesc,circlesc
Dim Shared As Double lines()
Dim Shared As Double circles()

Dim As Integer i,j,k

Dim As Integer sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end
Dim As Integer sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end
Dim As Double sprocket1x,sprocket1y,sprocket2x,sprocket2y

Dim As Integer chain_link_piece_1_circlesc_start,chain_link_piece_1_circlesc_end
Dim As Integer chain_link_piece_2_circlesc_start,chain_link_piece_2_circlesc_end
Dim As Integer chain_link_piece_3_circlesc_start,chain_link_piece_3_circlesc_end
Dim As Double clp1x,clp1y,clp2x,clp2y
Dim As Integer linksc,clp_total_entity_count,clp1cs,clp1ce,clp2cs,clp2ce,clp3cs,clp3ce

Dim As Double angle,lftotls

ScreenRes 600,600
Window (0,0)-(600,600)
'Window(50,200)-(250,400)
linesc=0
circlesc=0

sprocket_1_linesc_start=linesc+1
sprocket_1_circlesc_start=circlesc+1
read_entity_data
sprocket_1_linesc_end=linesc
sprocket_1_circlesc_end=circlesc

sprocket_2_linesc_start=linesc+1
sprocket_2_circlesc_start=circlesc+1
read_entity_data
sprocket_2_linesc_end=linesc
sprocket_2_circlesc_end=circlesc

sprocket1x=170
sprocket1y=300
sprocket2x=170+298.1563745237469
sprocket2y=300




chain_link_piece_1_circlesc_start=circlesc+1
read_entity_data
chain_link_piece_1_circlesc_end=circlesc

chain_link_piece_2_circlesc_start=circlesc+1
read_entity_data
chain_link_piece_2_circlesc_end=circlesc

chain_link_piece_3_circlesc_start=circlesc+1
read_entity_data
chain_link_piece_3_circlesc_end=circlesc

clp_total_entity_count=chain_link_piece_3_circlesc_end-chain_link_piece_1_circlesc_start+1
linksc=17
ReDim Preserve circles(circlesc+clp_total_entity_count*linksc,7)
'make 14 coppies of each link piece for a total of 15 links (1 + 14)
For i = 1 To linksc
    For j=chain_link_piece_1_circlesc_start To chain_link_piece_3_circlesc_end
        circlesc+=1
        For k=0 To 7
            circles(circlesc,k)=circles(j,k)
        Next
    Next
Next


move_entities(170,300,sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
move_entities(467.4,300,sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)

'353.6447006104083
'-6.35529938959172
'leaving from top of the large sprocket
'rotate the link -6.35529938959172
lftotls=352.5857983293379'187.414201670662
angle=lftotls
clp1x=170
clp1y=395.88679832249493
For i=0 To linksc
    Select Case i
        Case 0
            angle=352.7
        Case 5
            angle=345.00001
        Case 6 To 7
            angle-=30
        Case 8
            angle=187.22
        Case 13
            angle=171
        Case 14 To 20
            angle-=18
    End Select
    clp1cs=chain_link_piece_1_circlesc_start+clp_total_entity_count*i
    clp1ce=chain_link_piece_1_circlesc_end+clp_total_entity_count*i
    clp2cs=chain_link_piece_2_circlesc_start+clp_total_entity_count*i
    clp2ce=chain_link_piece_2_circlesc_end+clp_total_entity_count*i
    clp3cs=chain_link_piece_3_circlesc_start+clp_total_entity_count*i
    clp3ce=chain_link_piece_3_circlesc_end+clp_total_entity_count*i
    move_circle_entities(clp1x,clp1y,clp1cs,clp1ce)
    rotate_circle_entities(clp1x,clp1y,angle,clp1cs,clp1ce)
    clp1x=clp1x+cos(angle*pi/180)*30
    clp1y=clp1y+Sin(angle*pi/180)*30
    Select Case i
        Case 5 To 7
            angle-=30
        Case 13 To 20
            angle-=18
    End Select
    move_circle_entities(clp1x,clp1y,clp2cs,clp2ce)
    move_circle_entities(clp1x,clp1y,clp3cs,clp3ce)
    rotate_circle_entities(clp1x,clp1y,angle,clp2cs,clp2ce)
    rotate_circle_entities(clp1x,clp1y,angle,clp3cs,clp3ce)
    clp1x=clp1x+cos(angle*pi/180)*30
    clp1y=clp1y+Sin(angle*pi/180)*30
Next

show_entities
Sleep 1000


Do
    For j=1 To 360
        If InKey=Chr(27) Then Exit Do
        rotate_entities(sprocket1x,sprocket1y,-1,sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
        rotate_entities(sprocket2x,sprocket2y,-1,sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)
        Cls
        show_entities
        Sleep 1
    Next
Loop
End

Sub show_entities()
    ScreenLock
    Dim As Integer i
    For i=1 To linesc
        Line(lines(i,1),lines(i,2))-(lines(i,3),lines(i,4))
    Next
    For i=1 To circlesc
        Select Case circles(i,0)
            Case 1
                Circle(circles(i,1),circles(i,2)),circles(i,3)
            Case 2
                Circle(circles(i,1),circles(i,2)),circles(i,3),,circles(i,4),circles(i,5)
            Case 3
                plotellipse(circles(i,1),circles(i,2),circles(i,3),circles(i,4),circles(i,5),circles(i,6),circles(i,7))
        End Select
    Next
    ScreenUnLock
End Sub

Function mymod(n As Double,m As Integer) As Double
    Select Case n
        Case 0
            mymod = 0
        Case CDbl(m)
            mymod = CDbl(m)
        Case Else
            If InStr(Str(n),"e")<>0 Then
                mymod=0
            Else
                If InStr(Str(n),".")<>0 Then
                    mymod=Val(Str(val(Mid(Str(n),1,InStr(Str(n),".")-1)) Mod m)+"."+Mid(Str(n),InStr(Str(n),".")+1))
                Else
                    mymod = (n Mod m)
                EndIf
            End If
    End Select
End Function


Sub move_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
    Dim As Integer i
    for i = Ls to Le
        lines(i,1)+=move_x
        lines(i,2)+=move_y
        lines(i,3)+=move_x
        lines(i,4)+=move_y
    Next
    For i = Cs To Ce
        circles(i,1)+=move_x
        circles(i,2)+=move_y
    Next
End Sub

Sub move_circle_entities(move_x As Double, move_y As Double, Cs As Integer, Ce As Integer)
    Dim As Integer i
    For i = Cs To Ce
        circles(i,1)+=move_x
        circles(i,2)+=move_y
    Next
End Sub

Sub move_line_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer)
    Dim As Integer i
    for i = Ls to Le
        lines(i,1)+=move_x
        lines(i,2)+=move_y
        lines(i,3)+=move_x
        lines(i,4)+=move_y
    Next
End Sub









Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
    Dim As Integer i,j
    Dim As Double x1,y1,x2,y2,x1p,y1p,x2p,y2p
    Dim As Double arcangle,arcstart,arcend,arcendpoint1x,arcendpoint1y,arcendpoint2x,arcendpoint2y
    
    for i = Ls to Le
        x1p=lines(i,1)-pivot_pt_x
        y1p=lines(i,2)-pivot_pt_y
        x2p=lines(i,3)-pivot_pt_x
        y2p=lines(i,4)-pivot_pt_y
        lines(i,1)=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,2)=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        lines(i,3)=x2p*cos(rotation_angle*pi/180) - y2p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,4)=y2p*cos(rotation_angle*pi/180) + x2p*sin(rotation_angle*pi/180)+pivot_pt_y
    Next

    For i = Cs To Ce
        x1=circles(i,1)
        y1=circles(i,2)
        x1p=x1-pivot_pt_x
        y1p=y1-pivot_pt_y
        x1=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        y1=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        Select Case circles(i,0)
            Case 1
                circles(i,1)=x1
                circles(i,2)=y1
            Case 2
                arcendpoint1x=circles(i,1)+cos(circles(i,4))*circles(i,3)
                arcendpoint1y=circles(i,2)+sin(circles(i,4))*circles(i,3)
                arcendpoint2x=circles(i,1)+cos(circles(i,5))*circles(i,3)
                arcendpoint2y=circles(i,2)+sin(circles(i,5))*circles(i,3)
                x1p=arcendpoint1x-pivot_pt_x
                y1p=arcendpoint1y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcstart=arcangle*PI/180
                x1p=arcendpoint2x-pivot_pt_x
                y1p=arcendpoint2y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcend=arcangle*PI/180
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,4)=arcstart
                circles(i,5)=arcend
            Case 3,4'rotating ellipses
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,7)=mymod(circles(i,7)+rotation_angle,360)
        End Select
    Next
End Sub

Sub rotate_circle_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Cs As Integer, Ce As Integer)
    Dim As Integer i,j
    Dim As Double x1,y1,x2,y2,x1p,y1p,x2p,y2p
    Dim As Double arcangle,arcstart,arcend,arcendpoint1x,arcendpoint1y,arcendpoint2x,arcendpoint2y
    
    For i = Cs To Ce
        x1=circles(i,1)
        y1=circles(i,2)
        x1p=x1-pivot_pt_x
        y1p=y1-pivot_pt_y
        x1=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        y1=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        Select Case circles(i,0)
            Case 1
                circles(i,1)=x1
                circles(i,2)=y1
            Case 2
                arcendpoint1x=circles(i,1)+cos(circles(i,4))*circles(i,3)
                arcendpoint1y=circles(i,2)+sin(circles(i,4))*circles(i,3)
                arcendpoint2x=circles(i,1)+cos(circles(i,5))*circles(i,3)
                arcendpoint2y=circles(i,2)+sin(circles(i,5))*circles(i,3)
                x1p=arcendpoint1x-pivot_pt_x
                y1p=arcendpoint1y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcstart=arcangle*PI/180
                x1p=arcendpoint2x-pivot_pt_x
                y1p=arcendpoint2y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcend=arcangle*PI/180
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,4)=arcstart
                circles(i,5)=arcend
            Case 3,4'rotating ellipses
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,7)=mymod(circles(i,7)+rotation_angle,360)
        End Select
    Next
End Sub

Sub rotate_line_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer)
    Dim As Integer i,j
    Dim As Double x1p,y1p,x2p,y2p
    
    for i = Ls to Le
        x1p=lines(i,1)-pivot_pt_x
        y1p=lines(i,2)-pivot_pt_y
        x2p=lines(i,3)-pivot_pt_x
        y2p=lines(i,4)-pivot_pt_y
        lines(i,1)=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,2)=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        lines(i,3)=x2p*cos(rotation_angle*pi/180) - y2p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,4)=y2p*cos(rotation_angle*pi/180) + x2p*sin(rotation_angle*pi/180)+pivot_pt_y
    Next
End Sub













Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
    '1x,2y,3z,4r,5color,6start,7end,8aspect,9=1(circle)2(arc)3(ellips)4(ellipticalarc),10group,11 is ellipse rotation , 12 block
    Dim As Double i,x1p,y1p
    Dim As Double eplotx,eploty,eplotxp,eplotyp,easpect,eresolution,elength
    Dim As BOOLEAN eplot
    If estart>eend Then
        elength=360+eend
    Else
        elength=eend
    EndIf
    eplot=FALSE
    eresolution=1
    'plotellipse
    For i = estart To elength Step eresolution
        'Sleep 1
        'x1p=Cos(i*pi/180)*er1
        'y1p=Sin(i*pi/180)*er2
        eplotx=Cos(i*pi/180)*er1*Cos(eangle*pi/180) - Sin(i*pi/180)*er2*Sin(eangle*pi/180)+ex1
        eploty=Cos(i*pi/180)*er1*Sin(eangle*pi/180) + Sin(i*pi/180)*er2*Cos(eangle*pi/180)+ey1

        If eplot=false Then
            eplot=TRUE
        Else
            Line(eplotx,eploty)-(eplotxp,eplotyp)
        EndIf
        eplotxp=eplotx
        eplotyp=eploty
    Next

    x1p=Cos(eend*pi/180)*er1
    y1p=Sin(eend*pi/180)*er2
    eplotx=x1p*Cos(eangle*pi/180) - y1p*Sin(eangle*pi/180)+ex1
    eploty=y1p*Cos(eangle*pi/180) + x1p*Sin(eangle*pi/180)+ey1
    Line(eplotx,eploty)-(eplotxp,eplotyp)
End Sub

Sub read_entity_data()
    Dim As String entity_type
    Dim As Integer i,j,entity_count
    entity_type=""
    entity_count=0
    Do
        Read entity_type
        Read entity_count
        Select Case entity_type
            Case "ENTITY DATA START"
                'begin filling line and circle arrays
            Case "ENTITY DATA END"
                Exit Do
            Case "LINE"
                'Print "Line"
                linesc+=entity_count
                ReDim Preserve lines(linesc,4)
                For i = linesc-entity_count+1 To linesc
                    For j=1 To 4
                        Read lines(i,j)
                        'Print lines(i,j)
                    Next
                Next
            Case "CIRCLE"
                'Print "Circle"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=1
                    For j=1 To 3
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ARC"
                'Print "Arc"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=2
                    For j=1 To 5
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ELLIPSE"
                'Print "Ellipse"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=3
                    For j=1 To 7
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
        End Select
    Loop
End Sub

'big sprocket
Data "ENTITY DATA START"
DATA 0
'lines data x1,y1,x2,y2
DATA "LINE", 41
DATA-97.9202480392088, 6.072364661790445,-99.87901299359182, 13.03107389343951
DATA-95.00415385146233, 24.48385875660966,-99.01740943671227, 18.471024655737
DATA-95.00415385146239,-24.48385875660942,-99.01740943671233,-18.47102465573676
DATA-97.92024803920883,-6.072364661790189,-99.87901299359187,-13.03107389343926
DATA-82.7883911518724,-52.64343149083753,-88.46329194930918,-48.16505061641327
DATA-91.25122609839222,-36.03418271844164,-90.96376286065539,-43.25760013709514
DATA-62.46872390569825,-75.64989836238762,-69.24977108590986,-73.14434583711476
DATA-75.6498983623878,-62.46872390569804,-73.14434583711497,-69.24977108590967
DATA-36.03418271844185,-91.25122609839211,-43.25760013709537,-90.96376286065528
DATA-52.64343149083776,-82.78839115187229,-48.16505061641353,-88.46329194930904
DATA-6.07236466179045,-97.9202480392088,-13.03107389343952,-99.87901299359182
DATA-24.48385875660967,-95.00415385146231,-18.47102465573702,-99.01740943671227
DATA 24.48385875660942,-95.00415385146239, 18.47102465573675,-99.01740943671233
DATA 6.072364661790182,-97.92024803920883, 13.03107389343925,-99.87901299359184
DATA 52.64343149083753,-82.78839115187243, 48.16505061641328,-88.46329194930918
DATA 36.03418271844162,-91.25122609839225, 43.25760013709513,-90.96376286065542
DATA 75.64989836238763,-62.46872390569827, 73.14434583711477,-69.24977108590984
DATA 62.46872390569806,-75.64989836238782, 69.24977108590966,-73.14434583711496
DATA 91.25122609839212,-36.03418271844187, 90.96376286065529,-43.25760013709537
DATA 82.7883911518723,-52.64343149083776, 88.46329194930904,-48.16505061641352
DATA 97.92024803920879,-6.072364661790459, 99.8790129935918,-13.03107389343953
DATA 95.00415385146233,-24.48385875660968, 99.01740943671229,-18.47102465573703
DATA 95.00415385146238, 24.48385875660941, 99.01740943671233, 18.47102465573674
DATA 97.92024803920883, 6.072364661790175, 99.87901299359184, 13.03107389343924
DATA 82.78839115187243, 52.64343149083753, 88.46329194930915, 48.16505061641327
DATA 91.25122609839224, 36.03418271844164, 90.96376286065539, 43.25760013709511
DATA 62.46872390569824, 75.64989836238762, 69.24977108590984, 73.14434583711476
DATA 75.64989836238782, 62.46872390569804, 73.14434583711496, 69.24977108590964
DATA 36.03418271844188, 91.25122609839211, 43.25760013709538, 90.96376286065525
DATA 52.64343149083777, 82.78839115187229, 48.16505061641352, 88.46329194930904
DATA 6.072364661790466, 97.92024803920877, 13.03107389343953, 99.87901299359179
DATA 24.48385875660969, 95.00415385146233, 18.47102465573703, 99.01740943671227
DATA-24.48385875660939, 95.00415385146239,-18.47102465573673, 99.01740943671233
DATA-6.072364661790184, 97.92024803920883,-13.03107389343924, 99.87901299359184
DATA-52.64343149083752, 82.78839115187243,-48.16505061641326, 88.46329194930918
DATA-36.03418271844161, 91.25122609839225,-43.25760013709513, 90.96376286065542
DATA-75.64989836238765, 62.46872390569824,-73.14434583711476, 69.24977108590984
DATA-62.46872390569804, 75.64989836238782,-69.24977108590964, 73.14434583711496
DATA-91.25122609839211, 36.03418271844187,-90.96376286065525, 43.25760013709537
DATA-82.78839115187229, 52.64343149083778,-88.46329194930904, 48.16505061641352
DATA 0, 0, 3.3750779948604e-014, 95.88679832249493
'circles data x1,y1,radius
DATA "CIRCLE", 1
DATA 0, 0, 19.39421899515231
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 80
DATA-95.88679832249493, 1.4210854715e-014, 5.3851648071345, 4.839942021295272, 1.612405967231461
DATA-93.54028134689141, 14.8153251089273, 9.778725152391161, 4.247965142473813, 4.446394041093257
DATA-93.54028134689141, 14.8153251089273, 9.778725152391161, 1.522632000727353, 1.721060899346796
DATA-93.54028134689141, 14.8153251089273, 6.58506425852097, 2.553049150547038, 3.415976891273562
DATA-91.193764371288,-29.63065021785411, 5.3851648071345, 5.154101286654246, 1.92656523259044
DATA-93.54028134689149,-14.81532510892681, 9.778725152391161, 4.562124407832798, 4.760553306452237
DATA-93.54028134689149,-14.81532510892681, 9.778725152391161, 1.836791266086334, 2.035220164705774
DATA-93.54028134689149,-14.81532510892681, 6.58506425852097, 2.867208415906022, 3.73013615663255
DATA-77.5740493791016,-56.36084594350514, 5.3851648071345, 5.468260552013228, 2.240724497949415
DATA-84.38390687519488,-42.99574808067943, 9.778725152391161, 4.876283673191771, 5.074712571811213
DATA-84.38390687519488,-42.99574808067943, 9.778725152391161, 2.150950531445313, 2.349379430064753
DATA-84.38390687519488,-42.99574808067943, 6.58506425852097, 3.181367681264999, 4.044295421991523
DATA-56.3608459435052,-77.57404937910157, 5.3851648071345, 5.782419817372208, 2.554883763308393
DATA-66.96744766130357,-66.96744766130321, 9.778725152391161, 5.190442938550754, 5.388871837170198
DATA-66.96744766130357,-66.96744766130321, 9.778725152391161, 2.465109796804287, 2.663538695423732
DATA-66.96744766130357,-66.96744766130321, 6.58506425852097, 3.495526946623976, 4.358454687350502
DATA-29.63065021785415,-91.19376437128797, 5.3851648071345, 6.096579082731184, 2.869043028667383
DATA-42.99574808067986,-84.38390687519468, 9.778725152391161, 5.504602203909734, 5.703031102529175
DATA-42.99574808067986,-84.38390687519468, 9.778725152391161, 2.77926906216327, 2.97769796078271
DATA-42.99574808067986,-84.38390687519468, 6.58506425852097, 3.809686211982957, 4.672613952709483
DATA-1.953992523340276e-014,-95.88679832249493, 5.3851648071345, 0.1275530409105824, 3.183202294026359
DATA-14.8153251089273,-93.54028134689141, 9.778725152391161, 5.818761469268709, 6.01719036788815
DATA-14.8153251089273,-93.54028134689141, 9.778725152391161, 3.093428327522249, 3.291857226141691
DATA-14.8153251089273,-93.54028134689141, 6.58506425852097, 4.123845477341936, 4.986773218068459
DATA 29.6306502178541,-91.193764371288, 5.3851648071345, 0.4417123062695653, 3.497361559385338
DATA 14.81532510892682,-93.54028134689149, 9.778725152391161, 6.132920734627694, 0.04816432606754741
DATA 14.81532510892682,-93.54028134689149, 9.778725152391161, 3.40758759288123, 3.60601649150067
DATA 14.81532510892682,-93.54028134689149, 6.58506425852097, 4.438004742700917, 5.300932483427442
DATA 56.36084594350514,-77.57404937910162, 5.3851648071345, 0.7558715716285392, 3.811520824744314
DATA 42.99574808067943,-84.38390687519488, 9.778725152391161, 0.1638946928070797, 0.3623235914265215
DATA 42.99574808067943,-84.38390687519488, 9.778725152391161, 3.721746858240208, 3.920175756859651
DATA 42.99574808067943,-84.38390687519488, 6.58506425852097, 4.752164008059895, 5.615091748786417
DATA 77.57404937910158,-56.3608459435052, 5.3851648071345, 1.070030836987521, 4.125680090103296
DATA 66.96744766130321,-66.96744766130355, 9.778725152391161, 0.4780539581660643, 0.6764828567855078
DATA 66.96744766130321,-66.96744766130355, 9.778725152391161, 4.035906123599186, 4.234335022218629
DATA 66.96744766130321,-66.96744766130355, 6.58506425852097, 5.066323273418876, 5.929251014145397
DATA 91.19376437128798,-29.63065021785415, 5.3851648071345, 1.384190102346496, 4.439839355462276
DATA 84.38390687519468,-42.99574808067986, 9.778725152391161, 0.7922132235250471, 0.9906421221444854
DATA 84.38390687519468,-42.99574808067986, 9.778725152391161, 4.350065388958166, 4.548494287577609
DATA 84.38390687519468,-42.99574808067986, 6.58506425852097, 5.380482538777852, 6.24341027950438
DATA 95.88679832249491,-2.842170943040401e-014, 5.3851648071345, 1.698349367705476, 4.753998620821255
DATA 93.54028134689142,-14.81532510892731, 9.778725152391161, 1.106372488884023, 1.304801387503465
DATA 93.54028134689142,-14.81532510892731, 9.778725152391161, 4.664224654317144, 4.862653552936588
DATA 93.54028134689142,-14.81532510892731, 6.58506425852097, 5.694641804136832, 0.2743842376837707
DATA 91.193764371288, 29.63065021785411, 5.3851648071345, 2.012508633064455, 5.068157886180231
DATA 93.54028134689149, 14.81532510892681, 9.778725152391161, 1.420531754243002, 1.618960652862446
DATA 93.54028134689149, 14.81532510892681, 9.778725152391161, 4.978383919676126, 5.176812818295567
DATA 93.54028134689149, 14.81532510892681, 6.58506425852097, 6.008801069495812, 0.5885435030427483
DATA 77.57404937910161, 56.36084594350514, 5.3851648071345, 2.326667898423436, 5.38231715153921
DATA 84.3839068751949, 42.99574808067943, 9.778725152391161, 1.734691019601983, 1.933119918221423
DATA 84.3839068751949, 42.99574808067943, 9.778725152391161, 5.292543185035105, 5.490972083654545
DATA 84.3839068751949, 42.99574808067943, 6.58506425852097, 0.03977502767520338, 0.902702768401731
DATA 56.36084594350518, 77.57404937910157, 5.3851648071345, 2.640827163782412, 5.696476416898193
DATA 66.96744766130355, 66.96744766130321, 9.778725152391161, 2.048850284960963, 2.247279183580403
DATA 66.96744766130355, 66.96744766130321, 9.778725152391161, 5.606702450394082, 5.805131349013524
DATA 66.96744766130355, 66.96744766130321, 6.58506425852097, 0.3539342930341827, 1.216862033760707
DATA 29.63065021785415, 91.19376437128797, 5.3851648071345, 2.954986429141391, 6.010635682257174
DATA 42.99574808067987, 84.38390687519468, 9.778725152391161, 2.363009550319942, 2.561438448939382
DATA 42.99574808067987, 84.38390687519468, 9.778725152391161, 5.920861715753063, 6.119290614372505
DATA 42.99574808067987, 84.38390687519468, 6.58506425852097, 0.668093558393162, 1.53102129911969
DATA 3.3750779948604e-014, 95.88679832249493, 5.3851648071345, 3.269145694500375, 0.04160964043656391
DATA 14.81532510892732, 93.54028134689141, 9.778725152391161, 2.67716881567892, 2.875597714298361
DATA 14.81532510892732, 93.54028134689141, 9.778725152391161, 6.235020981112044, 0.1502645725518996
DATA 14.81532510892732, 93.54028134689141, 6.58506425852097, 0.982252823752143, 1.845180564478671
DATA-29.63065021785412, 91.193764371288, 5.3851648071345, 3.583304959859355, 0.3557689057955362
DATA-14.81532510892681, 93.54028134689149, 9.778725152391161, 2.991328081037897, 3.189756979657341
DATA-14.81532510892681, 93.54028134689149, 9.778725152391161, 0.2659949392914371, 0.4644238379108789
DATA-14.81532510892681, 93.54028134689149, 6.58506425852097, 1.296412089111122, 2.159339829837648
DATA-56.36084594350513, 77.5740493791016, 5.3851648071345, 3.897464225218333, 0.6699281711545243
DATA-42.99574808067943, 84.38390687519491, 9.778725152391161, 3.305487346396878, 3.50391624501632
DATA-42.99574808067943, 84.38390687519491, 9.778725152391161, 0.5801542046504129, 0.7785831032698581
DATA-42.99574808067943, 84.38390687519491, 6.58506425852097, 1.6105713544701, 2.473499095196629
DATA-77.57404937910157, 56.3608459435052, 5.3851648071345, 4.211623490577313, 0.9840874365135036
DATA-66.96744766130318, 66.96744766130355, 9.778725152391161, 3.619646611755859, 3.818075510375299
DATA-66.96744766130318, 66.96744766130355, 9.778725152391161, 0.8943134700093941, 1.092742368628841
DATA-66.96744766130318, 66.96744766130355, 6.58506425852097, 1.924730619829079, 2.787658360555602
DATA-91.19376437128797, 29.63065021785415, 5.3851648071345, 4.525782755936287, 1.298246701872485
DATA-84.38390687519468, 42.99574808067986, 9.778725152391161, 3.93380587711484, 4.132234775734278
DATA-84.38390687519468, 42.99574808067986, 9.778725152391161, 1.208472735368373, 1.406901633987815
DATA-84.38390687519468, 42.99574808067986, 6.58506425852097, 2.238889885188053, 3.101817625914583
DATA "ENTITY DATA END"
DATA 0

'small sprocket
Data "ENTITY DATA START"
DATA 0
'lines data x1,y1,x2,y2
DATA "LINE", 25
DATA-24.25747214638355, 54.51848019438589,-18.69707641887519, 59.13826305407355
DATA-6.251652986831032, 59.34312489724883,-13.37698837179155, 60.56377634995207
DATA-48.2668272075545, 35.08565275086517,-45.76127468228165, 41.86669993107675
DATA-35.08565275086495, 48.26682720755485,-41.86669993107654, 45.76127468228197
DATA-59.34312489724877, 6.251652986831377,-60.56377634995199, 13.37698837179189
DATA-54.51848019438584, 24.25747214638389,-59.13826305407347, 18.69707641887555
DATA-54.51848019438591,-24.25747214638349,-59.13826305407356,-18.69707641887513
DATA-59.34312489724884,-6.251652986830977,-60.56377634995209,-13.3769883717915
DATA-35.08565275086517,-48.2668272075545,-41.8666999310768,-45.76127468228166
DATA-48.26682720755475,-35.08565275086492,-45.76127468228192,-41.86669993107652
DATA-6.251652986831377,-59.34312489724877,-13.37698837179189,-60.56377634995199
DATA-24.25747214638389,-54.51848019438584,-18.69707641887555,-59.13826305407347
DATA 24.25747214638355,-54.51848019438589, 18.69707641887519,-59.13826305407355
DATA 6.251652986831032,-59.34312489724883, 13.37698837179155,-60.56377634995207
DATA 48.2668272075545,-35.08565275086517, 45.76127468228166,-41.8666999310768
DATA 35.08565275086492,-48.26682720755475, 41.86669993107652,-45.76127468228192
DATA 59.34312489724877,-6.251652986831377, 60.56377634995199,-13.37698837179189
DATA 54.51848019438584,-24.25747214638389, 59.13826305407347,-18.69707641887555
DATA 54.51848019438591, 24.25747214638349, 59.13826305407356, 18.69707641887513
DATA 59.34312489724884, 6.251652986830977, 60.56377634995209, 13.3769883717915
DATA 35.08565275086517, 48.2668272075545, 41.86669993107687, 45.76127468228167
DATA 48.26682720755475, 35.08565275086492, 45.76127468228187, 41.8666999310765
DATA 6.251652986831377, 59.34312489724877, 13.37698837179189, 60.56377634995199
DATA 24.25747214638389, 54.51848019438584, 18.69707641887555, 59.13826305407347
DATA 0, 0, 5.87446757904786e-014, 57.95554957734412
'circles data x1,y1,radius
DATA "CIRCLE", 1
DATA 0, 0, 11.01923788646684
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 48
DATA-28.97777478867205, 50.19097822426848, 5.3851648071345, 3.688024714979013, 0.460488660915196
DATA-14.48888739433575, 54.07326390080636, 9.778725152391161, 3.096047836157557, 3.294476734777001
DATA-14.48888739433575, 54.07326390080636, 9.778725152391161, 0.3707146944110952, 0.5691435930305386
DATA-14.48888739433575, 54.07326390080636, 6.58506425852097, 1.401131844230782, 2.264059584957308
DATA-50.19097822426848, 28.97777478867205, 5.3851648071345, 4.211623490577305, 0.984087436513495
DATA-39.5843765064701, 39.58437650647054, 9.778725152391161, 3.619646611755854, 3.818075510375299
DATA-39.5843765064701, 39.58437650647054, 9.778725152391161, 0.8943134700093941, 1.092742368628841
DATA-39.5843765064701, 39.58437650647054, 6.58506425852097, 1.924730619829083, 2.787658360555608
DATA-57.95554957734413, 1.067878424576563e-013, 5.3851648071345, 4.735222266175607, 1.507686212111794
DATA-54.07326390080625, 14.48888739433632, 9.778725152391161, 4.143245387354153, 4.3416742859736
DATA-54.07326390080625, 14.48888739433632, 9.778725152391161, 1.417912245607691, 1.616341144227137
DATA-54.07326390080625, 14.48888739433632, 6.58506425852097, 2.44832939542738, 3.311257136153909
DATA-50.19097822426853,-28.97777478867207, 5.3851648071345, 5.258821041773906, 2.031284987710093
DATA-54.07326390080643,-14.48888739433571, 9.778725152391161, 4.666844162952454, 4.865273061571899
DATA-54.07326390080643,-14.48888739433571, 9.778725152391161, 1.941511021205992, 2.139939919825437
DATA-54.07326390080643,-14.48888739433571, 6.58506425852097, 2.97192817102568, 3.834855911752206
DATA-28.9777747886721,-50.19097822426849, 5.3851648071345, 5.782419817372201, 2.554883763308391
DATA-39.58437650647054,-39.5843765064701, 9.778725152391161, 5.19044293855075, 5.388871837170198
DATA-39.58437650647054,-39.5843765064701, 9.778725152391161, 2.465109796804289, 2.663538695423734
DATA-39.58437650647054,-39.5843765064701, 6.58506425852097, 3.495526946623978, 4.358454687350507
DATA-5.87446757904786e-014,-57.95554957734412, 5.3851648071345, 0.02283328579091916, 3.07848253890669
DATA-14.48888739433632,-54.07326390080625, 9.778725152391161, 5.714041714149051, 5.912470612768496
DATA-14.48888739433632,-54.07326390080625, 9.778725152391161, 2.988708572402589, 3.187137471022033
DATA-14.48888739433632,-54.07326390080625, 6.58506425852097, 4.019125722222277, 4.882053462948803
DATA 28.97777478867207,-50.19097822426853, 5.3851648071345, 0.5464320613892163, 3.602081314504988
DATA 14.48888739433576,-54.07326390080642, 9.778725152391161, 6.23764048974735, 0.1528840811872107
DATA 14.48888739433576,-54.07326390080642, 9.778725152391161, 3.512307348000888, 3.710736246620333
DATA 14.48888739433576,-54.07326390080642, 6.58506425852097, 4.542724497820575, 5.405652238547104
DATA 50.19097822426849,-28.9777747886721, 5.3851648071345, 1.070030836987512, 4.125680090103288
DATA 39.5843765064701,-39.58437650647054, 9.778725152391161, 0.4780539581660626, 0.6764828567855078
DATA 39.5843765064701,-39.58437650647054, 9.778725152391161, 4.035906123599186, 4.234335022218632
DATA 39.5843765064701,-39.58437650647054, 6.58506425852097, 5.066323273418876, 5.929251014145402
DATA 57.95554957734413,-1.067878424576563e-013, 5.3851648071345, 1.593629612585816, 4.649278865701581
DATA 54.07326390080625,-14.48888739433632, 9.778725152391161, 1.001652733764362, 1.200081632383808
DATA 54.07326390080625,-14.48888739433632, 9.778725152391161, 4.559504899197487, 4.757933797816929
DATA 54.07326390080625,-14.48888739433632, 6.58506425852097, 5.589922049017172, 0.1696644825641127
DATA 50.19097822426858, 28.97777478867208, 5.3851648071345, 2.117228388184113, 5.172877641299886
DATA 54.07326390080648, 14.48888739433572, 9.778725152391161, 1.52525150936266, 1.723680407982106
DATA 54.07326390080648, 14.48888739433572, 9.778725152391161, 5.083103674795785, 5.28153257341523
DATA 54.07326390080648, 14.48888739433572, 6.58506425852097, 6.113520824615471, 0.6932632581624133
DATA 28.97777478867215, 50.19097822426851, 5.3851648071345, 2.640827163782413, 5.696476416898179
DATA 39.58437650647056, 39.58437650647005, 9.778725152391161, 2.048850284960961, 2.247279183580404
DATA 39.58437650647056, 39.58437650647005, 9.778725152391161, 5.606702450394082, 5.80513134901353
DATA 39.58437650647056, 39.58437650647005, 6.58506425852097, 0.3539342930341862, 1.216862033760712
DATA 5.87446757904786e-014, 57.95554957734412, 5.3851648071345, 3.164425939380712, 6.220075192496474
DATA 14.48888739433632, 54.07326390080625, 9.778725152391161, 2.572449060559258, 2.770877959178705
DATA 14.48888739433632, 54.07326390080625, 9.778725152391161, 6.130301225992383, 0.04554481743223981
DATA 14.48888739433632, 54.07326390080625, 6.58506425852097, 0.8775330686324797, 1.740460809359009
DATA "ENTITY DATA END"
DATA 0


'chain piece 1
Data "ENTITY DATA START"
DATA 0
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 8
DATA 15, 9.42809041582052, 7.716909687891069, 3.702733079760211, 5.722044881009169
DATA 15,-9.428090415820577, 7.716909687891069, 0.5611404261704176, 2.580452227419375
DATA 0, 0, 9.999999999999982, 0.5611404261704158, 1.570796326794897
DATA 0, 0, 9.999999999999982, 4.71238898038469, 5.72204488100917
DATA 0, 0, 5.385164807134504, 4.71238898038469, 1.570796326794897
DATA 30, 0, 5.385164807134504, 1.570796326794897, 4.71238898038469
DATA 30, 0, 9.999999999999982, 1.570796326794897, 2.580452227419377
DATA 30, 0, 9.999999999999982, 3.702733079760208, 4.712388980384688
DATA "ENTITY DATA END"
DATA 0

'chain piece 2
Data "ENTITY DATA START"
DATA 0
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 6
DATA 15, 9.428090415820492, 7.716909687891069, 3.702733079760211, 5.722044881009169
DATA 15,-9.428090415820606, 7.716909687891069, 0.5611404261704176, 2.580452227419375
DATA 0, 0, 5.385164807134504, 4.71238898038469, 1.570796326794897
DATA 30, 0, 9.999999999999982, 1.570796326794897, 4.71238898038469
DATA 30, 0, 5.385164807134504, 1.570796326794897, 4.71238898038469
DATA 0, 0, 9.999999999999982, 4.71238898038469, 7.853981633974483
DATA "ENTITY DATA END"
DATA 0



'chain piece 3
Data "ENTITY DATA START"
DATA 0
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 4
DATA 30.00000000000001, 0, 9.999999999999982, 0.5611404261704158, 2.580452227419379
DATA 30.00000000000001, 0, 9.999999999999982, 3.702733079760208, 5.72204488100917
DATA-5.329070518200751e-015, 0, 9.999999999999982, 0.5611404261704158, 2.580452227419379
DATA-5.329070518200751e-015, 0, 9.999999999999982, 3.702733079760208, 5.72204488100917
DATA "ENTITY DATA END"
DATA 0
Reply
#11
chain moves as sprockets rotate
[Image: draw-entities-data-move-rotate-chain-sprockets.png]
draw-entities-data-move-rotate-chain-sprockets.bas
Code:
'chain and sprockets
'the initial drawing for the sprockets and chain links
'were drawn using fbcadcam.
'owen reese, fbcadcam.com opreese@gmail.com

'up and down arrow keys speed up and slow down
'mouse wheel zoom in and out
'press esc to end.

Declare Function mymod(n As Double,m As Integer) As Double
Declare Sub show_entities()
Declare Sub move_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
Declare Sub move_circle_entities(move_x As Double, move_y As Double, Cs As Integer, Ce As Integer)
Declare Sub move_line_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer)
Declare Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
Declare Sub rotate_circle_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Cs As Integer, Ce As Integer)
Declare Sub rotate_line_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer)
Declare Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
Declare Sub read_entity_data()
Declare Sub zoomoutpan()
Declare Sub zoominpan()

Const pi As double = 4 * Atn(1)

Dim Shared As Integer linesc,circlesc
Dim Shared As Double lines()
Dim Shared As Double circles()
Dim Shared As Double chain_init()
Dim As Integer i,j,k,m,n,c,cc,speed

Dim Shared As Integer sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end
Dim Shared As Integer sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end
Dim As Double sprocket1x,sprocket1y,sprocket1r,sprocket2x,sprocket2y,sprocket2r

Dim Shared As Integer chain_link_piece_1_circlesc_start,chain_link_piece_1_circlesc_end
Dim Shared As Integer chain_link_piece_2_circlesc_start,chain_link_piece_2_circlesc_end
Dim As Integer chain_link_piece_3_circlesc_start,chain_link_piece_3_circlesc_end
Dim As Double clpx,clpy,clpx1,clpy1,clpx2,clpy2
Dim As Integer clpi,linksc,clp_total_entity_count,clp1cs,clp1ce,clp2cs,clp2ce,clp3cs,clp3ce

Dim As Double ac,angle,a1x,a1y,a2x,a2y

Dim As Double cpath(1079,2)

Dim Shared As Integer wx1,wy1,wx2,wy2,wzoom,wzoomt,maxzoomin,maxzoomout
Dim Shared As Integer mousex,mousey,mousew,mousewp,mouse_in_window

wzoom=20
wzoomt=20
maxzoomin=100
maxzoomout=10000


wx1=0
wy1=0
wx2=600
wy2=600

ScreenRes 600,600
window (wx1,wy1)-(wx2,wy2)
linesc=0
circlesc=0

sprocket_1_linesc_start=linesc+1
sprocket_1_circlesc_start=circlesc+1
read_entity_data
sprocket_1_linesc_end=linesc
sprocket_1_circlesc_end=circlesc

sprocket_2_linesc_start=linesc+1
sprocket_2_circlesc_start=circlesc+1
read_entity_data
sprocket_2_linesc_end=linesc
sprocket_2_circlesc_end=circlesc

sprocket1x=170
sprocket1y=300
sprocket1r=95.88679832249493
sprocket2x=467.592372833434
sprocket2y=300
sprocket2r=57.9555495773441



chain_link_piece_1_circlesc_start=circlesc+1
read_entity_data
chain_link_piece_1_circlesc_end=circlesc

chain_link_piece_2_circlesc_start=circlesc+1
read_entity_data
chain_link_piece_2_circlesc_end=circlesc

chain_link_piece_3_circlesc_start=circlesc+1
read_entity_data
chain_link_piece_3_circlesc_end=circlesc

clp_total_entity_count=chain_link_piece_3_circlesc_end-chain_link_piece_1_circlesc_start+1
linksc=17
ReDim Preserve circles(circlesc+clp_total_entity_count*linksc,7)
'make 17 more coppies of each link piece for a total of 18 links
For i = 1 To linksc
    For j=chain_link_piece_1_circlesc_start To chain_link_piece_3_circlesc_end
        circlesc+=1
        For k=0 To 7
            circles(circlesc,k)=circles(j,k)
        Next
    Next
Next

ReDim chain_init(clp_total_entity_count*(linksc+1),7)
c=0
For i = 0 To linksc
    For j=chain_link_piece_1_circlesc_start To chain_link_piece_3_circlesc_end
        c+=1
        For k=0 To 7
            chain_init(c,k)=circles(j,k)
        Next
    Next
Next

move_entities(170,300,sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
move_entities(467.4,300,sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)


'build a path for the chain to follow
a1x=sprocket1x+Cos(90*pi/180)*sprocket1r
a1y=sprocket1y+Sin(90*pi/180)*sprocket1r
a2x=sprocket2x+cos(90*pi/180)*sprocket2r
a2y=sprocket2y+Sin(90*pi/180)*sprocket2r
angle=atan2(a2y-a1y,a2x-a1x)/pi*180
'from top left to top right
c=-1
For i = 1 To 300
    c+=1
    cpath(c,1)=a1x+cos(angle*pi/180)*(i-1)
    cpath(c,2)=a1y+Sin(angle*pi/180)*(i-1)
Next
'around small sprocket
For i = 1 To 180
    c+=1
    cpath(c,1)=sprocket2x+Cos((90-i+1)*pi/180)*sprocket2r
    cpath(c,2)=sprocket2y+Sin((90-i+1)*pi/180)*sprocket2r
Next
'from bottom right to bottom left
a1x=sprocket2x+Cos(270*pi/180)*sprocket2r
a1y=sprocket2y+Sin(270*pi/180)*sprocket2r
a2x=sprocket1x+cos(270*pi/180)*sprocket1r
a2y=sprocket1y+Sin(270*pi/180)*sprocket1r
angle=atan2(a2y-a1y,a2x-a1x)/pi*180
For i = 1 To 300
    c+=1
    cpath(c,1)=a1x+cos(angle*pi/180)*(i-1)
    cpath(c,2)=a1y+Sin(angle*pi/180)*(i-1)
Next
'around the big sprockte
For i = 1 To 300
    c+=1
    cpath(c,1)=sprocket1x+Cos((270-(i-1)*.6)*pi/180)*sprocket1r
    cpath(c,2)=sprocket1y+Sin((270-(i-1)*.6)*pi/180)*sprocket1r
Next

For i=0 To linksc
    clp1cs=chain_link_piece_1_circlesc_start+clp_total_entity_count*i
    clp1ce=chain_link_piece_1_circlesc_end+clp_total_entity_count*i
    clp2cs=chain_link_piece_2_circlesc_start+clp_total_entity_count*i
    clp2ce=chain_link_piece_2_circlesc_end+clp_total_entity_count*i
    clp3cs=chain_link_piece_3_circlesc_start+clp_total_entity_count*i
    clp3ce=chain_link_piece_3_circlesc_end+clp_total_entity_count*i
    
    a1x=cpath(i*60,1)
    a1y=cpath(i*60,2)
    a2x=cpath(i*60+30,1)
    a2y=cpath(i*60+30,2)
    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
    clpx=a1x
    clpy=a1y
    move_circle_entities(clpx,clpy,clp1cs,clp1ce)
    move_circle_entities(clpx,clpy,clp3cs,clp3ce)
    rotate_circle_entities(clpx,clpy,angle,clp1cs,clp1ce)
    rotate_circle_entities(clpx,clpy,angle,clp3cs,clp3ce)

    Select Case i
        Case 0 To 16
            a1x=cpath(i*60+30,1)
            a1y=cpath(i*60+30,2)
            a2x=cpath(i*60+60,1)
            a2y=cpath(i*60+60,2)
            angle=atan2(a2y-a1y,a2x-a1x)/pi*180
            clpx=a1x
            clpy=a1y
            move_circle_entities(clpx,clpy,clp2cs,clp2ce)
            rotate_circle_entities(clpx,clpy,angle,clp2cs,clp2ce)
        Case 17
            a1x=cpath(i*60+30,1)
            a1y=cpath(i*60+30,2)
            a2x=cpath(0,1)
            a2y=cpath(0,2)
            angle=atan2(a2y-a1y,a2x-a1x)/pi*180
            clpx=a1x
            clpy=a1y
            move_circle_entities(clpx,clpy,clp2cs,clp2ce)
            rotate_circle_entities(clpx,clpy,angle,clp2cs,clp2ce)
    End Select
Next

show_entities
Sleep 1000

speed=1
Do
    c=0
    For j=1 To 360 Step speed
        Select Case InKey
            Case Chr(27),Chr(255)+"k"
                End
            Case Chr(255)+"H"
                If speed<10 Then
                    rotate_entities(sprocket1x,sprocket1y,-.6*(361-j),sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
                    rotate_entities(sprocket2x,sprocket2y,-1*(361-j),sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)
                    speed+=1
                    Exit For
                EndIf
            Case Chr(255)+"P"
                If speed>1 Then
                    rotate_entities(sprocket1x,sprocket1y,-.6*(361-j),sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
                    rotate_entities(sprocket2x,sprocket2y,-1*(361-j),sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)
                    speed-=1
                    Exit For
                EndIf
        End Select
        mouse_in_window=GetMouse(mousex,mousey,mousew)
        If mouse_in_window=0 Then
            mousey=600-mousey
            mousex=wx1+(wx2-wx1)*(mousex/600)
            mousey=wy1+(wy2-wy1)*(mousey/600)
            If mousew<>mousewp Then
                If mousew>mousewp Then
                    zoominpan
                Else
                    zoomoutpan
                EndIf
                mousewp=mousew
                ScreenLock
                window (wx1,wy1)-(wx2,wy2)
                ScreenUnLock
            EndIf
        EndIf
        
        'rotate the sprockets
        rotate_entities(sprocket1x,sprocket1y,-.6*speed,sprocket_1_linesc_start,sprocket_1_linesc_end,sprocket_1_circlesc_start,sprocket_1_circlesc_end)
        rotate_entities(sprocket2x,sprocket2y,-1*speed,sprocket_2_linesc_start,sprocket_2_linesc_end,sprocket_2_circlesc_start,sprocket_2_circlesc_end)
        'put them back to zero
        cc=0
        For i = 0 To linksc
            For m=chain_link_piece_1_circlesc_start To chain_link_piece_3_circlesc_end
                cc+=1
                For n=0 To 7
                    circles(chain_link_piece_1_circlesc_start+cc-1,n)=chain_init(cc,n)
                Next
            Next
        Next
        
        c+=speed
        
        'If c>=31 Then c=speed
        'move them up on the sprockets
        For i=0 To linksc
            clp1cs=chain_link_piece_1_circlesc_start+clp_total_entity_count*i
            clp1ce=chain_link_piece_1_circlesc_end+clp_total_entity_count*i
            clp2cs=chain_link_piece_2_circlesc_start+clp_total_entity_count*i
            clp2ce=chain_link_piece_2_circlesc_end+clp_total_entity_count*i
            clp3cs=chain_link_piece_3_circlesc_start+clp_total_entity_count*i
            clp3ce=chain_link_piece_3_circlesc_end+clp_total_entity_count*i
            Select Case i
                Case 0 To 16
                    a1x=cpath((i*60+c) Mod 1080,1)
                    a1y=cpath((i*60+c) Mod 1080,2)
                    a2x=cpath((i*60+30+c) Mod 1080,1)
                    a2y=cpath((i*60+30+c) Mod 1080,2)
                    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
                    clpx=a1x
                    clpy=a1y
                    move_circle_entities(clpx,clpy,clp1cs,clp1ce)
                    move_circle_entities(clpx,clpy,clp3cs,clp3ce)
                    rotate_circle_entities(clpx,clpy,angle,clp1cs,clp1ce)
                    rotate_circle_entities(clpx,clpy,angle,clp3cs,clp3ce)
                    
                    a1x=cpath((i*60+30+c) Mod 1080 ,1)
                    a1y=cpath((i*60+30+c) Mod 1080 ,2)
                    a2x=cpath((i*60+60+c) Mod 1080 ,1)
                    a2y=cpath((i*60+60+c) Mod 1080 ,2)
                    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
                    clpx=a1x
                    clpy=a1y
                    move_circle_entities(clpx,clpy,clp2cs,clp2ce)
                    rotate_circle_entities(clpx,clpy,angle,clp2cs,clp2ce)
                Case 17
                    a1x=cpath((i*60+c) Mod 1080 ,1)
                    a1y=cpath((i*60+c) Mod 1080 ,2)
                    a2x=cpath((i*60+30+c) Mod 1080,1)
                    a2y=cpath((i*60+30+c) Mod 1080,2)
                    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
                    clpx=a1x
                    clpy=a1y
                    move_circle_entities(clpx,clpy,clp1cs,clp1ce)
                    move_circle_entities(clpx,clpy,clp3cs,clp3ce)
                    rotate_circle_entities(clpx,clpy,angle,clp1cs,clp1ce)
                    rotate_circle_entities(clpx,clpy,angle,clp3cs,clp3ce)
                    
                    a1x=cpath((i*60+30+c) Mod 1080,1)
                    a1y=cpath((i*60+30+c) Mod 1080,2)
                    a2x=cpath((i*60+60+c) Mod 1080,1)
                    a2y=cpath((i*60+60+c) Mod 1080,2)
                    angle=atan2(a2y-a1y,a2x-a1x)/pi*180
                    clpx=a1x
                    clpy=a1y
                    move_circle_entities(clpx,clpy,clp2cs,clp2ce)
                    rotate_circle_entities(clpx,clpy,angle,clp2cs,clp2ce)
            End Select
        Next
        show_entities
        Sleep 1
    Next
Loop
End

Sub show_entities()
    ScreenLock
    Cls
    Dim As Integer i,clr
    clr=15
    For i=1 To linesc
        Select Case i
            Case sprocket_1_linesc_start
                clr=14
            Case sprocket_2_linesc_start
                clr=15            
        End Select
        Line(lines(i,1),lines(i,2))-(lines(i,3),lines(i,4)),clr
    Next
    For i=1 To circlesc
        Select Case i
            Case sprocket_1_circlesc_start
                clr=14            
            Case sprocket_1_circlesc_start
                clr=15            
            Case chain_link_piece_1_circlesc_start
                clr=3
        End Select
        Select Case circles(i,0)
            Case 1
                Circle(circles(i,1),circles(i,2)),circles(i,3),clr
            Case 2
                Circle(circles(i,1),circles(i,2)),circles(i,3),clr,circles(i,4),circles(i,5)
            Case 3
                plotellipse(circles(i,1),circles(i,2),circles(i,3),circles(i,4),circles(i,5),circles(i,6),circles(i,7))
        End Select
    Next
    ScreenUnLock
End Sub

Function mymod(n As Double,m As Integer) As Double
    Select Case n
        Case 0
            mymod = 0
        Case CDbl(m)
            mymod = CDbl(m)
        Case Else
            If InStr(Str(n),"e")<>0 Then
                mymod=0
            Else
                If InStr(Str(n),".")<>0 Then
                    mymod=Val(Str(val(Mid(Str(n),1,InStr(Str(n),".")-1)) Mod m)+"."+Mid(Str(n),InStr(Str(n),".")+1))
                Else
                    mymod = (n Mod m)
                EndIf
            End If
    End Select
End Function


Sub move_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
    Dim As Integer i
    for i = Ls to Le
        lines(i,1)+=move_x
        lines(i,2)+=move_y
        lines(i,3)+=move_x
        lines(i,4)+=move_y
    Next
    For i = Cs To Ce
        circles(i,1)+=move_x
        circles(i,2)+=move_y
    Next
End Sub

Sub move_circle_entities(move_x As Double, move_y As Double, Cs As Integer, Ce As Integer)
    Dim As Integer i
    For i = Cs To Ce
        circles(i,1)+=move_x
        circles(i,2)+=move_y
    Next
End Sub

Sub move_line_entities(move_x As Double, move_y As Double, Ls As Integer,Le As Integer)
    Dim As Integer i
    for i = Ls to Le
        lines(i,1)+=move_x
        lines(i,2)+=move_y
        lines(i,3)+=move_x
        lines(i,4)+=move_y
    Next
End Sub









Sub rotate_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer, Cs As Integer, Ce As Integer)
    Dim As Integer i,j
    Dim As Double x1,y1,x2,y2,x1p,y1p,x2p,y2p
    Dim As Double arcangle,arcstart,arcend,arcendpoint1x,arcendpoint1y,arcendpoint2x,arcendpoint2y
    
    for i = Ls to Le
        x1p=lines(i,1)-pivot_pt_x
        y1p=lines(i,2)-pivot_pt_y
        x2p=lines(i,3)-pivot_pt_x
        y2p=lines(i,4)-pivot_pt_y
        lines(i,1)=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,2)=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        lines(i,3)=x2p*cos(rotation_angle*pi/180) - y2p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,4)=y2p*cos(rotation_angle*pi/180) + x2p*sin(rotation_angle*pi/180)+pivot_pt_y
    Next

    For i = Cs To Ce
        x1=circles(i,1)
        y1=circles(i,2)
        x1p=x1-pivot_pt_x
        y1p=y1-pivot_pt_y
        x1=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        y1=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        Select Case circles(i,0)
            Case 1
                circles(i,1)=x1
                circles(i,2)=y1
            Case 2
                arcendpoint1x=circles(i,1)+cos(circles(i,4))*circles(i,3)
                arcendpoint1y=circles(i,2)+sin(circles(i,4))*circles(i,3)
                arcendpoint2x=circles(i,1)+cos(circles(i,5))*circles(i,3)
                arcendpoint2y=circles(i,2)+sin(circles(i,5))*circles(i,3)
                x1p=arcendpoint1x-pivot_pt_x
                y1p=arcendpoint1y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcstart=arcangle*PI/180
                x1p=arcendpoint2x-pivot_pt_x
                y1p=arcendpoint2y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcend=arcangle*PI/180
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,4)=arcstart
                circles(i,5)=arcend
            Case 3,4'rotating ellipses
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,7)=mymod(circles(i,7)+rotation_angle,360)
        End Select
    Next
End Sub

Sub rotate_circle_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Cs As Integer, Ce As Integer)
    Dim As Integer i,j
    Dim As Double x1,y1,x2,y2,x1p,y1p,x2p,y2p
    Dim As Double arcangle,arcstart,arcend,arcendpoint1x,arcendpoint1y,arcendpoint2x,arcendpoint2y
    
    For i = Cs To Ce
        x1=circles(i,1)
        y1=circles(i,2)
        x1p=x1-pivot_pt_x
        y1p=y1-pivot_pt_y
        x1=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        y1=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        Select Case circles(i,0)
            Case 1
                circles(i,1)=x1
                circles(i,2)=y1
            Case 2
                arcendpoint1x=circles(i,1)+cos(circles(i,4))*circles(i,3)
                arcendpoint1y=circles(i,2)+sin(circles(i,4))*circles(i,3)
                arcendpoint2x=circles(i,1)+cos(circles(i,5))*circles(i,3)
                arcendpoint2y=circles(i,2)+sin(circles(i,5))*circles(i,3)
                x1p=arcendpoint1x-pivot_pt_x
                y1p=arcendpoint1y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcstart=arcangle*PI/180
                x1p=arcendpoint2x-pivot_pt_x
                y1p=arcendpoint2y-pivot_pt_y
                x2=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
                y2=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
                arcangle=atan2((y1-y2)*-1,(x1-x2)*-1)/pi*180
                arcangle+=360
                arcangle=mymod(arcangle,360)
                arcend=arcangle*PI/180
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,4)=arcstart
                circles(i,5)=arcend
            Case 3,4'rotating ellipses
                circles(i,1)=x1
                circles(i,2)=y1
                circles(i,7)=mymod(circles(i,7)+rotation_angle,360)
        End Select
    Next
End Sub

Sub rotate_line_entities(pivot_pt_x As Double, pivot_pt_y As Double, rotation_angle As Double, Ls As Integer,Le As Integer)
    Dim As Integer i,j
    Dim As Double x1p,y1p,x2p,y2p
    
    for i = Ls to Le
        x1p=lines(i,1)-pivot_pt_x
        y1p=lines(i,2)-pivot_pt_y
        x2p=lines(i,3)-pivot_pt_x
        y2p=lines(i,4)-pivot_pt_y
        lines(i,1)=x1p*cos(rotation_angle*pi/180) - y1p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,2)=y1p*cos(rotation_angle*pi/180) + x1p*sin(rotation_angle*pi/180)+pivot_pt_y
        lines(i,3)=x2p*cos(rotation_angle*pi/180) - y2p*sin(rotation_angle*pi/180)+pivot_pt_x
        lines(i,4)=y2p*cos(rotation_angle*pi/180) + x2p*sin(rotation_angle*pi/180)+pivot_pt_y
    Next
End Sub













Sub plotellipse(ex1 As Double,ey1 As Double,er1 As Double,estart As Double,eend As Double,er2 As Double,eangle As Double)
    '1x,2y,3z,4r,5color,6start,7end,8aspect,9=1(circle)2(arc)3(ellips)4(ellipticalarc),10group,11 is ellipse rotation , 12 block
    Dim As Double i,x1p,y1p
    Dim As Double eplotx,eploty,eplotxp,eplotyp,easpect,eresolution,elength
    Dim As BOOLEAN eplot
    If estart>eend Then
        elength=360+eend
    Else
        elength=eend
    EndIf
    eplot=FALSE
    eresolution=1
    'plotellipse
    For i = estart To elength Step eresolution
        eplotx=Cos(i*pi/180)*er1*Cos(eangle*pi/180) - Sin(i*pi/180)*er2*Sin(eangle*pi/180)+ex1
        eploty=Cos(i*pi/180)*er1*Sin(eangle*pi/180) + Sin(i*pi/180)*er2*Cos(eangle*pi/180)+ey1

        If eplot=false Then
            eplot=TRUE
        Else
            Line(eplotx,eploty)-(eplotxp,eplotyp)
        EndIf
        eplotxp=eplotx
        eplotyp=eploty
    Next

    x1p=Cos(eend*pi/180)*er1
    y1p=Sin(eend*pi/180)*er2
    eplotx=x1p*Cos(eangle*pi/180) - y1p*Sin(eangle*pi/180)+ex1
    eploty=y1p*Cos(eangle*pi/180) + x1p*Sin(eangle*pi/180)+ey1
    Line(eplotx,eploty)-(eplotxp,eplotyp)
End Sub

Sub read_entity_data()
    Dim As String entity_type
    Dim As Integer i,j,entity_count
    entity_type=""
    entity_count=0
    Do
        Read entity_type
        Read entity_count
        Select Case entity_type
            Case "ENTITY DATA START"
                'begin filling line and circle arrays
            Case "ENTITY DATA END"
                Exit Do
            Case "LINE"
                'Print "Line"
                linesc+=entity_count
                ReDim Preserve lines(linesc,4)
                For i = linesc-entity_count+1 To linesc
                    For j=1 To 4
                        Read lines(i,j)
                        'Print lines(i,j)
                    Next
                Next
            Case "CIRCLE"
                'Print "Circle"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=1
                    For j=1 To 3
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ARC"
                'Print "Arc"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=2
                    For j=1 To 5
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
            Case "ELLIPSE"
                'Print "Ellipse"
                circlesc+=entity_count
                ReDim Preserve circles(circlesc,7)
                For i = circlesc-entity_count+1 To circlesc
                    circles(i,0)=3
                    For j=1 To 7
                        Read circles(i,j)
                        'Print i,circles(i,j)
                    Next
                Next
        End Select
    Loop
End Sub

Sub zoominpan()
    Dim As Double panx,pany,panxf,panyf
    'viewsset=FALSE
    'mousexp=mousex-1
    'tempmousex=mousexp-1
    If wx2-wx1<=maxzoomin Then Exit Sub
    panxf=(mousex-wx1)/(wx2-wx1)
    panyf=(mousey-wy1)/(wy2-wy1)
    wx1=wx1+wzoom
    wy1=wy1+wzoom
    wx2=wx2-wzoom
    wy2=wy2-wzoom
    panx=wx1+int((wx2-wx1)*panxf)
    pany=wy1+Int((wy2-wy1)*panyf)
    wx1=wx1+(mousex-panx)
    wx2=wx2+(mousex-panx)
    wy1=wy1+(mousey-pany)
    wy2=wy2+(mousey-pany)
    'inview()
    'redraw
    wzoom=(wx2-wx1)/wzoomt
    If wzoom<20 Then wzoom=20
End Sub
Sub zoomoutpan()
    Dim As Double panx,pany,panxf,panyf
    'viewsset=FALSE
    'mousexp=mousex-1
    'tempmousex=mousexp-1
    ''If wx2-wx1>160000 Then Exit Sub --- what is the limit ???
    'If selentity=true and snapenable=true Then
    '    mousex=fxm
    '    mousey=fym
    'EndIf
    panxf=(mousex-wx1)/(wx2-wx1)
    panyf=(mousey-wy1)/(wy2-wy1)
    wx1=wx1-wzoom
    wy1=wy1-wzoom
    wx2=wx2+wzoom
    wy2=wy2+wzoom
    panx=wx1+Int((wx2-wx1)*panxf)
    pany=wy1+Int((wy2-wy1)*panyf)
    wx1=wx1+(mousex-panx)
    wx2=wx2+(mousex-panx)
    wy1=wy1+(mousey-pany)
    wy2=wy2+(mousey-pany)
    'inview()
    'redraw
    wzoom=(wx2-wx1)/wzoomt
End Sub





'big sprocket
Data "ENTITY DATA START"
DATA 0
'lines data x1,y1,x2,y2
DATA "LINE", 41
DATA-97.9202480392088, 6.072364661790445,-99.87901299359182, 13.03107389343951
DATA-95.00415385146233, 24.48385875660966,-99.01740943671227, 18.471024655737
DATA-95.00415385146239,-24.48385875660942,-99.01740943671233,-18.47102465573676
DATA-97.92024803920883,-6.072364661790189,-99.87901299359187,-13.03107389343926
DATA-82.7883911518724,-52.64343149083753,-88.46329194930918,-48.16505061641327
DATA-91.25122609839222,-36.03418271844164,-90.96376286065539,-43.25760013709514
DATA-62.46872390569825,-75.64989836238762,-69.24977108590986,-73.14434583711476
DATA-75.6498983623878,-62.46872390569804,-73.14434583711497,-69.24977108590967
DATA-36.03418271844185,-91.25122609839211,-43.25760013709537,-90.96376286065528
DATA-52.64343149083776,-82.78839115187229,-48.16505061641353,-88.46329194930904
DATA-6.07236466179045,-97.9202480392088,-13.03107389343952,-99.87901299359182
DATA-24.48385875660967,-95.00415385146231,-18.47102465573702,-99.01740943671227
DATA 24.48385875660942,-95.00415385146239, 18.47102465573675,-99.01740943671233
DATA 6.072364661790182,-97.92024803920883, 13.03107389343925,-99.87901299359184
DATA 52.64343149083753,-82.78839115187243, 48.16505061641328,-88.46329194930918
DATA 36.03418271844162,-91.25122609839225, 43.25760013709513,-90.96376286065542
DATA 75.64989836238763,-62.46872390569827, 73.14434583711477,-69.24977108590984
DATA 62.46872390569806,-75.64989836238782, 69.24977108590966,-73.14434583711496
DATA 91.25122609839212,-36.03418271844187, 90.96376286065529,-43.25760013709537
DATA 82.7883911518723,-52.64343149083776, 88.46329194930904,-48.16505061641352
DATA 97.92024803920879,-6.072364661790459, 99.8790129935918,-13.03107389343953
DATA 95.00415385146233,-24.48385875660968, 99.01740943671229,-18.47102465573703
DATA 95.00415385146238, 24.48385875660941, 99.01740943671233, 18.47102465573674
DATA 97.92024803920883, 6.072364661790175, 99.87901299359184, 13.03107389343924
DATA 82.78839115187243, 52.64343149083753, 88.46329194930915, 48.16505061641327
DATA 91.25122609839224, 36.03418271844164, 90.96376286065539, 43.25760013709511
DATA 62.46872390569824, 75.64989836238762, 69.24977108590984, 73.14434583711476
DATA 75.64989836238782, 62.46872390569804, 73.14434583711496, 69.24977108590964
DATA 36.03418271844188, 91.25122609839211, 43.25760013709538, 90.96376286065525
DATA 52.64343149083777, 82.78839115187229, 48.16505061641352, 88.46329194930904
DATA 6.072364661790466, 97.92024803920877, 13.03107389343953, 99.87901299359179
DATA 24.48385875660969, 95.00415385146233, 18.47102465573703, 99.01740943671227
DATA-24.48385875660939, 95.00415385146239,-18.47102465573673, 99.01740943671233
DATA-6.072364661790184, 97.92024803920883,-13.03107389343924, 99.87901299359184
DATA-52.64343149083752, 82.78839115187243,-48.16505061641326, 88.46329194930918
DATA-36.03418271844161, 91.25122609839225,-43.25760013709513, 90.96376286065542
DATA-75.64989836238765, 62.46872390569824,-73.14434583711476, 69.24977108590984
DATA-62.46872390569804, 75.64989836238782,-69.24977108590964, 73.14434583711496
DATA-91.25122609839211, 36.03418271844187,-90.96376286065525, 43.25760013709537
DATA-82.78839115187229, 52.64343149083778,-88.46329194930904, 48.16505061641352
DATA 0, 0, 3.3750779948604e-014, 95.88679832249493
'circles data x1,y1,radius
DATA "CIRCLE", 1
DATA 0, 0, 19.39421899515231
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 80
DATA-95.88679832249493, 1.4210854715e-014, 5.3851648071345, 4.839942021295272, 1.612405967231461
DATA-93.54028134689141, 14.8153251089273, 9.778725152391161, 4.247965142473813, 4.446394041093257
DATA-93.54028134689141, 14.8153251089273, 9.778725152391161, 1.522632000727353, 1.721060899346796
DATA-93.54028134689141, 14.8153251089273, 6.58506425852097, 2.553049150547038, 3.415976891273562
DATA-91.193764371288,-29.63065021785411, 5.3851648071345, 5.154101286654246, 1.92656523259044
DATA-93.54028134689149,-14.81532510892681, 9.778725152391161, 4.562124407832798, 4.760553306452237
DATA-93.54028134689149,-14.81532510892681, 9.778725152391161, 1.836791266086334, 2.035220164705774
DATA-93.54028134689149,-14.81532510892681, 6.58506425852097, 2.867208415906022, 3.73013615663255
DATA-77.5740493791016,-56.36084594350514, 5.3851648071345, 5.468260552013228, 2.240724497949415
DATA-84.38390687519488,-42.99574808067943, 9.778725152391161, 4.876283673191771, 5.074712571811213
DATA-84.38390687519488,-42.99574808067943, 9.778725152391161, 2.150950531445313, 2.349379430064753
DATA-84.38390687519488,-42.99574808067943, 6.58506425852097, 3.181367681264999, 4.044295421991523
DATA-56.3608459435052,-77.57404937910157, 5.3851648071345, 5.782419817372208, 2.554883763308393
DATA-66.96744766130357,-66.96744766130321, 9.778725152391161, 5.190442938550754, 5.388871837170198
DATA-66.96744766130357,-66.96744766130321, 9.778725152391161, 2.465109796804287, 2.663538695423732
DATA-66.96744766130357,-66.96744766130321, 6.58506425852097, 3.495526946623976, 4.358454687350502
DATA-29.63065021785415,-91.19376437128797, 5.3851648071345, 6.096579082731184, 2.869043028667383
DATA-42.99574808067986,-84.38390687519468, 9.778725152391161, 5.504602203909734, 5.703031102529175
DATA-42.99574808067986,-84.38390687519468, 9.778725152391161, 2.77926906216327, 2.97769796078271
DATA-42.99574808067986,-84.38390687519468, 6.58506425852097, 3.809686211982957, 4.672613952709483
DATA-1.953992523340276e-014,-95.88679832249493, 5.3851648071345, 0.1275530409105824, 3.183202294026359
DATA-14.8153251089273,-93.54028134689141, 9.778725152391161, 5.818761469268709, 6.01719036788815
DATA-14.8153251089273,-93.54028134689141, 9.778725152391161, 3.093428327522249, 3.291857226141691
DATA-14.8153251089273,-93.54028134689141, 6.58506425852097, 4.123845477341936, 4.986773218068459
DATA 29.6306502178541,-91.193764371288, 5.3851648071345, 0.4417123062695653, 3.497361559385338
DATA 14.81532510892682,-93.54028134689149, 9.778725152391161, 6.132920734627694, 0.04816432606754741
DATA 14.81532510892682,-93.54028134689149, 9.778725152391161, 3.40758759288123, 3.60601649150067
DATA 14.81532510892682,-93.54028134689149, 6.58506425852097, 4.438004742700917, 5.300932483427442
DATA 56.36084594350514,-77.57404937910162, 5.3851648071345, 0.7558715716285392, 3.811520824744314
DATA 42.99574808067943,-84.38390687519488, 9.778725152391161, 0.1638946928070797, 0.3623235914265215
DATA 42.99574808067943,-84.38390687519488, 9.778725152391161, 3.721746858240208, 3.920175756859651
DATA 42.99574808067943,-84.38390687519488, 6.58506425852097, 4.752164008059895, 5.615091748786417
DATA 77.57404937910158,-56.3608459435052, 5.3851648071345, 1.070030836987521, 4.125680090103296
DATA 66.96744766130321,-66.96744766130355, 9.778725152391161, 0.4780539581660643, 0.6764828567855078
DATA 66.96744766130321,-66.96744766130355, 9.778725152391161, 4.035906123599186, 4.234335022218629
DATA 66.96744766130321,-66.96744766130355, 6.58506425852097, 5.066323273418876, 5.929251014145397
DATA 91.19376437128798,-29.63065021785415, 5.3851648071345, 1.384190102346496, 4.439839355462276
DATA 84.38390687519468,-42.99574808067986, 9.778725152391161, 0.7922132235250471, 0.9906421221444854
DATA 84.38390687519468,-42.99574808067986, 9.778725152391161, 4.350065388958166, 4.548494287577609
DATA 84.38390687519468,-42.99574808067986, 6.58506425852097, 5.380482538777852, 6.24341027950438
DATA 95.88679832249491,-2.842170943040401e-014, 5.3851648071345, 1.698349367705476, 4.753998620821255
DATA 93.54028134689142,-14.81532510892731, 9.778725152391161, 1.106372488884023, 1.304801387503465
DATA 93.54028134689142,-14.81532510892731, 9.778725152391161, 4.664224654317144, 4.862653552936588
DATA 93.54028134689142,-14.81532510892731, 6.58506425852097, 5.694641804136832, 0.2743842376837707
DATA 91.193764371288, 29.63065021785411, 5.3851648071345, 2.012508633064455, 5.068157886180231
DATA 93.54028134689149, 14.81532510892681, 9.778725152391161, 1.420531754243002, 1.618960652862446
DATA 93.54028134689149, 14.81532510892681, 9.778725152391161, 4.978383919676126, 5.176812818295567
DATA 93.54028134689149, 14.81532510892681, 6.58506425852097, 6.008801069495812, 0.5885435030427483
DATA 77.57404937910161, 56.36084594350514, 5.3851648071345, 2.326667898423436, 5.38231715153921
DATA 84.3839068751949, 42.99574808067943, 9.778725152391161, 1.734691019601983, 1.933119918221423
DATA 84.3839068751949, 42.99574808067943, 9.778725152391161, 5.292543185035105, 5.490972083654545
DATA 84.3839068751949, 42.99574808067943, 6.58506425852097, 0.03977502767520338, 0.902702768401731
DATA 56.36084594350518, 77.57404937910157, 5.3851648071345, 2.640827163782412, 5.696476416898193
DATA 66.96744766130355, 66.96744766130321, 9.778725152391161, 2.048850284960963, 2.247279183580403
DATA 66.96744766130355, 66.96744766130321, 9.778725152391161, 5.606702450394082, 5.805131349013524
DATA 66.96744766130355, 66.96744766130321, 6.58506425852097, 0.3539342930341827, 1.216862033760707
DATA 29.63065021785415, 91.19376437128797, 5.3851648071345, 2.954986429141391, 6.010635682257174
DATA 42.99574808067987, 84.38390687519468, 9.778725152391161, 2.363009550319942, 2.561438448939382
DATA 42.99574808067987, 84.38390687519468, 9.778725152391161, 5.920861715753063, 6.119290614372505
DATA 42.99574808067987, 84.38390687519468, 6.58506425852097, 0.668093558393162, 1.53102129911969
DATA 3.3750779948604e-014, 95.88679832249493, 5.3851648071345, 3.269145694500375, 0.04160964043656391
DATA 14.81532510892732, 93.54028134689141, 9.778725152391161, 2.67716881567892, 2.875597714298361
DATA 14.81532510892732, 93.54028134689141, 9.778725152391161, 6.235020981112044, 0.1502645725518996
DATA 14.81532510892732, 93.54028134689141, 6.58506425852097, 0.982252823752143, 1.845180564478671
DATA-29.63065021785412, 91.193764371288, 5.3851648071345, 3.583304959859355, 0.3557689057955362
DATA-14.81532510892681, 93.54028134689149, 9.778725152391161, 2.991328081037897, 3.189756979657341
DATA-14.81532510892681, 93.54028134689149, 9.778725152391161, 0.2659949392914371, 0.4644238379108789
DATA-14.81532510892681, 93.54028134689149, 6.58506425852097, 1.296412089111122, 2.159339829837648
DATA-56.36084594350513, 77.5740493791016, 5.3851648071345, 3.897464225218333, 0.6699281711545243
DATA-42.99574808067943, 84.38390687519491, 9.778725152391161, 3.305487346396878, 3.50391624501632
DATA-42.99574808067943, 84.38390687519491, 9.778725152391161, 0.5801542046504129, 0.7785831032698581
DATA-42.99574808067943, 84.38390687519491, 6.58506425852097, 1.6105713544701, 2.473499095196629
DATA-77.57404937910157, 56.3608459435052, 5.3851648071345, 4.211623490577313, 0.9840874365135036
DATA-66.96744766130318, 66.96744766130355, 9.778725152391161, 3.619646611755859, 3.818075510375299
DATA-66.96744766130318, 66.96744766130355, 9.778725152391161, 0.8943134700093941, 1.092742368628841
DATA-66.96744766130318, 66.96744766130355, 6.58506425852097, 1.924730619829079, 2.787658360555602
DATA-91.19376437128797, 29.63065021785415, 5.3851648071345, 4.525782755936287, 1.298246701872485
DATA-84.38390687519468, 42.99574808067986, 9.778725152391161, 3.93380587711484, 4.132234775734278
DATA-84.38390687519468, 42.99574808067986, 9.778725152391161, 1.208472735368373, 1.406901633987815
DATA-84.38390687519468, 42.99574808067986, 6.58506425852097, 2.238889885188053, 3.101817625914583
DATA "ENTITY DATA END"
DATA 0

'small sprocket
Data "ENTITY DATA START"
DATA 0
'lines data x1,y1,x2,y2
DATA "LINE", 25
DATA-24.25747214638355, 54.51848019438589,-18.69707641887519, 59.13826305407355
DATA-6.251652986831032, 59.34312489724883,-13.37698837179155, 60.56377634995207
DATA-48.2668272075545, 35.08565275086517,-45.76127468228165, 41.86669993107675
DATA-35.08565275086495, 48.26682720755485,-41.86669993107654, 45.76127468228197
DATA-59.34312489724877, 6.251652986831377,-60.56377634995199, 13.37698837179189
DATA-54.51848019438584, 24.25747214638389,-59.13826305407347, 18.69707641887555
DATA-54.51848019438591,-24.25747214638349,-59.13826305407356,-18.69707641887513
DATA-59.34312489724884,-6.251652986830977,-60.56377634995209,-13.3769883717915
DATA-35.08565275086517,-48.2668272075545,-41.8666999310768,-45.76127468228166
DATA-48.26682720755475,-35.08565275086492,-45.76127468228192,-41.86669993107652
DATA-6.251652986831377,-59.34312489724877,-13.37698837179189,-60.56377634995199
DATA-24.25747214638389,-54.51848019438584,-18.69707641887555,-59.13826305407347
DATA 24.25747214638355,-54.51848019438589, 18.69707641887519,-59.13826305407355
DATA 6.251652986831032,-59.34312489724883, 13.37698837179155,-60.56377634995207
DATA 48.2668272075545,-35.08565275086517, 45.76127468228166,-41.8666999310768
DATA 35.08565275086492,-48.26682720755475, 41.86669993107652,-45.76127468228192
DATA 59.34312489724877,-6.251652986831377, 60.56377634995199,-13.37698837179189
DATA 54.51848019438584,-24.25747214638389, 59.13826305407347,-18.69707641887555
DATA 54.51848019438591, 24.25747214638349, 59.13826305407356, 18.69707641887513
DATA 59.34312489724884, 6.251652986830977, 60.56377634995209, 13.3769883717915
DATA 35.08565275086517, 48.2668272075545, 41.86669993107687, 45.76127468228167
DATA 48.26682720755475, 35.08565275086492, 45.76127468228187, 41.8666999310765
DATA 6.251652986831377, 59.34312489724877, 13.37698837179189, 60.56377634995199
DATA 24.25747214638389, 54.51848019438584, 18.69707641887555, 59.13826305407347
DATA 0, 0, 5.87446757904786e-014, 57.95554957734412
'circles data x1,y1,radius
DATA "CIRCLE", 1
DATA 0, 0, 11.01923788646684
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 48
DATA-28.97777478867205, 50.19097822426848, 5.3851648071345, 3.688024714979013, 0.460488660915196
DATA-14.48888739433575, 54.07326390080636, 9.778725152391161, 3.096047836157557, 3.294476734777001
DATA-14.48888739433575, 54.07326390080636, 9.778725152391161, 0.3707146944110952, 0.5691435930305386
DATA-14.48888739433575, 54.07326390080636, 6.58506425852097, 1.401131844230782, 2.264059584957308
DATA-50.19097822426848, 28.97777478867205, 5.3851648071345, 4.211623490577305, 0.984087436513495
DATA-39.5843765064701, 39.58437650647054, 9.778725152391161, 3.619646611755854, 3.818075510375299
DATA-39.5843765064701, 39.58437650647054, 9.778725152391161, 0.8943134700093941, 1.092742368628841
DATA-39.5843765064701, 39.58437650647054, 6.58506425852097, 1.924730619829083, 2.787658360555608
DATA-57.95554957734413, 1.067878424576563e-013, 5.3851648071345, 4.735222266175607, 1.507686212111794
DATA-54.07326390080625, 14.48888739433632, 9.778725152391161, 4.143245387354153, 4.3416742859736
DATA-54.07326390080625, 14.48888739433632, 9.778725152391161, 1.417912245607691, 1.616341144227137
DATA-54.07326390080625, 14.48888739433632, 6.58506425852097, 2.44832939542738, 3.311257136153909
DATA-50.19097822426853,-28.97777478867207, 5.3851648071345, 5.258821041773906, 2.031284987710093
DATA-54.07326390080643,-14.48888739433571, 9.778725152391161, 4.666844162952454, 4.865273061571899
DATA-54.07326390080643,-14.48888739433571, 9.778725152391161, 1.941511021205992, 2.139939919825437
DATA-54.07326390080643,-14.48888739433571, 6.58506425852097, 2.97192817102568, 3.834855911752206
DATA-28.9777747886721,-50.19097822426849, 5.3851648071345, 5.782419817372201, 2.554883763308391
DATA-39.58437650647054,-39.5843765064701, 9.778725152391161, 5.19044293855075, 5.388871837170198
DATA-39.58437650647054,-39.5843765064701, 9.778725152391161, 2.465109796804289, 2.663538695423734
DATA-39.58437650647054,-39.5843765064701, 6.58506425852097, 3.495526946623978, 4.358454687350507
DATA-5.87446757904786e-014,-57.95554957734412, 5.3851648071345, 0.02283328579091916, 3.07848253890669
DATA-14.48888739433632,-54.07326390080625, 9.778725152391161, 5.714041714149051, 5.912470612768496
DATA-14.48888739433632,-54.07326390080625, 9.778725152391161, 2.988708572402589, 3.187137471022033
DATA-14.48888739433632,-54.07326390080625, 6.58506425852097, 4.019125722222277, 4.882053462948803
DATA 28.97777478867207,-50.19097822426853, 5.3851648071345, 0.5464320613892163, 3.602081314504988
DATA 14.48888739433576,-54.07326390080642, 9.778725152391161, 6.23764048974735, 0.1528840811872107
DATA 14.48888739433576,-54.07326390080642, 9.778725152391161, 3.512307348000888, 3.710736246620333
DATA 14.48888739433576,-54.07326390080642, 6.58506425852097, 4.542724497820575, 5.405652238547104
DATA 50.19097822426849,-28.9777747886721, 5.3851648071345, 1.070030836987512, 4.125680090103288
DATA 39.5843765064701,-39.58437650647054, 9.778725152391161, 0.4780539581660626, 0.6764828567855078
DATA 39.5843765064701,-39.58437650647054, 9.778725152391161, 4.035906123599186, 4.234335022218632
DATA 39.5843765064701,-39.58437650647054, 6.58506425852097, 5.066323273418876, 5.929251014145402
DATA 57.95554957734413,-1.067878424576563e-013, 5.3851648071345, 1.593629612585816, 4.649278865701581
DATA 54.07326390080625,-14.48888739433632, 9.778725152391161, 1.001652733764362, 1.200081632383808
DATA 54.07326390080625,-14.48888739433632, 9.778725152391161, 4.559504899197487, 4.757933797816929
DATA 54.07326390080625,-14.48888739433632, 6.58506425852097, 5.589922049017172, 0.1696644825641127
DATA 50.19097822426858, 28.97777478867208, 5.3851648071345, 2.117228388184113, 5.172877641299886
DATA 54.07326390080648, 14.48888739433572, 9.778725152391161, 1.52525150936266, 1.723680407982106
DATA 54.07326390080648, 14.48888739433572, 9.778725152391161, 5.083103674795785, 5.28153257341523
DATA 54.07326390080648, 14.48888739433572, 6.58506425852097, 6.113520824615471, 0.6932632581624133
DATA 28.97777478867215, 50.19097822426851, 5.3851648071345, 2.640827163782413, 5.696476416898179
DATA 39.58437650647056, 39.58437650647005, 9.778725152391161, 2.048850284960961, 2.247279183580404
DATA 39.58437650647056, 39.58437650647005, 9.778725152391161, 5.606702450394082, 5.80513134901353
DATA 39.58437650647056, 39.58437650647005, 6.58506425852097, 0.3539342930341862, 1.216862033760712
DATA 5.87446757904786e-014, 57.95554957734412, 5.3851648071345, 3.164425939380712, 6.220075192496474
DATA 14.48888739433632, 54.07326390080625, 9.778725152391161, 2.572449060559258, 2.770877959178705
DATA 14.48888739433632, 54.07326390080625, 9.778725152391161, 6.130301225992383, 0.04554481743223981
DATA 14.48888739433632, 54.07326390080625, 6.58506425852097, 0.8775330686324797, 1.740460809359009
DATA "ENTITY DATA END"
DATA 0


'chain piece 1
Data "ENTITY DATA START"
DATA 0
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 8
DATA 15, 9.42809041582052, 7.716909687891069, 3.702733079760211, 5.722044881009169
DATA 15,-9.428090415820577, 7.716909687891069, 0.5611404261704176, 2.580452227419375
DATA 0, 0, 9.999999999999982, 0.5611404261704158, 1.570796326794897
DATA 0, 0, 9.999999999999982, 4.71238898038469, 5.72204488100917
DATA 0, 0, 5.385164807134504, 4.71238898038469, 1.570796326794897
DATA 30, 0, 5.385164807134504, 1.570796326794897, 4.71238898038469
DATA 30, 0, 9.999999999999982, 1.570796326794897, 2.580452227419377
DATA 30, 0, 9.999999999999982, 3.702733079760208, 4.712388980384688
DATA "ENTITY DATA END"
DATA 0

'chain piece 2
Data "ENTITY DATA START"
DATA 0
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 6
DATA 15, 9.428090415820492, 7.716909687891069, 3.702733079760211, 5.722044881009169
DATA 15,-9.428090415820606, 7.716909687891069, 0.5611404261704176, 2.580452227419375
DATA 0, 0, 5.385164807134504, 4.71238898038469, 1.570796326794897
DATA 30, 0, 9.999999999999982, 1.570796326794897, 4.71238898038469
DATA 30, 0, 5.385164807134504, 1.570796326794897, 4.71238898038469
DATA 0, 0, 9.999999999999982, 4.71238898038469, 7.853981633974483
DATA "ENTITY DATA END"
DATA 0



'chain piece 3
Data "ENTITY DATA START"
DATA 0
'arcs data x1,y1,radius,arc_start,arc_end
DATA "ARC", 4
DATA 30.00000000000001, 0, 9.999999999999982, 0.5611404261704158, 2.580452227419379
DATA 30.00000000000001, 0, 9.999999999999982, 3.702733079760208, 5.72204488100917
DATA-5.329070518200751e-015, 0, 9.999999999999982, 0.5611404261704158, 2.580452227419379
DATA-5.329070518200751e-015, 0, 9.999999999999982, 3.702733079760208, 5.72204488100917
DATA "ENTITY DATA END"
DATA 0
Reply