Points on a circle primitive

Points on a circle primitive
Hi all,

Below is a perl script to take a bunch of angles and convert them to points on the edge of a circle primitve (ie. a 16 or 48 point polygon). The comments up top describe how to use it. It's designed to make generating rims on the bottom of curved parts relatively easy when there's only a few segments required and hand-coding makes more sense than using Philo's wonderful toys.


#! /usr/bin/perl
# ang2point.pl [-r RAD] [-t THICK] [-s SEGS] ang1 ang2 ... angn
# RAD defaults to 20
# THICK defaults to none
# SEGS defaults to 16
# Projects the angles onto a circular primitive of radius RAD
# with SEGS segments. If THICK is specified it also shows the
# points on an inner radius of RAD-THICK
# It scales the radius at each angle to ensure it lies on the
# SEG-sided polygon that approximates the circle.

use POSIX;


for ($ia=0; $ia<=$#ARGV; $ia++) {
    if ($opt eq '-r') {
    } elsif ($opt eq '-t') {
    } elsif ($opt eq '-s') {
    } else {
    push @angs, $opt;

print "0 // ang2point.pl ".join(' ', @ARGV)."\n";
print "0 // Calculating $nang points at outer radius $rad on $segs segments\n";
if ($thick>0) {
    print "0 // Also calculating inner radius $radp\n";


foreach $ang (@angs) {
    #print "$a0 + $ar\n";



    #print "Effective radius $reff\n";
    push @reffs, $reff;
    push @rieffs, $rieff;

foreach $ia (0..$#angs) {
    push @pts, sprintf("0 // Point %2d: %.3f 0 %.3f\n",
               $ia+1, $x, $z);
    if ($thick>0) {
    push @ipts, sprintf("0 // Inner point %2d: %.3f 0 %.3f\n",
                $ia+1, $x, $z);

print @pts;
print @ipts;
« Next Oldest | Next Newest »

Messages In This Thread
Points on a circle primitive - by Tim Gould - 2012-01-08, 21:51

Forum Jump:

Users browsing this thread: 1 Guest(s)