Delaunay triangulation in Alaska

This forum is for eXpress++ general support.
Message
Author
User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Delaunay triangulation in Alaska

#11 Post by Auge_Ohr »

i have used your Xbase++ EXE to produce this Result.
i have not compare your Xbase++ Code with Pascal Code.

as i can say the Pascal Code only "calculate" Coordinate but does not "paint"
in your Xbase++ Code you still "paint" Pixel by Pixel ... why ?

Code: Select all

FUNCTION Circle(hDC,X0,Y0,R0,nColor)
FUNCTION Line(hDC,X1,Y1,X2,Y2,nColor)
change hDC back to oPS and use GRA Function to "paint"
You can correct my source code to correct this problem?
I understand that you did it. Do you understand, what is it?
i would use your Code if you compile with /W ... and not using any PUBLIC ...

i did similar "Calculation" with Circle to (quick) rotate a Bitmap.
i also begin with Triangle to get a Point on Circle but it was to slow and not exact.

Code: Select all

R:=sqrt(dx1*dx1+dy1*dy1)   // Pythagoras
IF mFlagCircle
   Circle(hDC,xo,yo,R,nColorB)          // ‘¤¥« âì ®â®¡à ¦¥­¨¥ ®ªà㦭®áâ¨, ¥á«¨ íâ® § ¤ ­®
ENDIF
btw. i can not read "non" ASCI Sign on my System
i found a Way to use GraInitMatrix()*** with GraRotate() to build a Vertices for API "PlgBlt".
i think same Way can be used for your Problem.
*** c:\ALASKA\XPPW32\INCLUDE\gra.ch

Code: Select all

LOCAL aMatrix   := GraInitMatrix()
LOCAL oPs       := ::oStatic2:lockPS()

   nCalc1 := nDegrees+(270)
   IF nCalc1 > 360
      nCalc1 -= 360
   ENDIF
   nSegment := graSegOpen(oPs)
   GraSegClose(oPS)
   GraRotate( oPS, aMatrix, nCalc1, {aSize1[1]/2,aSize1[2]/2}, GRA_TRANSFORM_REPLACE )
   GraSegDestroy( oPS, nSegment )
   cVertices1 := ::DrehX(aMatrix,aSize1,aSize2)
as you see i just use aMatrix Array Result of GRA Function ... no need to "calculate" with SIN()/COS()
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Delaunay triangulation in Alaska

#12 Post by Eugene Lutsenko »

I have converted my PRG to DOC to be able to read comments. I attach a running program in Pascal. Everything else - the same.

You write:
Auge_Ohr wrote:change hDC back to oPS and use GRA Function to "paint"
On something like this, I thought. But I still do not know how to do it. To get the value ops need to create a graphic standard graphical tools. But then, with such an object will not work Roger schedule that I need. Especially need to be able to read the pixel values. But beyond that I can change the image in the process of handling the button clicks. And how to do this with a standard graphics I do not know. Only if you use AktiveX, but I refused him, because it must be installed.

About the rest, to be honest, I do not know how it can help. While this in itself is interesting.
Attachments
DeloneTriangulation.rar
(282.98 KiB) Downloaded 598 times

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Delaunay triangulation in Alaska

#13 Post by Auge_Ohr »

i try your last Sample but there are still lines missing ... and slow
Missing_Lines2.jpg
Missing_Lines2.jpg (248.62 KiB) Viewed 9992 times
so i made my own Class from PAS Code
DLT_PAS.JPG
DLT_PAS.JPG (179.79 KiB) Viewed 9992 times
Hardware : P4 (!) HT 3GHz, HD 3450 512MB, 2GB RAM
here Demo EXE to test on your Hardware
DLT001.ZIP
(23.54 KiB) Downloaded 585 times
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Delaunay triangulation in Alaska

#14 Post by Eugene Lutsenko »

It works perfectly, quickly and correctly! It would be interesting to use the source code. What do the different colors of edges? And what Pascal programs you have taken as a basis: the first or the second?
Image
Image

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Delaunay triangulation in Alaska

#15 Post by Auge_Ohr »

It works perfectly, quickly and correctly! It would be interesting to use the source code.
still working on it ...
i "think" it need to much "solve" even Time does not differ much.

now i use a full Circle (360°) but for 3 Point of Triangle i need max. 180° to find all 3.
if i measure Distance of Pixel i can calculate how much Dregree i have to search for.
What do the different colors of edges?
this was my Question about Color of each Pixel.
i can generate Points and have X,Y Coordinate but what Color Value (RGB) ? where does it come from ?

Code: Select all

METHOD DemoDlg:Triangulation()
...
  ::Line(::Points[p1].x,::Points[p1].y,::Points[n].x ,::Points[n].y ,nColorR)
  ::Line(::Points[p2].x,::Points[p2].y,::Points[n].x ,::Points[n].y ,nColorG)
  ::Line(::Points[p1].x,::Points[p1].y,::Points[p2].x,::Points[p2].y,nColorB)
these are those 3 Line from each Triangle -> Color for Gradient ?

when run Demo Sample twice, with same Points, some Lines will be overwrite with "new" Color ... hm ...
... and "where" (1st Ribs ?) to start ... and use which Edge of the Triangle as Start for Gradient ?


---

next Problem

i try to take Color from mid of Line for TriGradient
Match_Color_TriAngle.jpg
Match_Color_TriAngle.jpg (138.72 KiB) Viewed 9970 times
i also start from mid of Line else Color will went to Triangle Edge ...
Edge_Color_TriAngle.jpg
Edge_Color_TriAngle.jpg (92.31 KiB) Viewed 9970 times
here i use Random Color
Random_Color_TriAngle.jpg
Random_Color_TriAngle.jpg (100.05 KiB) Viewed 9970 times
so the Problem is to make a TriGradient in a Triangle ... it would be easy if it is a rectangle.
greetings by OHR
Jimmy

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Delaunay triangulation in Alaska

#16 Post by Auge_Ohr »

latest Demo
DLT002.ZIP
v1.9.335
(30.2 KiB) Downloaded 567 times
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Delaunay triangulation in Alaska

#17 Post by Eugene Lutsenko »

you get a very nice! I would also like to be able to so. I need to meet the challenges that I put in front of him, and for the future.

The first two points of the characteristics - is its coordinates X, Y. The color - this third characteristic points - Z. The It's just a number. How to convert this value Z in color. I think we need to find the minimum and maximum Z, and then display the linear range on the color circle, but not 360 degrees, and 270. Then, only the color triangle vertices converging in one point, is the same. This is what we should, if we imagine that the triangulation of the surface displays, such as terrain.

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Delaunay triangulation in Alaska

#18 Post by Auge_Ohr »

this Version seem to make what i want :)

i did add 4th Element to Points Array to hold Color Value
i use GraGradient with these Color on Edge to create TriGardient
Color_Points_TriAngle.jpg
Color_Points_TriAngle.jpg (86.09 KiB) Viewed 9953 times
Color_Gradient_TriAngle.jpg
Color_Gradient_TriAngle.jpg (50.76 KiB) Viewed 9953 times

Code: Select all

// TTPoint=record
//   x,y:integer;
//
#xtranslate .x          => \[1\]
#xtranslate .y          => \[2\]
#xtranslate .z          => \[3\]
#xtranslate .Color      => \[4\]


// TTriangle=record
//   p1,p2,p3:integer;
//
#xtranslate .xx         => \[1\]
#xtranslate .yy         => \[2\]
#xtranslate .zz         => \[3\]


METHOD DemoDlg:DrawGradient()
LOCAL X1,Y1,X2,Y2,X3,Y3,j
LOCAL aColors  := {}
LOCAL nColor1  := GRA_CLR_WHITE
LOCAL nColor2  := GRA_CLR_WHITE
LOCAL nColor3  := GRA_CLR_WHITE

   FOR j := 1 TO ::TrianglesCount

      IF ::triangles[j].xx * ::triangles[j].yy * ::triangles[j].zz = 0
          EXIT
      ELSE
         X1 := ::Points[ ::triangles[j].xx ].x
         Y1 := ::Points[ ::triangles[j].xx ].y

         X2 := ::Points[ ::triangles[j].yy ].x
         Y2 := ::Points[ ::triangles[j].yy ].y

         X3 := ::Points[ ::triangles[j].zz ].x
         Y3 := ::Points[ ::triangles[j].zz ].y

         nColor1 := ::Points[ ::triangles[j].xx ].Color
         nColor2 := ::Points[ ::triangles[j].yy ].Color
         nColor3 := ::Points[ ::triangles[j].zz ].Color

         aColors := {nColor1,nColor2,nColor3 }
         GraGradient(::oPS, {X1,Y1}, {{X2,Y2}, {X3,Y3}}, aColors, GRA_GRADIENT_TRIANGLE)
      ENDIF
   NEXT

RETURN NIL
as you see i use #xtranslate to simulate PAS Syntax ... seems me "readable" ;)

some Words to PAS Code: there some "BEGIN". if you found "BREAK" than use BEGIN SEQUENCE

i "think" i understand why your Code sometimes fail with missing Lines.
if you look on your Cirle, create with SetPixel(), not every Pixel is painted so you might not "hit" it to compare.

to paint Line,Circle or Gradient you can use plain Xbase++.
only in Function ShowColor() i use GetPixel as DLL Call.

as it works now i can begin to optimize Code ... try & Error to "solve" seem me not the fastest Way.
DLT003.ZIP
(36.99 KiB) Downloaded 557 times
Syntax : DLT.EXE <NumPoints>

"save" -> Points.DBF. if found on start it will use its Data instead of Random.

LIMIT :

Ribs,Triangle := 10240 // Static Array
NumPoints < 10240/3 ??? // AADD()
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Delaunay triangulation in Alaska

#19 Post by Eugene Lutsenko »

Hey, Jimmy!

All very fine, just fine! You have proven that this is possible! But could you put on the forum or send me the source code in Alaska, which could compile and execute? And that to me your tips and programming finds enough to do something like that myself.

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Delaunay triangulation in Alaska

#20 Post by Eugene Lutsenko »

Jimmy!
Answer that one please

Post Reply