English
Source / code snippets

Konvexe wrap of/ one Punktwolke (Convex hull-Algorithm)

 

p.specht


Window Title "A nonrecursive CONVEX HULL drawing algorithm"
' Demoware (C) 2012-07 by P. woodpecker - No warranties! without jedwede Gewähr!
Window 0,0-%maxx,%maxy:font 2:var xx&=%maxx\2:var yy&=%maxy\2' :randomize
declare u!,v!,k!,q&,nenn!,lastk!,bestpoint&,wait%,countr&,qred&
var n&=80:declare x![n&],y![n&],i&,j&,tmp!
Nochmal:

WhileLoop n&:i&=&Loop:x![i&]=rnd(xx&)+xx&/2:y![i&]=rnd(yy&)+yy&/2:EndWhile

    WhileLoop n&:i&=&Loop:WhileLoop n&:j&=&Loop

        if x![i&]<x![j&]:tmp!=x![i&]:x![i&]=x![j&]:x![j&]=tmp!:tmp!=y![i&]:y![i&]=y![j&]:y![j&]=tmp!:endif

            EndWhile :EndWhile :usepen 0,1,rgb(200,0,0):cls:WhileLoop n&:i&=&Loop
            rectangle x![i&]+3,(y![i&]+3) - (x![i&]-3),y![i&]-3
            'drawtext x![i&],y![i&],st$(int(& Loop))

        EndWhile

        ' ROTE SEITE
        bestpoint&=1

        REPEAT

            q&=bestpoint&:lastk! = val("-1.7976931348623157E+308")

            WhileLoop q&+1,n&,1:i&=&Loop

                nenn!=x![i&]-x![q&]

                if nenn!<>0

                    k!=(y![i&]-y![q&])/nenn!

                    if k!>lastk!:lastk!=k!:bestpoint&=i&:endif

                    else

                        if y![i&]>=y![q&]:bestpoint&=i&:

                            BREAK

                        endif

                    endif

                Endwhile

                Line x![q&],y![q&] - x![bestpoint&],y![bestpoint&]

            UNTIL q&=bestpoint&

            qred&=bestpoint&
            ' BLAUE SEITE
            Usepen 0,1,rgb(0,0,200):bestpoint&=1

            REPEAT

                q&=bestpoint&:lastk! = val("1.7976931348623157E+308")

                WhileLoop q&+1,n&:i&=&Loop

                    nenn!=x![i&]-x![q&]

                    if nenn!>0:k!=(y![i&]-y![q&])/nenn!

                        if k!<lastk!:lastk!=k!:bestpoint&=i&:endif

                        else

                            if y![i&]<=y![q&]:bestpoint&=i&

                                BREAK

                            endif

                        endif

                    Endwhile

                    Line x![q&],y![q&] - x![bestpoint&],y![bestpoint&]

                UNTIL q&=bestpoint&

                ' possible Error touch up:

                if bestpoint&<>qred&

                    Usepen 0,3,rgb(0,200,0)
                    Line x![qred&],y![qred&] - x![bestpoint&],y![bestpoint&]

                endif

                inc countr&:locate 1,50:print countr&
                ' waitinput
                Goto "Nochmal"
                End
                ProgEnd
 
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
04/27/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

570 Views

Untitledvor 0 min.
N.Art07/21/22
Ernst07/21/21
Uwe ''Pascal'' Niemeier06/13/21
R.Schneider05/28/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie