Re: Re: How to draw circle

From: Olivier Couet <couet_at_mail.cern.ch>
Date: Tue, 18 Jan 2005 14:28:46 +0100 (CET)

Here we go:

{

   c1 = new TCanvas("c1");

   Double_t w = gPad->GetWw()*gPad->GetAbsWNDC();  
   Double_t h = gPad->GetWh()*gPad->GetAbsHNDC();  
   Double_t xmin = -150;
   Double_t xmax =  150;
   Double_t ymin = -150;
   Double_t ymax = ((xmax-xmin)*h/w)-150;
   c1->SetFixedAspectRatio();
   c1->Range(xmin,ymin,xmax,ymax);
   TEllipse el1(0.,0.,100.,100.);
   el1.Draw();
}

Cheers, Olivier

On Tue, 18 Jan 2005, Manoj Kumar Jha wrote:

> Hi Rene,
> I have one more question. The following script is valid when the
> coordinates of the canvas are positive. For example
>
> xmin = 0.;
> ymin = 0.;
> xmax = 2.;
> ymax = xmax*h/w;
>
> It would be nice if I can plot the circle for the following case also
> xmin = -150.;
> ymin = -150.;
> xmax = 150.;
>
> TEllipse e1(0.,0.,100.,100.);
> e1.Draw();
>
> In this case, value of ymax will be changed. I have taken
> ymax = xmax*(h-xmin)/(w+ymin)
>
> I am getting ellipse. Could you please help me in this case ?
>
> Thanks and with regards,
> manoj
>
>
>
>
> On Tue, 2005-01-11 at 21:55, Rene Brun wrote:
> > see your example modified below
> >
> > Rene Brun
> >
> >
> > {
> > gROOT->Reset();
> > c1 = new TCanvas("c1");
> > //compute the pad range to get a fix aspect ratio
> > Double_t w = gPad->GetWw()*gPad->GetAbsWNDC();
> > Double_t h = gPad->GetWh()*gPad->GetAbsHNDC();
> > Double_t xmin = 0;
> > Double_t xmax = 2;
> > Double_t ymin = 0;
> > Double_t ymax = xmax*h/w;
> > c1->SetFixedAspectRatio();
> > c1->Range(xmin,ymin,xmax,ymax);
> > TPaveLabel pel(0.1,0.8,0.9,0.95,"Examples of Circle");
> > pel.SetFillColor(42);
> > pel.Draw();
> > TEllipse el1(0.5,0.5,.2,.2);
> > el1.Draw();
> > }
> >
> > Manoj Kumar Jha wrote:
> > >
> > > Dear rooters,
> > > I am trying to draw a circle using the attached script. But, I am
> > > getting an ellipse (the figure is attached). Could you please let me
> > > know where I am committing the mistake ?
> > >
> > > Thanks,
> > > manoj
> > > --
> > > ***************************************************
> > > Manoj Kumar Jha
> > > Research Scholar
> > > Department of Physics & Astrophysics
> > > University of Delhi | Delhi - 110 007 | India
> > > Phone : 91-11-27667036(O)
> > > E-mail: Manoj.Jha_at_cern.ch
> > > ***************************************************
> > >
> > > --------------------------------------------------------------------------------
> > > Name: try.C
> > > try.C Type: text/x-c++
> > > Encoding: 7bit
> > >
> > > Name: figure.ps
> > > figure.ps Type: Postscript Document (application/postscript)
> > > Encoding: 7bit
>

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet_at_cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7670300
Received on Tue Jan 18 2005 - 14:28:52 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:04 MET