Create polygon around dot

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create polygon around dot
# 1  
Old 10-21-2013
Create polygon around dot

Dear Masters,

Kindly need your help to solve my issue..
My goal is create a polygon around "dot" (x,y coordinate)

lets say we have some dot as below (these coordinates have meter as unit)

588237.20     5768355.50
588337.90      5768402.50
588459.70      5768436.00
588584.30       5768464.00
588653.80       5768470.50
588679.10       5768465.00

And I want to create polygong around dot which has radius 150 meters.

my logical is
for every dot, if dot has x_ori and y_ori, i have to calculate every 2 degree (0-360 degree) for x_calculated and y_calculated.

polygon1 : x_ori + x_calculated1 , y_ori + y_calculated1
polygon2 : x_ori + x_calculated2 , y_ori + y_calculated2
polygon181 : x_ori + x_calculated181 , y_ori + y_calculated181

x_calculated1 = 150*cos ((0*pi)/180)
x_calculated2 = 150*cos ((2*pi)/180)
x_calculated3 = 150*cos ((4*pi)/180)
x_calculated181 = 150*cos ((360*pi)/180)

y_calculated1 = 150*sin ((0*pi)/180)
y_calculated2 = 150*sin ((2*pi)/180)
y_calculated3 = 150*sin ((4*pi)/180)
y_calculated181 = 150*sin ((360*pi)/180)

pi is 3.14159265359

Thank you for your helps..
Create polygon around dot-sinus_en_cosinuspng
# 2  
Old 10-21-2013
I'd try it in awk:

awk '{ for(N=0; N<360; N+=2) { 
        print "Point "N" is ", $1+15*cos(A), $2+15*sin(A);
} }' inputfile

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 10-21-2013
May I propose to add BEGIN {Pi=4*atan2(1,1)} and then use Pi for optimal precision?
This User Gave Thanks to RudiC For This Post:
# 4  
Old 10-21-2013
$ echo asdf | awk '{ print 4*atan2(1,1); }'

# 5  
Old 10-21-2013
echo asdf | awk '{ printf "%20.20f\n", 4*atan2(1,1); }'

Default output fmt is "%.6g"

---------- Post updated at 23:00 ---------- Previous update was at 22:48 ----------

awk -v OFMT="%.15f" 'BEGIN {Pi=4*atan2(1,1); print sin(Pi); print sin (3.14159)}' 

This User Gave Thanks to RudiC For This Post:
# 6  
Old 10-21-2013
The accuracy difference between the two Pi values equates to about 4 microns over the 150 meter radius.

Since the OP's datafile only goes to mm precision it is probably all moot and 22/7 will do quite nicely,

Last edited by Chubler_XL; 10-21-2013 at 09:16 PM..
These 2 Users Gave Thanks to Chubler_XL For This Post:
# 7  
Old 10-23-2013
thank for your helps Masters...

---------- Post updated at 10:05 PM ---------- Previous update was at 08:01 AM ----------

Hi Masters,

I have tried the script and thank you that is works, Here I need more improvement. I edit a script from Corona688 as below

awk '{ for(N=0; N<=360; N+=2) { A=(2*3.14159*N)/360; printf "circle %20.3f%20.3f\n", $1+150*cos(A), $2+150*sin(A); } }' inputfile

but I need to add numbering at the end of raw (increasing for every input coordinate) as output example below

for 2 input coordinate

767996.759989 88392.0959787
770043.399989 87148.8058945 

And I should get output as below

circle 768146.759  88392.095  1
circle 768146.668  88397.330  1
circle 768146.394  88402.559  1
circle 768145.938  88407.775  1
circle 768145.300  88371.219  1
circle 768145.938  88376.415  1
circle 768146.394  88381.631  1
circle 768146.668  88386.860  1
circle 770193.399  87148.805  2
circle 770193.308  87154.040  2
circle 770193.034  87159.269  2
circle 770192.578  87164.485  2
circle 770192.578  87133.125  2
circle 770193.034  87138.341  2
circle 770193.308  87143.570  2
circle 770193.399  87148.805  2

thanks for your helps,

Last edited by ipatah; 10-23-2013 at 12:18 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mv or cp with a . (dot)?

How can I rename a file with a . prefix? I actually need to copy the file but the . seems to be very tough to do. mv ./bla ../fa/la/.bla - doesn't work. I've tried all sorts of bracketing and that doesn't work. Maybe the only way to do it would be to name the file _.bla then rename it... (19 Replies)
Discussion started by: scribling
19 Replies

2. Shell Programming and Scripting

Remove prefixes before dot

Shell : Bash shell I have a text file with entries like below srv.sr_num sr_number, atvx.ATTRIB_37 Product_Name, ktx.X_ATTRIB_52 Product_Type, mkx.created sr_created_date, nbv.sr_cat_type_cd sr_type, bkrx.sr_area sr_category, .. frx.order_id, des.stats_name , fpxg.current_id_name, ...... .... (3 Replies)
Discussion started by: John K
3 Replies

3. Shell Programming and Scripting

How to Removing a dot from a file name?

I need a script that will allow me to rename all of my files in subdir /FilesIn as follows: From kumc_835_111200.RMT.dat to kumc_835_111200RMT.dat kumc_835_111200.KMR.dat to kumc_835_111200KMR.dat .................etc How do I do that whithout doing a sed ... (10 Replies)
Discussion started by: mrn6430
10 Replies

4. UNIX for Dummies Questions & Answers

How to get data only inside polygon created by points which is part of whole data from file?

hiii, Help me out..i have a huge set of data stored in a file.This file has has 2 columns which is latitude & longitude of a region. Now i have a program which asks for the number of points & based on this number it asks the user to enter that latitude & longitude values which are in the same... (7 Replies)
Discussion started by: reva
7 Replies

5. UNIX for Dummies Questions & Answers

variable name with dot(.)

Hi, Is it possible to declare variable with name having dot(.) in it ? something like gs.test='HELLO' Thanks in advance :) (1 Reply)
Discussion started by: gopalss
1 Replies

6. Shell Programming and Scripting

Replacing dot for comma

I wanted to change 34.66 to 34,66. I tried the command: sed 's/./,/' $NUM Where $NUM is a variable with 34.66 value. The output is ,4.66 (2 Replies)
Discussion started by: bdalmeida
2 Replies

7. Linux

Regarding Dot Matrix Printing

Hi all, What I want is that can we manage printing a text file on a Dot Matrix printer installed on a Linux machine and the printer should not take the normal A4 format, but should print only to the extent the text file has text in it. What happen usually is that when we give print comand to any... (0 Replies)
Discussion started by: aman_mlt
0 Replies

8. Shell Programming and Scripting

splitting on dot in perl

I am trying to split input that looks like ,2005-09-12 01:45:00.000000,2005-09-12 01:48:18.000000, I want to split on the dot . What I am using is ($ev_time,$rol)=split(/\./),$inputfile; This does not recognize the dot as what I want to split on. (2 Replies)
Discussion started by: reggiej
2 Replies

9. Shell Programming and Scripting

dot files

Hi, everyone. I'm now using rsync command, and please tell me what is the wildcard for below looks like. I want to chose dotfiles, such as .ipod .apple but i don't want to chose . and .. ------------------ .* doesn't work, of course. Thanks, Euler04 (2 Replies)
Discussion started by: Euler04
2 Replies
Login or Register to Ask a Question