Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > General > Chit Chat
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Chit Chat The place for open discussions.

Point Inside A triangle

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 09-13-2009, 03:23 PM
ceaser's Avatar
Basic4ppc Veteran
 
Join Date: May 2008
Location: Paarl, South Africa
Posts: 306
Default

Thanks Wolfgang...it helped. It seems to be faster than using the area method.

My only problem is that, like DeeCee says, if you have 10 000 triangles. It can take some time when the triangle that you are working with is the last one!

Thanks
Michael
Reply With Quote
  #12 (permalink)  
Old 09-25-2009, 10:23 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi DeeCee and Ceasar,

I was on travel the last weeks, so I didn't answer your post before.

I have made some tests finding the triangle where the point is in.
Attached 3 test programs:
The programs checks 10000 triangles, the point is in the last one.

3 methods are used:
1)Check triangle:
- checks if the point lies in the triangle
2)Check rectangle:
- calculates the coordinates of the surrounding rectangle
- checks if the point lies in the surrounding rectangle
- if yes, checks if the point lies in the triangle
3)Check X Y Max Min:
- the xmin, xmax, ymin and ymax of the surrounding rectangle for each triangle are precalculated somewhere else in the program and memorized
- checks if the point lies in the surrounding rectangle
- if yes, checks if the point lies in the triangle

Checking if a point lies in a rectangle is faster then checking for a triangle.

TestFindTriangle1:
- standard variables
- 10000 triangles with the 3 coordinates

TestFindTriangle2:
- variables declared as Double
- 10000 triangles with the 3 coordinates

TestFindTriangle3: variables declared as Double
- variables declared as Double
- 4 points with their coordinates
- 10000 triangles with the vertex point indexes

Test results optimized compiled on my htc Touch HD in seconds:
Code:
<font size="2"><font face="Courier New"><font size="2"><font face="Courier New">  Test1 Test2 Test3</font></font></font></font>
<font size=
"2"><font face="Courier New"><font color="#800080"><font size="2"><font face="Courier New"><font color="#800080"><font size="2"><font face="Courier New"><font color="#800080">1</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">) </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">43    </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">30    33</font></font></font></font></font></font></font></font></font>
<font face=
"Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">2</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">) </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">40    13</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">    15</font></font></font></font></font></font></font></font></font>
<font face=
"Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">3</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">) </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">12     4</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">     5</font></font></font></font></font></font></font></font></font>
Hope this could help you.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #13 (permalink)  
Old 10-13-2009, 07:22 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Be sure to check out my new http://www.basic4ppc.com/forum/addit...html#post28926 which should give a performance boost to this sort of calculation. You could probably do the Delauney calculation in Basic4ppc now.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #14 (permalink)  
Old 10-13-2009, 08:22 PM
ceaser's Avatar
Basic4ppc Veteran
 
Join Date: May 2008
Location: Paarl, South Africa
Posts: 306
Default

Hi Agraham

Thanks for that. I did have a look at it, but have not played with it yet.

I suppose I could also use it in my surveying program, as there are routines which are based on some heavy maths. For instance the calculations involved in a spiral, cross-section calcs, or even in the CAD....

Thanks
Michael
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
dllToDate stating point Cableguy Open Source Projects 90 03-01-2009 07:46 PM
Array inside Struct fjsantos Questions (Windows Mobile) 2 06-17-2008 05:28 PM
Fixed Point Math im4retro Questions (Windows Mobile) 3 05-31-2008 07:13 AM
3 Point Arc ceaser Questions (Windows Mobile) 38 05-27-2008 04:23 PM
Ticks as a floating point value on XP (not 2000) lancaster Questions (Windows Mobile) 4 04-09-2008 11:38 AM


All times are GMT. The time now is 09:56 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0