Looking for an algorithm (GIS) [text only]
Author Message Looking for an algorithm (GIS) [text only]

Hello !

I'm working with a GIS and I have a pointer to structures (X,Y) that are
nodes coordinates that define an Arc:

parray = (X1,Y1) (node 1)
parray = (X2,Y2) (node 2)
parray = (X3,Y3) (node 3)
.........

And I have the couple (from,to) that define a new "Arc".
"from" and "to" are in percent and define the beginning and the end of
the new Arc. Note that "from" can be greater than "to"

Of course, It is possible that a new node has to be defined.

How can I dynamically generate a new "parray" with these criteria ?

More generally, is there a web site where I can find these kinds of
algorithms ?

Help would be very appreciated.

--
Jean-Paul Dzisiak

CEME - Universit de Lige
Centre d'Etude et de Modlisation de l'Environnement
Sart-Tilman B5
B-4000 Lige
BELGIQUE

Tl +32 (0) 4 366 23 56
Fax +32 (0) 4 366 23 55

Mon, 04 Apr 2005 16:50:13 GMT  Looking for an algorithm (GIS) [text only]

Quote:
> Hello !

> I'm working with a GIS and I have a pointer to structures (X,Y) that are
> nodes coordinates that define an Arc:

> parray = (X1,Y1) (node 1)
> parray = (X2,Y2) (node 2)
> parray = (X3,Y3) (node 3)
> .........

> And I have the couple (from,to) that define a new "Arc".
> "from" and "to" are in percent and define the beginning and the end of
> the new Arc. Note that "from" can be greater than "to"

have:

struct point {
double x;
double y;

Quote:
} parray[] = {

{X1, Y1},    /* where Xi and Yi are some constants */
{X2, Y2},
{X3, Y3}

Quote:
};

which describes an arc in some sort of coordinate system.
What you want to have is an arc derived from the given
that starts at n% of the total length and ends at m% of the total
length of the original arc. Is that correct?

But you are not asking us how to perform the math to do this, are
but not with the algorithm itself.

Quote:

> Of course, It is possible that a new node has to be defined.

A new node, for what?

Quote:

> How can I dynamically generate a new "parray" with these

criteria ?

with malloc():

struct point *parrayp;

parrayp = malloc(3 * sizeof *parrayp);  /* enough to describe an
arc */

Quote:

> More generally, is there a web site where I can find these kinds of
> algorithms ?

> Help would be very appreciated.

You post here, you read here.
--

"LISP  is worth learning for  the profound enlightenment  experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days."   -- Eric S. Raymond

Tue, 05 Apr 2005 00:22:51 GMT  Looking for an algorithm (GIS) [text only]

Quote:

>> Hello !

>> I'm working with a GIS and I have a pointer to structures (X,Y) that are
>> nodes coordinates that define an Arc:

>> parray = (X1,Y1) (node 1)
>> parray = (X2,Y2) (node 2)
>> parray = (X3,Y3) (node 3)
>> .........

>> And I have the couple (from,to) that define a new "Arc".
>> "from" and "to" are in percent and define the beginning and the end of
>> the new Arc. Note that "from" can be greater than "to"

> have:

> struct point {
>   double x;
>   double y;
> } parray[] = {
>   {X1, Y1},    /* where Xi and Yi are some constants */
>   {X2, Y2},
>   {X3, Y3}
> };

> which describes an arc in some sort of coordinate system.
> What you want to have is an arc derived from the given
> that starts at n% of the total length and ends at m% of the total
> length of the original arc. Is that correct?

Yes, this sort of thing is fairly common in GIS, but the OP's
terminology is a little confusing (s/vertex/node/ in most instances).
And these probably aren't "arcs" in the normal mathematical sense, but
chains of line segments.

Quote:
> But you are not asking us how to perform the math to do this, are
> but not with the algorithm itself.

OP posted this in a number of groups...

Algorithm is theoretically straight forward:
Compute the length of each segment.
Sum the lengths.
Find the segments for the start and the end.
Compute the start and end vertices along each of the respective
segments (i.e. arraynew -> 10% (parray[n] <-> parray[n+1])).