compass bearing from vector

Alejandro Hinojosa Corona alhinc at cicese.mx
Thu Jul 20 15:58:24 EDT 1995


> From grass-lists-owner at moon.cecer.army.mil Thu Jul 20 11:11:30 1995
> Date: Thu, 20 Jul 95 11:42:28 MDT
> From: kelly at eos.icess.ucsb.edu (Kelly Elder)
> Sender: grass-lists-owner at moon.cecer.army.mil
> Reply-To: grassu-list at moon.cecer.army.mil
> To: grassu-list at max.cecer.army.mil
> Subject: compass bearing from vector
> Cc: kelly at eos.icess.ucsb.edu
> Content-Length: 994
> 
> 
> requesting help for netless friend:
> 
> a colleague has a file of coordinates for start and stop x,y's
> for a number of lines.  she wants a shell script that gives
> her back compass bearings (what i call azimuths) for each pair
> of coordinates.
> 
> given:
> 	x1 y1	X1 Y1
> 	x2 y2	X2 Y2
> 	x3 y3	X3 Y3
> 	-- --   -- --
> 	-- --   -- --
> 	xN yN	XN YN
> 
> she wants:
> 
> 	x1 y1	X1 Y1   12
> 	x2 y2	X2 Y2   272
> 	x3 y3	X3 Y3   315
> 	-- --   -- --   --
> 	-- --   -- --   --
> 	xN yN	XN YN   52
> 
> 
> better yet, would be a mouse program that lets her click on a
> given displayed vector and produces an azimuth for the line
> of choice.
> 
> seems the shell script would be simple to write in awk, but i
> don't have the time.  seems the mouse program would be a pain
> to write and i don't have the ability.  i would guess it has
> already been done, or is part of the military grass modules.
> seems like the bazooka folks would want this capability too.
> 
> please send any possibilities to me at:
> 
> 	kelly at icess.ucsb.edu
> 
> thanks for your time!
> 
> kelly
> 
Kelly:

This may be a starting point with awk:

awk '{printf "%s %.8f \n",$0,(atan2(($4 - $2),($3 - $1))) * 180 /3.1415926535897}' infile >outfile

Regards


Alejandro Hinojosa
Research Associate
Earth Sciences Division
CICESE (Centro de Investigacion Cientifica y Educacion Superior de Ensenada)
Ensenada, Baja California, Mexico.

Mailing address: P.O. Box 434843
                 San Diego Ca. 92143-4843
voice; (01152)6174-4501 to 08 fax:(01152)6174-4933
email: alhinc at cicese.mx  (158.97.1.33)




More information about the grass-user mailing list