LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-16-2010, 10:53 AM   #16
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62

It seems, that there is something wrong with the minmax.awk. Can you post hpgl.plt? For the plt-files posted above, minmax.awk works.
 
1 members found this post helpful.
Old 02-16-2010, 11:37 AM   #17
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
In my original post

In my original post there are two files one LL origin and one center origin of the same simple drawing. Can you use the LL as your sample.
I'm not sure if we understand each other. I don't think I need anything changed except the coordinate values from a LL plt file to a center plot file resulting in some coordinate values being neg. numbers if ploted to the left of 0,0.
The LL plt can't have neg numbers because 0,0 is the machines limits in that quadrant but a center origin plot can move neg. coordinates because it can move half the page towards LL before it reaches the machines limits.

I included the hpgl.plt file just in case.
Attached Files
File Type: txt hpgl.plt.txt (3.9 KB, 8 views)
 
Old 02-16-2010, 11:46 AM   #18
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
bounding box

I was thinking what about grabbing the bounding box values (72/inch) and divide by half gives you page center doing the math to relate bounding box to plotter units (1016 /inch) then comparing x and y values if they are less than the converted bounding box value they are assigned a negative?? Something like that or is that even possible? I don't know if that will work or not?
 
Old 02-16-2010, 11:57 AM   #19
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
in addition

Also after determining if it gets an negative or positive signature it can be subtracted from half the bounding box value which would then place it in the right position in the neg values (LL quadrant)

eg: say you had a value in LL .plot file of x=10 y=250
the corresponding value in center origin .plot should be if 10 less that (boundingbox plus all the math) then (boundingbox plus all the math) minus 10 should give equivalent value in neg. value for that position on a center origin machine.
 
Old 02-16-2010, 12:30 PM   #20
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
There was a little error in the pattern matching in the awk-scripts.

Use the same command as before. Maybe I should explain how the scripts work:
The minmax script will try to find the lower left and upper right corner of the drawing (by looking only at PU/PD commands and find extremal values of the coordinates). Then these values will be given as parameters to the conv script.
This script will do the following: each command is read. If it is a PD or PU command, then the coordinates are moved by (x,y) -= ((maxx+minx)/2,(maxy+miny)/2) and written out. This will for sure generate negative coordinate values. The conversion's math is basic high school mathematics.
Attached Files
File Type: txt conv.awk.txt (293 Bytes, 11 views)
File Type: txt minmax.awk.txt (424 Bytes, 12 views)
 
Old 02-16-2010, 12:44 PM   #21
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
testing

I'm going to run this through my plotter to test but can't figure where in the awk scripts to delete the ";" at the first of each line in the attached output.plt file
Attached Files
File Type: txt output.plt.txt (2.0 KB, 12 views)
 
Old 02-16-2010, 12:54 PM   #22
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
Now this issue should be fixed.
Attached Files
File Type: txt conv.awk.txt (322 Bytes, 7 views)
File Type: txt minmax.awk.txt (426 Bytes, 10 views)
 
Old 02-16-2010, 01:12 PM   #23
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
files are same

Looks like no negative numbers again?
Graphic2.plt is the LL origin file to be converted the result is output.plt and here is the command I used

awk -f <(echo "BEGIN { "; awk -f minmax.awk Graphic2.plt; echo "}"; cat conv.awk) Graphic2.plt > output
Attached Files
File Type: txt output.plt.txt (3.3 KB, 11 views)
File Type: txt Graphic2.plt.txt (3.5 KB, 14 views)
File Type: txt Graphic2.ps.txt (20.3 KB, 13 views)
 
Old 02-16-2010, 01:18 PM   #24
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
output

This is what the exact same file should look like after conversion
Attached Files
File Type: txt Graphic3.plt.txt (3.2 KB, 9 views)
 
Old 02-16-2010, 01:33 PM   #25
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
If I run the command on your source file, the output file has negative values.
Attached Files
File Type: txt out.plt.txt (3.0 KB, 9 views)
 
Old 02-16-2010, 01:59 PM   #26
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
ran test

I ran the out.plt file you posted on the plotter and it works! The scale is right on but skewed towards the lower left corner by about 3/4 inch no biggie but I just can't get to generate the proper file with neg. values take a look at my command again. I made sure I re-downloaded the last minmax and conv.awk files. Did you make any more changes to them since the last time you posted them?

awk -f <(echo "BEGIN { "; awk -f minmax.awk Graphic2.plt; echo "}"; cat conv.awk) Graphic2.plt > roland.plt

Graphic2.plt is the LL origin plot file like I sent you
 
Old 02-16-2010, 02:15 PM   #27
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
No I did not change anything in the scripts. What awk are you using? "awk --version" or "awk -v". I'm using GNU awk version 3.1.6 and the shell is bash.

The command is exactly the same as I used. Maybe you are using a different version of awk?
It seems, that your version of awk does not recognize the regular expression I use to match the PD and PU commands.

If you want to move the whole plot by a constant make the following change to conv.awk:
Code:
    newx = x - (maxx+minx)/2;
    newy = y - (maxy+miny)/2;
to

Code:
    newx = x - (maxx+minx)/2 + 0.75 * 1016;
    newy = y - (maxy+miny)/2;
Now I know, why your centered files are moved a little bit to the right. If you change this lines here, you can also rotate or resize your plot. Or do any transformation you want on it.

Last edited by irmin; 02-16-2010 at 02:20 PM.
 
Old 02-16-2010, 02:34 PM   #28
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
/bin/sh

Running in a /bin/sh script
and I tried everything I could to get a damxxx version! I get reference to mawk and no version but it's ubuntu 9.10 if thats any help.
I got rid of the ( ) brackets and the syntax error is gone but I get all positive #'s but the /bin/sh script reports

./hpgl.sh: 83: cannot open echo: No such file
minx=200000
maxx=-200000
miny=200000
maxy=-200000
}


here is my command

awk -f < echo "BEGIN { "; awk -f $HOME/.hpgl/minmax.awk $HOME/hpgl-hot-folder/temp.plot; echo "}"; cat $HOME/.hpgl/conv.awk $HOME/hpgl-hot-folder/temp.plot > $HOME/hpgl-hot-folder/temp-conv.plot
 
Old 02-16-2010, 02:42 PM   #29
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
The syntax <(...) is a bash extension. Either you specify bash as the script processor or replace the command with:
Code:
(echo "BEGIN { "; awk -f minmax.awk Graphic2.plt; echo "}"; cat conv.awk) > /tmp/script-$$
awk -f /tmp/script-$$ Graphic2.plt > roland.plt
rm -f /tmp/script-$$
 
Old 02-16-2010, 03:43 PM   #30
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
almost

I tried it both from my shel script and in a bash terminal window with no errors on either but still no neg. numbers maybe it is something to do with my awk?

Also substituted mawk for awk same results...
Installed original-awk failed with an empty file

Hey guess what installed gawk and that did the trick!!!
only from a bash terminal window not from my shell script
processed file looks like

PU;
SP1;
PU5089,19855;PD6615,19855;PD6621,19855;PD6627,19853;PD6633,19850;PD6637,19846;PD6641,19841;PD6644,19 836;PD6646,19830;PD6647,19823;PD6647,17564;PD6646,17557;PD6644,17551;PD6641,17546;PD6637,17541;PD663 3,17537;PD6627,17534;PD6621,17532;PD6615,17532;PD5089,17532;PD5082,17532;PD5076,17534;PD5071,17537;P D5066,17541;PD5062,17546;PD5060,17551;PD5058,17557;PD5057,17564;PD5057,19823;PD5058,19830;PD5060,198 36;PD5062,19841;PD5066,19846;PD5071,19850;PD5076,19853;PD5082,19855;PD5089,19855;
PU3341,21200;PD12928,21200;PD12949,21199;PD12968,21196;PD12988,21191;PD13006,21185;PD13023,21176;PD1 3040,21166;PD13055,21155;PD13069,21142;PD13082,21128;PD13094,21112;PD13104,21096;PD13112,21078;PD131 19,21060;PD13124,21041;PD13127,21021;PD13128,21001;PD13128,9212;PD13127,9192;PD13124,9172;PD13119,91 53;PD13112,9134;PD13104,9117;PD13094,9101;PD13082,9085;PD13069,9071;PD13055,9058;PD13040,9047;PD1302 3,9036;PD13006,9028;PD12988,9021;PD12968,9016;PD12949,9013;PD12928,9012;PD3341,9012;PD3321,9013;PD33 01,9016;PD3282,9021;PD3263,9028;PD3246,9036;PD3229,9047;PD3214,9058;PD3200,9071;PD3187,9085;PD3175,9 101;PD3165,9117;PD3157,9134;PD3150,9153;PD3145,9172;PD3142,9192;PD3141,9212;PD3141,21001;PD3142,2102 1;PD3145,21041;PD3150,21060;PD3157,21078;PD3165,21096;PD3175,21112;PD3187,21128;PD3200,21142;PD3214, 21155;PD3229,21166;PD3246,21176;PD3263,21185;PD3282,21191;PD3301,21196;PD3321,21199;PD3341,21200;
PU7973,15860;PD14900,15860;PD14914,15860;PD14929,15858;PD14942,15854;PD14956,15849;PD14968,15843;PD1 4980,15836;PD14991,15827;PD15002,15818;PD15011,15808;PD15019,15797;PD15027,15785;PD15033,15772;PD150 37,15759;PD15041,15745;PD15043,15731;PD15044,15716;PD15044,5855;PD15043,5840;PD15041,5826;PD15037,58 12;PD15033,5799;PD15027,5786;PD15019,5774;PD15011,5763;PD15002,5753;PD14991,5744;PD14980,5735;PD1496 8,5728;PD14956,5722;PD14942,5717;PD14929,5713;PD14914,5711;PD14900,5710;PD7973,5710;PD7958,5711;PD79 44,5713;PD7930,5717;PD7917,5722;PD7905,5728;PD7893,5735;PD7882,5744;PD7871,5753;PD7862,5763;PD7854,5 774;PD7846,5786;PD7840,5799;PD7835,5812;PD7832,5826;PD7830,5840;PD7829,5855;PD7829,15716;PD7830,1573 1;PD7832,15745;PD7835,15759;PD7840,15772;PD7846,15785;PD7854,15797;PD7862,15808;PD7871,15818;PD7882, 15827;PD7893,15836;PD7905,15843;PD7917,15849;PD7930,15854;PD7944,15858;PD7958,15860;PD7973,15860;
PU8958,16880;PD9046,16876;PD9132,16867;PD9217,16851;PD9300,16829;PD9382,16800;PD9463,16767;PD9542,16 727;PD9619,16682;PD9694,16632;PD9768,16576;PD9839,16516;PD9908,16450;PD9974,16380;PD10039,16306;PD10 100,16227;PD10160,16144;PD10216,16057;PD10269,15966;PD10320,15871;PD10367,15773;PD10412,15671;PD1045 3,15566;PD10490,15458;PD10524,15347;PD10555,15233;PD10582,15117;PD10605,14998;PD10624,14877;PD10639, 14754;PD10650,14628;PD10656,14501;PD10658,14373;PD10656,14244;PD10650,14117;PD10639,13992;PD10624,13 868;PD10605,13747;PD10582,13629;PD10555,13512;PD10524,13398;PD10490,13287;PD10453,13179;PD10412,1307 4;PD10367,12973;PD10320,12874;PD10269,12780;PD10216,12689;PD10160,12601;PD10100,12518;PD10039,12439; PD9974,12365;PD9908,12295;PD9839,12230;PD9768,12169;PD9694,12114;PD9619,12063;PD9542,12018;PD9463,11 979;PD9382,11945;PD9300,11917;PD9217,11895;PD9132,11879;PD9046,11869;PD8958,11866;PD8871,11869;PD878 5,11879;PD8700,11895;PD8616,11917;PD8534,11945;PD8454,11979;PD8375,12018;PD8298,12063;PD8222,12114;P D8149,12169;PD8078,12230;PD8009,12295;PD7942,12365;PD7878,12439;PD7816,12518;PD7757,12601;PD7701,126 89;PD7647,12780;PD7597,12874;PD7549,12973;PD7505,13074;PD7464,13179;PD7426,13287;PD7392,13398;PD7362 ,13512;PD7335,13629;PD7312,13747;PD7293,13868;PD7278,13992;PD7267,14117;PD7260,14244;PD7258,14373;PD 7260,14501;PD7267,14628;PD7278,14754;PD7293,14877;PD7312,14998;PD7335,15117;PD7362,15233;PD7392,1534 7;PD7426,15458;PD7464,15566;PD7505,15671;PD7549,15773;PD7597,15871;PD7647,15966;PD7701,16057;PD7757, 16144;PD7816,16227;PD7878,16306;PD7942,16380;PD8009,16450;PD8078,16516;PD8149,16576;PD8222,16632;PD8 298,16682;PD8375,16727;PD8454,16767;PD8534,16800;PD8616,16829;PD8700,16851;PD8785,16867;PD8871,16876 ;PD8958,16880;
PU;
PU;PU;PU0,0;


instead of the new lines in a proper processed file from a bash terminal

IN;
SP1;
LT;
PU-169,-2012;
PD-58,-2008;
PD49,-1995;
PD157,-1975;
PD263,-1947;
PD366,-1911;
PD468,-1869;
PD567,-1819;
PD665,-1762;
PD761,-1698;
PD853,-1628;
PD943,-1551;
PD1031,-1468;
PD1115,-1380;
PD1196,-1285;
PD1275,-1186;
PD1349,-1080;
PD1420,-970;
PD1488,-855;
PD1552,-735;
PD1612,-611;
PD1668,-482;
PD1721,-349;
PD1767,-212;
PD1811,-72;
PD1850,71;
PD1883,218;
PD1913,369;
PD1937,522;
PD1955,679;
PD1970,837;
PD1978,998;
PD1981,1160;
PD1978,1323;
PD1970,1484;
PD1955,1643;
PD1937,1798;
PD1913,1952;
PD1883,2102;
PD1850,2249;
PD1811,2394;
PD1767,2534;
PD1721,2670;
PD1668,2803;
PD1612,2932;
PD1552,3056

if thats any help

it must be an env. bash/sh
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do simple math in shell script gidrow Programming 5 07-30-2009 03:46 PM
csh Shell Script: Getting wc command output to variable to do math on it, how? vxc69 Programming 5 05-04-2009 04:31 PM
improve math calculation... java os2 Programming 1 10-21-2004 06:17 PM
putting a math calculation in a cron job the_rhino Linux - Newbie 3 10-11-2004 01:46 PM
c math calculation alaios Programming 3 06-01-2004 01:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration