Lines on shapes

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.

Hi,

Is there anyone out there who can help me with an algorithm for figuring out whether a line lies on the edge of any arbitary area? I've been trying to get this working for a couple of weeks and my mind is just too weak for this :)

I have an image which has a lot of lines in it that make up any type and shape of, err, shape. The lines are stored as a series of points in an array. I'd like the user of my tool to be able to select lines somehow.

My first idea was to all them to drag an area over the lines to select them. But there is possible problems of selecting too many or the wrong lines too easily.

My second idea was to create a full scale bitmap, draw all the lines and then flood fill the area and check the colour of pixels surrounding the points in the array. Problem: full scale image is 21600 * 10800 :(

I would still like to use the second method, as these shapes will always be fully enclosed areas. But I can't figure out a good way to decide if a line is on the border of the area the user clicks in.

Any suggestions would kick ass :wink:
Cheers.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

Is it possible for you to draw a small picture of what this looks like, i'm having a hard time picturing in my mind what the algorithm should do. Are the lines stored as vectors, vertices or what?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Pupil

Is it possible for you to draw a small picture of what this looks like, i'm having a hard time picturing in my mind what the algorithm should do. Are the lines stored as vectors, vertices or what?
OK

Just an image with some enclosed shapes in it :)

I'd like to be able to pick any X-Y co-ordinate on that image and be able to select the lines which make up the outline of the area that was clicked on. For example, clicking in the centre of the image would select the lines shown here


The lines are stored as an array of X-Y co-ordinate for the start and end points.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

OK, nice pics :)

Are the points that make up a shape grouped together somehow?

I think using vector math would be appropriate to use in this case. The problem shouldn't prove to be too hard to solve, i think, at least that is my estimatation, which might very well be wrong.

Maybe you could send me a small sample of you shape picture to investigate further how to solve this...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Mischa.

Hi!

Maybe PtInRegion_(.. could help you?

Best Greetings
Mischa
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Pupil
Are the points that make up a shape grouped together somehow?
Yes, they are grouped as a sequence of lines, so one line that follows another will join onto the previous one. There are breaks in the sequences, but I do not know exactly where they occur.
I think using vector math would be appropriate to use in this case. The problem shouldn't prove to be too hard to solve, i think, at least that is my estimatation, which might very well be wrong.
Oh no, I'll need to go do some maths revision :wink:
Maybe you could send me a small sample of you shape picture to investigate further how to solve this...
OK, but it will probably be tomorrow as I don't have the files with me right now.

Thanks.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Maybe you could send me a small sample of you shape picture to investigate further how to solve this...
OK, http://www.david-mcminn.co.uk/graphics/Image1.png is an example of one of the pictures from the data files. It's 50Kb.

And http://www.david-mcminn.co.uk/files/mwcoast.zip is one of the source files used for that image. It's 233Kb.

The points are stored as floating point numbers in pairs. Each point is a longitude and latitude multiplied by 60 (so they range from -10800 to +10800 and 5400 to -5400).

The first two in each set are ID and number of points. Then you have the number of points. Then another set (ID + number) and so on. An ID of 0 is used to terminate the file (IIRC).

Thanks.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Andre.

David, the picture / links are missing...

Regards
André

*** German PureBasic Support ***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

Move your Mouse over those two 'here's, and you'll see...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

Ok, i'll take a look at it this weekend...
Post Reply