Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Draw a star.
Date: Thu, 20 Dec 2007 03:25:30 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 31
Message-ID: <fkcnba$fu1$1@fred.mathworks.com>
References: <ec8smq02a8a@drn.newsguy.com> <ellieandrogerxyzzy-2008061008490001@dialup-4.232.60.187.dial1.losangeles1.level3.net> <fkc8vb$7rg$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1198121130 16321 172.30.248.35 (20 Dec 2007 03:25:30 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 20 Dec 2007 03:25:30 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:443114


"Ionut Plesa" <hartson9@k.ro> wrote in message <fkc8vb$7rg
$1@fred.mathworks.com>...
> ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford)
> wrote in message
> 
<ellieandrogerxyzzy-2008061008490001@dialup-4.232.60.187.dial1.losan
geles1.level3.net>...
> > theta = 0:4/5*pi:4*pi;
> > plot(cos(theta),sin(theta),'y-')
> > axis equal
> > 
> > Roger Stafford
> How can i fill this star with colour? Make it a coloured star.
---------
  Matlab's 'fill' instruction interprets the area inside the star's inner pentagon 
as being outside the fill area, since it is inside "twice", so to speak.  Therefore 
that pentagon area doesn't get filled.  My solution would be to rewrite the 
program so that the polygon doesn't cross itself, something along the lines of 
the fourteen-pointed star method earlier in this thread.  Similarly to that 
problem, fix it so that the polygon alternates repeatedly between the r1 and 
r2 radii as theta increases from 0 to 2*pi.

 theta = 0:2/10*pi:2*pi;
 r1 = 1; r2 = cos(2*pi/5)/cos(pi/5);
 r = (r1+r2)/2 + (r1-r2)/2*(-1).^[0:10];
 x = r.*cos(theta); y = r.*sin(theta);
 fill(x,y,'y')
 axis equal

Roger Stafford