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

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.

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!)

Hi Agraham\Klaus:sign0085::sign0085::sign0188::sign0188: Any ideas?:BangHead::sign0148: Thanks Michael

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!.

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.

3D drawing Look at my 3D excersize, if it helps you - be welcome to use it. http://www.basic4ppc.com/forum/share-your-creations/3908-exercise-3d-rotation.html#post22546

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

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

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

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_Clicklastpoint = 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 pointsminy = point(1).utm_yFor i = 2 To lastpoint If point(i).utm_y < miny Then miny = point(i).utm_yNext' sum all rectangles of two following pointstotal_area = 0For 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 KMsqrkm.Text = Format(total_area,"N3") dunham.Text = Format(total_area * 1000, "N1") ' or in Dunhamsacre.Text = Format(247.105 381 47 * total_area,"N3") ' or in Acresareapanel.Visible = TrueEnd 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).