Delauney

Discussion in 'Questions (Windows Mobile)' started by ceaser, Jun 6, 2009.

  1. ceaser

    ceaser Active Member Licensed User

    Hi All

    Attached is a module to generate a Tin Model (with the help of Agraham:sign0188:). With this Tin Model one can generate contours, shade the model,calc areas & volumes.

    What I need help in is the following::sign0085:
    1. Add triangles by tapping on three points.
    2. Delete a triangle
    3. A better shading routine.
    4. 3D View

    I am also attaching a file called "Check.txt". Import this file to get points on your screen that you can work with.

    Thanks
    Michael
     

    Attached Files:

  2. klaus

    klaus Expert Licensed User

    Hi Michael,

    I wanted to have a look at your program, but there are some files missing:
    Stock.bas and images.

    1. Add triangles by tapping on three points.
    Should there be at least 1 or 2 existing points?
    If 3 new points, how to connect to the other triangles ?

    2. Delete a triangle
    How do you think it ?
    By deleting what ?

    Best regards.
     
    Last edited: Jun 6, 2009
  3. ceaser

    ceaser Active Member Licensed User

    Hi Klaus:sign0188:

    Sorry about that! :sign0013::BangHead:I am attaching the "Stock.bas" file.

    What I need is:
    1. By tapping inside a triangle, the routine should delete the selected triangle.
    The user must however first confirm before deleting the triangle.
    2. What I would like by adding triangles manually, is that by tapping on three points, the routine should form a triangle with the 3 selected points. This is when there are no existing triangles. However if the 1st selected point sits adjacent to a existing side of a triangle, then the routine must automatically form a triangle with the adjacent 2 points of the existing triangle. The routine must also not allow adding a triangle, if one exists already.
    3. Any idea on the shading of the Tin Model that it looks more realistic? A blueish color (water) at the low levels, green(vegetation & trees) in the middle, changing (very little vegetation) to brown and finally at the highest level it must be very light (rock outcrop\snow) in color.
    4. Any idea on the 3D view?

    Thanks
    Michael Papenhagen
    (alias Ceaser!)
     

    Attached Files:

  4. ceaser

    ceaser Active Member Licensed User

    Hi Agraham\Klaus:sign0085::sign0085::sign0188::sign0188:

    Any ideas?:confused::BangHead::sign0148:

    Thanks
    Michael
     
  5. agraham

    agraham Expert Licensed User

    No because the code doesn't run, it errors when trying to import Check.txt and I'm afraid I've got other things to do than try to fix it!.
     
  6. klaus

    klaus Expert Licensed User

    Hi Michael,

    I understand agraham's trouble, the code didn't work either at the beginning. Needed to find the right Delauney library, and furtunately I had an older Check.csv file, from you, which works.
    Now I am still trying to find what's wrong between the CoOrds and mouse positions, because klicking in a triangle I can't find. It takes quite some time to find out what happens, and the last days I was busy on other things.
    This is for erasing a triangle. I have not yet looked at adding a triangle it's related to the same scaling problem.
    For the shading I havo no solution.
    For 3D drawing, I'm afraid that it would be very slow, I think a library would more efficient than B4PPC code.

    Best regards.
     
    Last edited: Jun 9, 2009
  7. derez

    derez Expert Licensed User

  8. ceaser

    ceaser Active Member Licensed User

    Thanks Derez. I will have a look at it.

    Anyway, I am posting the code again with the importing of the coordinate points fixed.:sign0085:

    Thanks
    Michael
     
  9. ceaser

    ceaser Active Member Licensed User

    Hi derez

    I had a look at your coding. Excellent code! I will definitely be able to use it.:sign0188:

    Thanks
    Michael
    Freiherr von Klein Bolhagen
     
  10. derez

    derez Expert Licensed User

    I'm glad that it will be of use to someone :)

    BTW - the trick for identifying if a polygon has to be shown or hidden is similar to the criteria for deciding if a point is above or below a line, only in one dimension higher.

    Also - I wrote an algorithm to calculate the area of a poligon without the need to split it to triangles. I use it in my navigation program, to calculate an area which is defined by a route (set of coordinates), it is assuming flat area of course. If you want it - just say :)
     
    Last edited: Jun 13, 2009
  11. ceaser

    ceaser Active Member Licensed User

    Hi derez

    Yes please:wav:

    Thanks
    Michael
     
  12. derez

    derez Expert Licensed User

    Here is the code, see the attached image for the theory. I'm sure you didn't expect such a simple one...

    Code:
    Sub Area_Click
    lastpoint = tgtnum.Text + 
    0
    ' check with the user that the last point is defined.
    If Msgbox("Last point is " & lastpoint & " ?""Last Point" ,cMsgboxYesNo, cMsgboxNone)= cNo Then Return

    ' find the minimum of UTM_Y of all the points
    miny = point(1).utm_y
    For i = 2 To lastpoint
     
    If point(i).utm_y < miny Then miny = point(i).utm_y
    Next

    ' sum all rectangles of two following points
    total_area = 0
    For i = 1 To lastpoint - 1
      total_area = total_area + ((
    point(i).utm_y + point(i+1).utm_y)/2 - miny) * (point(i+1).utm_x - point(i).utm_x)
    Next
    ' also between the last and the first - now it is a closed loop.
    total_area = total_area + ((point(lastpoint).utm_y + point(1).utm_y)/2 - miny) * (point(1).utm_x - point(lastpoint).utm_x)

    total_area = 
    Abs(total_area/1000000' change from sqr meters to sqr KM
    sqrkm.Text = Format(total_area,"N3"
    dunham.Text = Format(total_area * 
    1000"N1"' or in Dunhams
    acre.Text = Format(247.105 381 47 * total_area,"N3"' or in Acres
    areapanel.Visible = True
    End Sub
    The calculation is based on UTM coordinates.
    If you want to do it with Geo coordinates - remember that one degree in latitude is always 60 Nm, while in longitude it is 60 Nm * cos(latitude), and if the diferences in latitude are large, take the middle between Y and miny for the cos(latitude).
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice