Results 1 to 6 of 6

Thread: PolyHedral Greenhouse (simple OOP)

  1. #1

    PolyHedral Greenhouse (simple OOP)

    This is part of a real project to design a small rotunda greenhouse. It calculates the shape of the roof and wall panels including mitre and bevel angles for the frame. The output is only a set of figures at this stage, and in the absence of a modelling device scissors cardboard and tape give a fair representation of the design.

    Before this program gets too complicated, I wanted to use it to show off some of the latest Oxygen features, which includes some C like syntax. The aim is to produce very clear and highly maintainable code, so it can be extended to produce further variations in design and more detailed outputs such as materials and costs.

    In particular, note the Report method which uses 2 inner functions: single liners to help format the output values. As inner functions these are completely encapsulated inside the method and invisible to the rest of the program.


    Latest Oxygen with a few adjustments as usual

    http://community.thinbasic.com/index.php?topic=2517

    [code=thinbasic]

    '----------------------------------------
    'Polyhedral GreenHouse
    '========================================

    '16:18 03/02/2010

    uses "oxygen","file"
    dim src as string

    src ="

    basic

    /*

    ROOF PANEL
    /\ apex
    / \
    / \
    -------------- truncation
    / \
    / main \
    / \
    ..............
    \ / /\
    \ tail / / \
    \ / / \
    \ / / \
    \ / / head \
    \ / / \
    \/ / \
    ------------------------
    | main | shoulder
    | |
    SIDE PANEL | |
    | |
    | |
    | |
    | |
    | |
    | |
    --------------

    */

    class greenhouse

    protected double

    a,b,n,r,
    w1,w2,w3,h1,h2,h3,
    fr,ta,ra,rm,sh,s1,s2,v1,sc,ma,
    sina,cosa,tana,sinb,cosb,tanb,
    rptw,rptm,rtam,rsdm,rptr,sdtm,sdsm


    '----------------------------------------------------------
    method input(double scale, double sides, double RoofSlope )
    '==========================================================

    'INPUTS

    sc=scale 'SCALE
    n=sides 'NUMBER OF SIDES
    a=pi/n 'MAIN ANGLE
    b=rad(RoofSlope) 'ROOF PANEL SLOPE
    rptw=0.2*sc 'ROOF PANEL TRUNCATION WIDTH

    end method


    '-----------------
    method calculate()
    '=================

    'TRIGO PROPORTIONS

    cosa=cos a
    sina=sin a
    tana=tan a
    sinb=sin b
    cosb=cos b
    tanb=tan b


    'MAIN CALCS

    r=sc/cos(a) 'CORNER RADIUS
    fr=r*cosa 'FACE RADIUS
    w1=r*sina 'SIDE PANEL W1
    w2=w1*cosa 'ROOF PANEL W2

    h1=w1*sina/cosb 'ROOF PANEL TAIL
    h2=r*cosa/cosb 'ROOF PANEL MAIN
    v1=h1*sinb 'SIDE PANEL PEAK
    ta=atn(h1/w2) 'TAIL ANGLE
    ma=atn( tana/sin(ta) )/2 'TAIL BEVEL
    ra=asin(sina*cosa*cosb) 'ROOF ANGLE
    rptr=h2-rptw/tan(ra) 'ROOF PANEL TRUNCATED
    rm=atn(tana*sinb*cos(ra) ) 'ROOF BEVEL

    sh=sc*2-v1 'SIDE PANEL SHOULDER HEIGHT

    rptm=atn(h2/w2)*.5 'ROOF PANEL TOP MITRE
    rtam=ta 'ROOF PANEL TAIL MITRE
    rsdm=.5*(pi-atn(h2/w2)-ta) 'ROOF PANEL SIDE MITRE
    sdtm=atn(v1/w1) 'SIDE PANEL TIP MITRE
    sdsm=pi*.25-sdtm*.5 'SIDE PANEL SHOULDER MITRE

    end method


    'OUTPUT

    '--------------
    method report()
    '==============

    function degs(double d) as string= left(str(deg(d)),5) chr(9)
    function vals(double d) as string = left(str(d),5) chr(9)

    print `

    Polyhedral GreenHouse Measurements:

    ` vals(this.sc) `scaling
    ` vals(r) `Corner radius
    ` vals(fr) `Face radius
    ` vals(n) `number of sides
    ` degs(b) `roof slope
    --------------------------------------
    ` vals(w2) `roof panel half width
    ` vals(h1) `roof panel tail
    ` vals(h2) `roof panel main
    ` vals(rptw) `roof panel truncation width
    ` vals(rptr) `roof panel truncated
    --------------------------------------
    ` degs(ta) `roof tail angle
    ` degs(ra) `roof panel apex angle
    --------------------------------------
    ` degs(rptm) `roof panel top mitre
    ` degs(rsdm) `roof panel side mitre
    ` degs(rtam) `roof panel tail mitre
    ` degs(b ) `roof panel top bevels (top opening)
    ` degs(rm) `roof panel side bevels
    ` degs(ma) `roof panel tail bevels
    --------------------------------------
    ` vals(w1) `side panel half width
    ` vals(sh) `side panel shoulder
    ` vals(v1) `side panel head
    ` degs(sdtm) `side panel tip mitre
    ` degs(sdsm) `side panel shoulder mitre
    ` vals(45) `side panel base mitre
    ` degs(a ) `side panel side bevels
    ` degs(ma) `side panel apex bevels
    `

    end method

    end class


    '----
    'MAIN
    '====

    greenhouse g
    g.input 1,6,45 '(double scale, double sides, double RoofSlope )
    g.calculate
    g.report

    "





    'file_save ( "t.txt", o2_prep src )
    'msgbox 0, o2_prep src

    o2_asmo src
    if len(o2_error) then
    msgbox 0, o2_error : stop
    end if

    o2_exec

    [/code]

    Latest Version Attached below
    Featuring inner class for processing panel frame struts.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736

    Re: PolyHedral Greenhouse (simple OOP)

    Hi Charles,

    this is very nice project!
    The only problem is that I get "too many right brackets" executing the code above with latest TB beta and Oxygen.


    Petr


    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3

    Re: PolyHedral Greenhouse (simple OOP)

    Hi Petr,

    Try the Oxygen zip or latest SVN - The last problem I fixed was to do with functions inside methods. & This program is also contained in the OOP subfolder.

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: PolyHedral Greenhouse (simple OOP)

    Here are my results guys, does this look correct?

    Thanks for another cool example to study Charles!
    Attached Images Attached Images
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736

    Re: PolyHedral Greenhouse (simple OOP)

    The problem was in having ol' dll in the folder where I saved it, worked good here!
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6

    Re: PolyHedral Greenhouse (simple OOP)

    Thank you both for testing!

    I made one minor correction to the program. the tip/tail bevel angle was incorrect.

    This model can generate a lot of useful information like bill of materials, floor area, surface area and volume to mention a few so I will continue posting the updated program as an attachment to the first post.

    As you can see, the OOP is extremely simple and its main benefit is to encapsulate substantial sets of data.
    Attached Images Attached Images

Similar Threads

  1. My simple editor
    By Aurel in forum Alternative IDEs
    Replies: 38
    Last Post: 10-01-2011, 19:51

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •