Re: TView::WCtoNDC

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Mon Sep 27 1999 - 22:14:37 MEST


 Hello Dmitri,

  Could you supply the full text of your version of TView class
  Especially I'd like to see how you fill :

      Float_t         fTnorm[12];        // Transformation matrix
      Float_t         fTback[12];         // Back transformation matrix

>From my point of view to do what you want you should not touch
WCtoNDC class rather introduce a special method to re-define fTnorm
matrix

This matrix is defined by 

void TView::ResetView(Float_t longitude, Float_t latitude, Float_t psi, Int_t &irep)

method via "FindScope" as follows:
{
    irep = 0;
    Float_t sqrt3 = 0.5*TMath::Sqrt(3.0);
 
    for (Int_t i = 0; i < 3; i++) {
        if (fRmin[i] >= fRmax[i]) { irep = -1; return;}
                scale[i]  = sqrt3*(fRmax[i] - fRmin[i]);
                center[i] = 0.5*(fRmax[i] + fRmin[i]);
    }
}

>From the code above it is clear the SECOND transformation you introduced
within your version of ONLY method of TView doesn't match the PRIMARY
transfromation the rest methods of your class use.

 Apparently the factor:

root [3] 1.0/(0.5*sqrt(3)) 
(double)1.15470053837925170e+000

I think sqrt3 was chosen to make sure all verteces of the cube
(fRmax[i] - fRmin[i]) (in other words the cube diagonal) 
are visible with either rotation angle.

 Myself see no reason for a new class.

  May be one should contribute  a new method (approach)

        TView::WCtoDC and avoid 
        gPad->Range(-1, -1, 1, 1);


  Hope this helps,
                            Valery


> 
> Hi Rooters, 
> 
> I've noticed that TView's ctor resets range of TPad 
> to (-1,-1,1,1). I didn't quite like it and created MyView, 
> which inherits from TView and does not reset TPad's range. 
> To draw various 3D primitives I need to override TView::WCtoNDC
> method like this:
> 
> xn[0] *= fPadX2-fPadX1; xn[0] += 0.5*(fPadX2+fPadX1);
> xn[1] *= fPadY2-fPadY1; xn[1] += 0.5*(fPadY2+fPadY1);
> 
> works fine, but... 
> 
> suppose I draw TSPHE with radius 100 and centered at (0,0,0)
> (TPad range is set properly, i.g. like (-200,-200,200,200))
> so I invoke something like this:
> {
> to my surprise visible radius of Sphere is less then 100. (ellipse and 
> sphere don't coinside) 
> there is some 'coefficient' approximately 1.16, which being used like this
> in MyView::WCtNDC:
> 
> xn[0] *= (fPadX2-fPadX1)/1.16; xn[0] += 0.5*(fPadX2+fPadX1);
> xn[1] *= (fPadY2-fPadY1)/1.16; xn[1] += 0.5*(fPadY2+fPadY1);
> 
> gives more satisfactory result.
> Could you please hint me where this number comes from? May be I'd
> be able to get exact number (not use the result of my 'measurement')



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:40 MET