OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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 
24 
25 #include <cmath>
26 #include <algorithm>
27 
28 // File scope function for calculating general transformations around arcs.
29 namespace {
30  Euclid3D ArcTransform(double l, double h) {
31  Euclid3D t;
32 
33  if(h) {
34  double phi = h * l;
35  t = Euclid3D::YRotation(- phi);
36  t.setX((cos(phi) - 1.0) / h);
37  t.setZ(sin(phi) / h);
38  } else {
39  t.setZ(l);
40  }
41 
42  return t;
43  }
44 }
45 
46 
48 {}
49 
50 
52  return len;
53 }
54 
55 
57  return len;
58 }
59 
60 
62  return h;
63 }
64 
65 
67  return angle;
68 }
69 
70 
72  angle = phi;
73  if(len != 0.0) h = angle / len;
74 }
75 
76 
78  if(len != 0.0) {
79  h = hh;
80  angle = h * len;
81  }
82 }
83 
84 
86  if (l < 0.0) {
87  throw GeneralClassicException("PlanarArcGeometry::setElementLength",
88  "The length of an element has to be positive");
89  }
90  len = l;
91  if(len != 0.0) angle = h * len;
92 }
93 
94 
96  return len / 2.0;
97 }
98 
99 
101  return - len / 2.0;
102 }
103 
104 
106  return len / 2.0;
107 }
108 
109 
110 Euclid3D PlanarArcGeometry::getTransform(double fromS, double toS) const {
111  return ArcTransform(toS - fromS, h);
112 }
113 
114 
116  return ArcTransform(len, h);
117 }
118 
119 
121  return ArcTransform(s, h);
122 }
123 
124 
126  return ArcTransform(- len / 2.0, h);
127 }
128 
129 
131  return ArcTransform(len / 2.0, h);
132 }
Tps< T > cos(const Tps< T > &x)
Cosine.
Definition: TpsMath.h:129
Tps< T > sin(const Tps< T > &x)
Sine.
Definition: TpsMath.h:111
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
static Euclid3D YRotation(double angle)
Make rotation.
Definition: Euclid3D.cpp:164
double getExit() const
Get exit.
Euclid3D getEntranceFrame() const
Get transform.
double getCurvature() const
Get curvature.
void setCurvature(double)
Set curvature.
double getBendAngle() const
Get angle.
virtual double getOrigin() const
Get origin.
virtual double getArcLength() const
Get arc length.
virtual void setElementLength(double)
Set length.
virtual void setBendAngle(double)
Set angle.
Euclid3D getExitFrame() const
Get transform.
double getEntrance() const
Get entrance.
virtual double getElementLength() const
Get element length.
virtual Euclid3D getTransform(double fromS, double toS) const
Get transform.
virtual Euclid3D getTotalTransform() const
Get transform.