OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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 <algorithm>
26#include <cmath>
27
28// File scope function for calculating general transformations around arcs.
29namespace {
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} // namespace
45
47
48double PlanarArcGeometry::getArcLength() const { return len; }
49
50double PlanarArcGeometry::getElementLength() const { return len; }
51
52double PlanarArcGeometry::getCurvature() const { return h; }
53
54double PlanarArcGeometry::getBendAngle() const { return angle; }
55
57 angle = phi;
58 if (len != 0.0) h = angle / len;
59}
60
62 if (len != 0.0) {
63 h = hh;
64 angle = h * len;
65 }
66}
67
69 if (l < 0.0) {
71 "PlanarArcGeometry::setElementLength",
72 "The length of an element has to be positive");
73 }
74 len = l;
75 if (len != 0.0) angle = h * len;
76}
77
78double PlanarArcGeometry::getOrigin() const { return len / 2.0; }
79
80double PlanarArcGeometry::getEntrance() const { return -len / 2.0; }
81
82double PlanarArcGeometry::getExit() const { return len / 2.0; }
83
84Euclid3D PlanarArcGeometry::getTransform(double fromS, double toS) const {
85 return ArcTransform(toS - fromS, h);
86}
87
88Euclid3D PlanarArcGeometry::getTotalTransform() const { return ArcTransform(len, h); }
89
90Euclid3D PlanarArcGeometry::getTransform(double s) const { return ArcTransform(s, h); }
91
92Euclid3D PlanarArcGeometry::getEntranceFrame() const { return ArcTransform(-len / 2.0, h); }
93
94Euclid3D PlanarArcGeometry::getExitFrame() const { return ArcTransform(len / 2.0, h); }
Displacement and rotation in space.
Definition Euclid3D.h:67
void setZ(double z)
Set displacement.
Definition Euclid3D.cpp:53
void setX(double x)
Set displacement.
Definition Euclid3D.cpp:49
static Euclid3D YRotation(double angle)
Make rotation.
Definition Euclid3D.cpp:109
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.