Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!5f968bd6!not-for-mail
From: ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Draw a star.
Message-ID: <ellieandrogerxyzzy-2008062041000001@dialup-4.232.6.13.dial1.losangeles1.level3.net>
References: <ec8smq02a8a@drn.newsguy.com> <ellieandrogerxyzzy-2008061008490001@dialup-4.232.60.187.dial1.losangeles1.level3.net> <ecau8b0197n@drn.newsguy.com>
Organization: -
Lines: 43
Date: Mon, 21 Aug 2006 03:41:00 GMT
NNTP-Posting-Host: 4.232.6.13
X-Complaints-To: abuse@earthlink.net
X-Trace: newsread3.news.pas.earthlink.net 1156131660 4.232.6.13 (Sun, 20 Aug 2006 20:41:00 PDT)
NNTP-Posting-Date: Sun, 20 Aug 2006 20:41:00 PDT
Xref: news.mathworks.com comp.soft-sys.matlab:365604


In article <ecau8b0197n@drn.newsguy.com>, Patrick Flaherty
<Patrick_member@newsguy.com> wrote:

> ....
> However the star there is 14-pointed (not 5).
> ....
----------------------------
  The Malaysian fourteen-pointed star is a bit more of a challenge.

% The rectanglar background
a = 80; b = 60;
x1 = [a,-a,-a,a,a];
y1 = [b,b,-b,-b,b];

% The star
t = (-1/4:1/28:3/4)*2*pi;
r1 = 44; r2 = 19;
r = (r1+r2)/2 + (r1-r2)/2*(-1).^[0:28];
x2 = r.*cos(t);
y2 = r.*sin(t);

% Fill the polygons
fill(x1,y1,'b',x2,y2,'y')
axis equal

Brief description: x1 and y1 trace out a 160 by 120 rectangular polygon. 
The angle t progresses from -pi/2 to +3/2*pi in steps of 2*pi/28 for the
28 line segments of the star, while r alternates between radius 44 and
19.  x2 and y2 have the coordinates of the alternate outer and inner
successive points of the polygon defining the star.  The 'fill' command
first draws a blue rectangle and then superimposes the yellow star.  'axis
equal' ensures that scaling is equal between the x and y axes in the plot.

  My advice to you would be, not to give your nephew the above complete
code, but to describe in broad terms the nature of the steps involved and
let him work out the details: how to generate polygonal points on two
different circles using an angle t and a radius r which alternates between
two fixed radii; then the conversion to cartesian coordinates x =
r.*cos(t) and y = r.*sin(t); and finally how the 'fill' function is used
to fill the interior of polygons with selected colors.  He will learn more
if he has to do some of the work.

Roger Stafford