Perform Patch 1

Fixed Error :

1.) RANDOMINT() can generate "dupe" Points ... this is not allowed

**Code:**

DO WHILE .T.

mX := RANDOMINT( 1, aSize[1]-2)

mY := RANDOMINT( 1, aSize[2]-2)

// dupe Check

//

IF ASCAN(aCheck,{|X| X[1] = mX .AND. X[2] = mY } ) > 0

LOOP

ELSE

AADD(aCheck,{mX,mY})

EXIT

ENDIF

ENDDO

New :

i wonder why FindFirstRib() had 3 Loops in PAS Code just to get P1 & P2 ( Index-Number of Point Array )

i try to find out "what" he is searching for ...

P1 seems to be Max_X, Max_Y while

P2 seems to be Min_X , Max_Y

now i can ASORT Array and find Points "on-fly" instead of 3 Loops ( 1000*1000*1000 )

**Code:**

METHOD DemoDlg:FindFirstRib()

...

#IFDEF AO_PATCH1

aTest := ASORT( aTest,,, {|aX,aY| STR(aX[1])+STR(aX[2]) < ;

STR(aY[1])+STR(aY[2]) } )

::Ribs[1].p2 := aTest[P2][3] // { Min_X,Max_Y }

aTest := ASORT( aTest,,, {|aX,aY| STR(aX[2])+STR(aX[1]) > ;

STR(aY[2])+STR(aY[1]) } )

::Ribs[1].p1 := aTest[P1][3] // { Max_X,Max_Y }

#ENDIF

! Note : i have add 4 Points on Edge to "fill Screen" which might be the Reason that this works (fast)

while "FindPoint()" try R1 & R2 there will be a lot of "dupe" ( 20-30 % )

**Code:**

#IFDEF AO_PATCH1

IF ASCAN(::aDupe,{|x| x[1] = r1 .AND. x[2] = r2 }) > 0

RETURN(0)

ELSE

AADD(::aDupe,{r1,r2})

ENDIF

#ENDIF

but it still use 2 FOR / NEXT Loop to compare with "each other" Point it a Circle match ...

those "Patch" have reduce "solve" for 100 Point to < 20000 ( we have start with > 37000 ) so Time decrease about 50%

Attachment:

DLT_PATCH1_19968.jpg [ 16.95 KiB | Viewed 11687 times ]
coming next :

i have ASORT(::aPoints, ...)

... what about calculate Distance and create a Matrix ...

i can get Distance R1 to every other Point and same with R2

**Code:**

METHOD DemoDlg:Distance(aPos1,aPos2)

LOCAL nLen:=Len(aPos1), i, nTotal

/* For 1,2,3, or notional Dimensions, perform a Distance calculation */

nTotal:=0

FOR i:=1 TO len(aPos1)

nTotal+=((aPos1[i]-aPos2[i])^2)

NEXT i

RETURN Sqrt(nTotal)

i have already implement in Source ...

i guess i still need 2 FOR / NEXT Loop but i can begin with shortest Distance of R1 / R2

... to be continue