[R] How to do rotation for polygon?

William Dunlap wdunlap at tibco.com
Thu Sep 10 18:18:54 CEST 2009


Try representing the pentagon as a set of complex
numbers.  Translate them by adding a complex
number and multiply by exp(1i*angle) to rotate them
around the origin.  E.g. to rotate them around their
center of gravity, mean(p), do

> p<-complex(real=c(4,5,7,8,6), imag=c(5,3,3,5,7))
> plot(p, xlim=c(0,10), ylim=c(0,10), type="n")
> for(k in 0:10)polygon(border=k, lwd=k+1,
(p-mean(p))*exp(k*1i/10*pi)+mean(p))

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Hemavathi Ramulu
> Sent: Thursday, September 10, 2009 1:44 AM
> To: Greg Snow
> Cc: r-help at r-project.org
> Subject: Re: [R] How to do rotation for polygon?
> 
> Hi everyone,
> I still couldn't get the diagram as I mentioned before. I try Grey and
> Milton suggestion but
> it confusing.
> I hope anyone helped me.
> 
> Thanks in advance.
> 
> Regards,
> Hema.
> 
> On Thu, Sep 3, 2009 at 11:39 PM, Greg Snow 
> <Greg.Snow at imail.org> wrote:
> 
> > The my.symbols and ms.polygon functions in the 
> TeachingDemos package may
> > help.
> >
> > --
> > Gregory (Greg) L. Snow Ph.D.
> > Statistical Data Center
> > Intermountain Healthcare
> > greg.snow at imail.org
> > 801.408.8111
> >
> >
> > > -----Original Message-----
> > > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> > > project.org] On Behalf Of Hemavathi Ramulu
> > > Sent: Wednesday, September 02, 2009 11:05 PM
> > > To: r-help at r-project.org
> > > Subject: [R] How to do rotation for polygon?
> > >
> > > Hi everyone,
> > > I have coding for repeating pentagon as below:
> > >
> > > plot(0:11,type="n")
> > > for (i in 1:10 )polygon(rep(c(4,5,7,8,6)), 
> i*c(.5,.3,.3,.5,.7), bor=2)
> > >
> > > which are increasing vertically.
> > >
> > > Now, I want to know how to rotate the pentagon, so that I will get
> > > pattern
> > > like flower.
> > > Basicly, repeating pentagon in circle.
> > >
> > > Thanks alot for helping me to solve this problem.
> > > --
> > > Hemavathi
> > >
> > >       [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help at r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide http://www.R-project.org/posting-
> > > guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> -- 
> Hemavathi Ramulu
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 




More information about the R-help mailing list