Page 1 of 2

Whats the fastest way to do this?

Posted: 08 Jan 2006, 15:37
by krogothe
Right, i have a load of points in a 2d array, in a certain order:

Image

I want to draw lines beween them of a certain (variable) thickness (think locii of connected lines) so that any point within a certain distance from the dots and the imaginary lines connecting them has some operation performed to them (in this picture they are made black). Like this:

Image

Surely i could work out every point on the lines and then draw a circle around it and then set a flag so that the points around it arent processed again, but that would be much too slow! How could i speed that up?

Posted: 08 Jan 2006, 17:06
by Weaver
Why cant you do it with circles on the points and rectangles between them?

Posted: 08 Jan 2006, 19:20
by Sheekel
dragons teeth placement?

:P

Posted: 08 Jan 2006, 20:19
by Lindir The Green
:roll:

mex placement.

Posted: 08 Jan 2006, 20:22
by krogothe
neither now shut up or help :P
yeah weaver's way is faster, but i think there must be a way to make it faster still, probably with matrix algebra or something

Posted: 08 Jan 2006, 20:35
by AF
If we knew what it was for we could answer you better.

My thoughts would be to use more points inbetween the points, sorta like a dotted line, spaced apart by x*0.6, where x would be the breadth/thickness of the lines you describe.

When you get a new point you need to check, split the problem space into 4 quadrants, and search for the nearest existing point to the new point in the new points quadrant. Then measure the distance and if distance <= the x of that point, then it is inside the line, else it is outside.

Or you could list each point in turn, and find the gradient of the lines joining them up. Then all you have todo is check the gradient of the new point against existing points, and if the gradient of the new line is equal to the gradient of any of the existing lines then it is on the line, and if it is inside but nto on then you'd ahve to vary it to how big the difference is in proportion to what x is.

Or you could use a grid approach, flagging grid squares that have a point in them, or have a lines passing through or nearby. That would mean generating the grid data would eb costly, but after that the checks are much faster. Find which grid square the new point is and check if it's flagged.

Posted: 08 Jan 2006, 20:39
by AF
=O

Where else have we seen these diagrams from krogothe?!?!?! his mex class! And what was it that somebody recently told me about how NTAI handled mex spots (maybe it was in a pm with an NTAI test build log), how they didnt follow a path to make visiting each mex in turn more efficient... I think that might be what krogothes doing, if not it's given me enough to try and implement it once my exams are done.

hmm that and I now know how I'm gonna do DT walls.....

Posted: 08 Jan 2006, 20:50
by jcnossen
neither now shut up or help
yeah weaver's way is faster, but i think there must be a way to make it faster still, probably with matrix algebra or something
Whatever way you do it, the thing that actually takes up most of the CPU time will be rasterizing it onto a grid, and accessing whatever 2D array you want to access.
I would also represent everything by quads, then you don't have to make a seperate rasterization for the circles. Now just make a fast quad rasterization. There are plenty of tutorials about software rendering anyway so that should be no problem.

Posted: 08 Jan 2006, 20:56
by krogothe
LOL
you guys suck at guessing! :lol:
all i want is the quickest way to do just what youre seeing, filling in pixels from a certain distance from points and lines, nothing else!
AF, The first way you mentioned could work, but thats basically drawing less circles, which are slow to draw(then again i could use some faster methods ive learnt :twisted:)... ill try either way and see which is fastest...
EDIT Ill stay on the safe side and take advice from zaphod first (eg find out what rasterizing means) :)

Posted: 08 Jan 2006, 21:06
by jcnossen
We aren't guessing, we're giving possible solutions. You still seem to thing that there is an optimal solution for every problem... THERE ISN'T.

Posted: 08 Jan 2006, 21:15
by krogothe
I dont think theres an optimal solution for things (except my metal class :roll: )
You didnt guess, but the 3 guys before you did, guessing if it was for mexes or dragon teeth, which i pointed out, its for neither, please dont all go hostile on me because i made a little joke, if weve managed a couple of weeks without krogothe barbecues, we can manage a few more!

Posted: 08 Jan 2006, 21:30
by jcnossen
I didn't really mean that as hostile though... just a bit too persuasive I guess ;)
Ok my guess, is it for unit group movement through the map?

Posted: 08 Jan 2006, 21:38
by krogothe
hmmm a good guess (considering you read the old posts about it) but no biscuit :P
okay im getting acquainted to rasterizing, it could be good since the corners need not be rounded

Posted: 08 Jan 2006, 21:40
by Masse
this must be some sort of a defence placement...

well... lets think... what u need is
better defence placement
unit grouping
all air/water stuff
...umm...
i forget all the other stuff...

Posted: 08 Jan 2006, 21:44
by krogothe
nope

Posted: 08 Jan 2006, 21:47
by Min3mat
scouts attacking mexes?

Posted: 08 Jan 2006, 21:47
by AF
Is this the actual thing your messing with or is it you trying to log it to an image file...

Posted: 08 Jan 2006, 21:55
by krogothe
no and its the actual thing

Posted: 08 Jan 2006, 21:58
by jcnossen
is it a new painting program?

Posted: 08 Jan 2006, 22:00
by krogothe
rofl
not its KAI-related