OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
PlanarArcGeometry.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: PlanarArcGeometry.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: PlanarArcGeometry
10 // Defines a Geometry which is a simple arc in the XZ plane.
11 //
12 // ------------------------------------------------------------------------
13 // Class category: BeamlineGeometry
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:32:34 $
17 // $Author: fci $
18 //
19 // ------------------------------------------------------------------------
20 
23 #include <cmath>
24 
25 
26 // File scope function for calculating general transformations around arcs.
27 namespace {
28  Euclid3D ArcTransform(double l, double h) {
29  Euclid3D t;
30 
31  if(h) {
32  double phi = h * l;
33  t = Euclid3D::YRotation(- phi);
34  t.setX((cos(phi) - 1.0) / h);
35  t.setZ(sin(phi) / h);
36  } else {
37  t.setZ(l);
38  }
39 
40  return t;
41  }
42 }
43 
44 
46 {}
47 
48 
50  return len;
51 }
52 
53 
55  return len;
56 }
57 
58 
60  return h;
61 }
62 
63 
65  return angle;
66 }
67 
68 
70  angle = phi;
71  if(len != 0.0) h = angle / len;
72 }
73 
74 
76  if(len != 0.0) {
77  h = hh;
78  angle = h * len;
79  }
80 }
81 
82 
84  len = l;
85  if(len != 0.0) angle = h * len;
86 }
87 
88 
90  return len / 2.0;
91 }
92 
93 
95  return - len / 2.0;
96 }
97 
98 
100  return len / 2.0;
101 }
102 
103 
104 Euclid3D PlanarArcGeometry::getTransform(double fromS, double toS) const {
105  return ArcTransform(toS - fromS, h);
106 }
107 
108 
110  return ArcTransform(len, h);
111 }
112 
113 
115  return ArcTransform(s, h);
116 }
117 
118 
120  return ArcTransform(- len / 2.0, h);
121 }
122 
123 
125  return ArcTransform(len / 2.0, h);
126 }
virtual double getArcLength() const
Get arc length.
virtual double getOrigin() const
Get origin.
virtual void setBendAngle(double)
Set angle.
void setCurvature(double)
Set curvature.
Tps< T > sin(const Tps< T > &x)
Sine.
Definition: TpsMath.h:111
double getExit() const
Get exit.
static Euclid3D YRotation(double angle)
Make rotation.
Definition: Euclid3D.cpp:164
double getBendAngle() const
Get angle.
virtual Euclid3D getTransform(double fromS, double toS) const
Get transform.
virtual Euclid3D getTotalTransform() const
Get transform.
Displacement and rotation in space.
Definition: Euclid3D.h:68
void setZ(double z)
Set displacement.
Definition: Euclid3D.cpp:79
void setX(double x)
Set displacement.
Definition: Euclid3D.cpp:69
virtual double getElementLength() const
Get element length.
Tps< T > cos(const Tps< T > &x)
Cosine.
Definition: TpsMath.h:129
double getCurvature() const
Get curvature.
Euclid3D getExitFrame() const
Get transform.
double getEntrance() const
Get entrance.
Euclid3D getEntranceFrame() const
Get transform.
virtual void setElementLength(double)
Set length.