[GRASS5] Current sockets bug

Hi all,

it seems I got an idea about the sockets bug:
- It occurs in
src/display/devices/XDRIVER/XDRIVER24/SWIZCHER.c

The call should be
Usage: x0 [nlev]
          ^^^^^
but
argv[1] is:
/data3/grass5/grass5/dev/fifo.1a /data3/grass5/grass5/dev/fifo.1b

at that position (test around line 118ff).
As fifos are not required, something must be wrong here.

Hopefully someone gets it fixed...

Markus

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Fri, Mar 09, 2001 at 01:43:47PM +0000, Markus Neteler wrote:

Hi all,

it seems I got an idea about the sockets bug:
- It occurs in
src/display/devices/XDRIVER/XDRIVER24/SWIZCHER.c

The call should be
Usage: x0 [nlev]
          ^^^^^
but
argv[1] is:
/data3/grass5/grass5/dev/fifo.1a /data3/grass5/grass5/dev/fifo.1b

at that position (test around line 118ff).
As fifos are not required, something must be wrong here.

Hopefully someone gets it fixed...

It's in d.mon/pgms/start.c (run2()). I think the define of USE_G_SOCKS
got missed in the configure.in somehow. Fix that, and the problem
should disappear. I'll try to look at it this weekend.

--
Eric G. Miller <egm2@jps.net>

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

Greetings,

I would greatly appreciate any help with developing a simple function that returns the angle (in degrees) of a line when given two points (x1, y1 and x2, y2).

Embarrassingly I have spent days trying to figure this out (that's what I get for using the teachers edition of geometry in high school!!). ;->

I have ran across a function on the web, but somehow it seems really off:
     angle = (((Atan((northingDifference/eastingDifference)))*180)/PI)

The points that I am using are UTM coordinates.

I realize that this may seem slightly of topic, however I will contribute the developed module when I am done. I figure that this function should be a piece of cake for all of you brilliant people out there.

An example set of coordinates are:

  x1 = 265,000
  y1 = 4,155,000

  x2 = 305,000
  y2 = 4,154,000

Thanks,
Jeshua Lacock
Cartographer/Owner
http://SierraMaps.com
http://3dTopoMaps.com
Telephone: (760) 935-4481

---------------------------------------- If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

Jeshua Lacock wrote:

Greetings,

I would greatly appreciate any help with developing a simple function
that returns the angle (in degrees) of a line when given two points
(x1, y1 and x2, y2).

Embarrassingly I have spent days trying to figure this out (that's
what I get for using the teachers edition of geometry in high
school!!). ;->

I have ran across a function on the web, but somehow it seems really off:
     angle = (((Atan((northingDifference/eastingDifference)))*180)/PI)

The points that I am using are UTM coordinates.

I realize that this may seem slightly of topic, however I will
contribute the developed module when I am done. I figure that this
function should be a piece of cake for all of you brilliant people
out there.

An example set of coordinates are:

  x1 = 265,000
  y1 = 4,155,000

  x2 = 305,000
  y2 = 4,154,000

Thanks,
Jeshua Lacock
Cartographer/Owner
http://SierraMaps.com
http://3dTopoMaps.com
Telephone: (760) 935-4481

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

Jeshua,

If you take a look at the new version of r.profile, it has a routine that returns
the azimuth between two points. Hopefully this helps with what you are looking
for.

A library routine that returns the azimuth between two points would be a nice
feature.

--
Bob Covill

Tekmap Consulting
P.O. Box 2016
Fall River, NS
Canada
B2T 1K6

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

Jeshua Lacock wrote:

Greetings,

I would greatly appreciate any help with developing a simple function
that returns the angle (in degrees) of a line when given two points
(x1, y1 and x2, y2).

Embarrassingly I have spent days trying to figure this out (that's
what I get for using the teachers edition of geometry in high
school!!). ;->

I have ran across a function on the web, but somehow it seems really off:
     angle = (((Atan((northingDifference/eastingDifference)))*180)/PI)

Jeshua

This might give an answer in the wrong quadrant - only reliable if
between N -> E.

The atan2 function is a standard function to determine the value of the
angle and assign it to the correct quadrant by taking account of the
sign of the easting and northing offsets from the first point:

in degrees

angle = atan2( y2 - y1, x2 - x1 ) * 180 / M_PI /* if math.h def'd */

The angle will be in standard mathematical format:

East = 0 --> (anticlockwise) --> North = 90 etc.

but you may want to use a different convention.

The points that I am using are UTM coordinates.

Above should be OK. Some uses may require a very small correction based
on considerations of the projection, but that would depend on the exact
problem.

David

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Sat, Mar 10, 2001 at 04:25:20PM -0400, Bob Covill wrote:

Jeshua Lacock wrote:

> Greetings,
>
> I would greatly appreciate any help with developing a simple function
> that returns the angle (in degrees) of a line when given two points
> (x1, y1 and x2, y2).
>
> Embarrassingly I have spent days trying to figure this out (that's
> what I get for using the teachers edition of geometry in high
> school!!). ;->
>
> I have ran across a function on the web, but somehow it seems really off:
> angle = (((Atan((northingDifference/eastingDifference)))*180)/PI)

Arctan() will give you an acute angle. You would need to know the
quadrant the line is in (assuming the first point as the origin) to add
a correction factor.

Assuming (0 == North, 90 == East, etc...):

// Sorta code...

dy = (y2 - y1);
dx = (x2 - x1);

if (dy > 0.0 && dx > 0.0) {quadadjust = 0.0;}
else if (dy > 0.0 && dx < 0.0) {quadadjust = 360.0;}
else if (dy < 0.0 && dx > 0.0) {quadadjust = 180.0;}
else if (dy < 0.0 && dx < 0.0) {quadadjust = 180.0;}
else {
  if (dx == 0.0) {slope = (dy > 0.0) ? 0.0 : 180.0;}
  else if (dy == 0.0) {slope = (dx > 0.0) ? 90.0 : 270.0;}
  else {/* huh? */}
  return slope;
}

slope = ((atan(dy/dx) * 180) / M_PI) + quadadjust;
return slope;

// End.

Note, I haven't really checked the above... And floating point numbers
can be weird in comparisons, so maybe an EPSILON is needed...

I understand there are better ways to do this than using atan() which
can be expensive...

Jeshua,

If you take a look at the new version of r.profile, it has a routine that returns
the azimuth between two points. Hopefully this helps with what you are looking
for.

A library routine that returns the azimuth between two points would be a nice
feature.

--
Bob Covill

Tekmap Consulting
P.O. Box 2016
Fall River, NS
Canada
B2T 1K6

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

--
Eric G. Miller <egm2@jps.net>

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Sat, Mar 10, 2001 at 02:04:23PM -0800, Eric G. Miller wrote:

On Sat, Mar 10, 2001 at 04:25:20PM -0400, Bob Covill wrote:
> Jeshua Lacock wrote:
>
> > Greetings,
> >
> > I would greatly appreciate any help with developing a simple function
> > that returns the angle (in degrees) of a line when given two points
> > (x1, y1 and x2, y2).
> >
> > Embarrassingly I have spent days trying to figure this out (that's
> > what I get for using the teachers edition of geometry in high
> > school!!). ;->
> >
> > I have ran across a function on the web, but somehow it seems really off:
> > angle = (((Atan((northingDifference/eastingDifference)))*180)/PI)

Arctan() will give you an acute angle. You would need to know the
quadrant the line is in (assuming the first point as the origin) to add
a correction factor.

Assuming (0 == North, 90 == East, etc...):

// Sorta code...

dy = (y2 - y1);
dx = (x2 - x1);

if (dy > 0.0 && dx > 0.0) {quadadjust = 0.0;}
else if (dy > 0.0 && dx < 0.0) {quadadjust = 360.0;}
else if (dy < 0.0 && dx > 0.0) {quadadjust = 180.0;}
else if (dy < 0.0 && dx < 0.0) {quadadjust = 180.0;}
else {
  if (dx == 0.0) {slope = (dy > 0.0) ? 0.0 : 180.0;}
  else if (dy == 0.0) {slope = (dx > 0.0) ? 90.0 : 270.0;}
  else {/* huh? */}
  return slope;
}

slope = ((atan(dy/dx) * 180) / M_PI) + quadadjust;
return slope;

// End.

Note, I haven't really checked the above... And floating point numbers
can be weird in comparisons, so maybe an EPSILON is needed...

I understand there are better ways to do this than using atan() which
can be expensive...

Sorry, the above is *not correct*.
I think the below would work...

dy = y2 - y1;
dx = x2 - x1;

assert (!(dx == 0.0 && dy == 0.0));

if (dx == 0.0) /* Special case, vertical line */
{
  if (dy > 0.0)
    return 0.0;
  else
    return 180.0;
}
if (dy == 0.0) /* Special case, horizontal line */
{
  if (dx > 0.0)
    return 90.0;
  else
    return 270.0;
}
if (dx > 0.0)
  return 90.0 - atan(dy/dx) * (180 / M_PI);
else if (dx < 0.0)
  return 270.0 - atan(dy/dx) * (180 / M_PI);

exit (EXIT_FAILURE);

--
Eric G. Miller <egm2@jps.net>

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'