source: trunk/source/geometry/solids/BREPS/src/G4Parabola.cc @ 1337

Last change on this file since 1337 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 5.0 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4Parabola.cc,v 1.9 2007/05/18 07:33:31 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30// ----------------------------------------------------------------------
31// GEANT 4 class source file
32//
33// G4Parabola.cc
34//
35// ----------------------------------------------------------------------
36
37#include "G4Parabola.hh"
38#include "G4CurvePoint.hh"
39#include "G4GeometryTolerance.hh"
40
41G4Parabola::G4Parabola(){}
42G4Parabola::~G4Parabola(){}
43
44G4Parabola::G4Parabola(const G4Parabola& right)
45  : G4Conic(), focalDist(right.focalDist), F(right.F), L0(right.L0)
46{
47  pShift    = right.pShift;
48  position  = right.position;
49  bBox      = right.bBox;
50  start     = right.start;
51  end       = right.end;
52  pStart    = right.pStart;
53  pEnd      = right.pEnd;
54  pRange    = right.pRange;
55  bounded   = right.bounded;
56  sameSense = right.sameSense;
57}
58
59G4Parabola& G4Parabola::operator=(const G4Parabola& right)
60{
61  if (&right == this) return *this;
62
63  F  = right.F;
64  L0 = right.L0;
65  focalDist = right.focalDist;
66  pShift    = right.pShift;
67  position  = right.position;
68  bBox      = right.bBox;
69  start     = right.start;
70  end       = right.end;
71  pStart    = right.pStart;
72  pEnd      = right.pEnd;
73  pRange    = right.pRange;
74  bounded   = right.bounded;
75  sameSense = right.sameSense;
76
77  return *this;
78}
79
80G4Curve* G4Parabola::Project(const G4Transform3D& tr)
81{
82  G4double axisZ= (tr*position.GetPZ()).unit().z();
83
84  if (std::abs(axisZ)<G4GeometryTolerance::GetInstance()->GetAngularTolerance()) 
85    { return 0; }
86 
87 
88  G4Vector3D newAxis(0, 0, axisZ>0? +1: -1);
89
90  G4Vector3D xPrime= tr*position.GetPX();
91  xPrime.setZ(0);
92  G4Vector3D yPrime= tr*position.GetPY();
93  yPrime.setZ(0);
94  G4double u= -(xPrime*yPrime)/xPrime.mag2();
95
96  G4Point3D newLocation= G4Point3D( tr*position.GetLocation()+
97                                    focalDist*(u*u*xPrime+2*u*yPrime) );
98  newLocation.setZ(0);
99  G4Vector3D newRefDirection= xPrime;
100  G4double newFocalDist= (focalDist*((2*u+1)*xPrime+2*yPrime)).mag()/std::sqrt(5.);
101                         
102  // create the new parabola
103  G4Axis2Placement3D newPosition;
104  newPosition.Init(newRefDirection, newAxis, newLocation);
105  G4Parabola* r= new G4Parabola;
106  r->Init(newPosition, newFocalDist);
107
108  // introduce the shift in the parametrization
109  // maybe the Sign must be changed?
110  r->SetPShift(u);
111
112  // set the bounds when necessary
113  if (IsBounded()) 
114    r->SetBounds(GetPStart(), GetPEnd());
115 
116  return r;
117}
118
119
120void G4Parabola::InitBounded()
121{
122  // the bbox must include the start and endpoints as well as the
123  // extreme points if they lie on the curve
124  bBox.Init(GetStart(), GetEnd());
125
126  // the parameter values
127  // belonging to the points with an extreme x, y and z coordinate
128  for (G4int i=0; i<3; i++) 
129  {
130    G4double x_i= position.GetPX()(i);
131   
132    if (std::abs(x_i) <= 
133        G4GeometryTolerance::GetInstance()->GetAngularTolerance()) 
134    {
135      G4double u= - position.GetPY()(i) / x_i;
136      if (IsPOn(u)) 
137        bBox.Extend(GetPoint(u));
138    }
139  }
140}
141
142
143G4bool G4Parabola::Tangent(G4CurvePoint& cp, G4Vector3D& v)
144{
145  // The tangent is computed from the 3D point representation
146  // for all conics. An alternaive implementation (based on
147  // the parametric point) might be worthwhile adding
148  // for efficiency.
149 
150  const G4Axis2Placement3D& pos= *(GetPosition());
151  G4Point3D p= pos.GetToPlacementCoordinates() * cp.GetPoint();
152
153  v= p.y()*pos.GetPX() + (2*focalDist)*pos.GetPY();
154  return true;
155}
Note: See TracBrowser for help on using the repository browser.