Short few bits of code to bash out a sculptie from a 127x256 Gimp-made PGM (greyscale plain pixmap, not raw!). The plain PGM was made with the first and last rows completely white, and what I needed to rotate around the Z axis in black. The one-liner extracts the radii, the following script generates a plain PPM that takes those radii and rotates it around the Z axis, stepping through every 1.4 degrees (roughly).
tail -n +5 Sculptie.pgm | perl -nle 'BEGIN{$l=$c=0;} $c++ unless($_);
+if(++$l==127){$l=0;print $c; $c=0;}' > Sculptie.zr
#!/usr/bin/perl
# Use: rot.pl < Sculptie.zr > Sculptie.ppm
#4 * atan2 1, 1;
my $step= 4*atan2(1,1)/128;
my $i=0;
my $a=$step*255;
my @r,$j,$k,$z,$zi;
while(<>) {
chomp;
$r[$i++]=$_;
}
$z=$i;
$z--;
print "P3\n256 256 255\n";
for($j=$z;$j>-1;$j--) {
$a=$step*255;
for($i=0;$i<256;$i++) {
my $x=127+int($r[$j]*cos($a));
my $y=127+int($r[$j]*sin($a));
print "$x $y $j\n";
$a-=$step;
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.