10 #include "CLHEP/Vector/TwoVector.h"
11 #include "CLHEP/Vector/ThreeVector.h"
20 double Hep2Vector::setTolerance (
double tol) {
27 double Hep2Vector::operator () (
int i)
const {
39 double & Hep2Vector::operator () (
int i) {
53 void Hep2Vector::rotate(
double aangle) {
54 double ss = std::sin(aangle);
55 double cc = std::cos(aangle);
66 return Hep2Vector(p.x()/
a, p.y()/
a);
69 std::ostream &
operator << (std::ostream & os,
const Hep2Vector & q) {
70 os <<
"(" << q.x() <<
", " << q.y() <<
")";
75 double &
x,
double & y );
77 std::istream &
operator>>(std::istream & is, Hep2Vector & p) {
84 Hep2Vector::operator Hep3Vector ()
const {
85 return Hep3Vector ( dx, dy, 0.0 );
88 int Hep2Vector::compare (
const Hep2Vector & v)
const {
91 }
else if ( dy < v.dy ) {
93 }
else if ( dx > v.dx ) {
95 }
else if ( dx < v.dx ) {
103 bool Hep2Vector::operator > (
const Hep2Vector & v)
const {
104 return (compare(v) > 0);
107 return (compare(v) < 0);
109 bool Hep2Vector::operator>= (
const Hep2Vector & v)
const {
110 return (compare(v) >= 0);
112 bool Hep2Vector::operator<= (
const Hep2Vector & v)
const {
113 return (compare(v) <= 0);
116 bool Hep2Vector::isNear(
const Hep2Vector & p,
double epsilon)
const {
117 double limit = dot(p)*epsilon*
epsilon;
118 return ( (*
this - p).mag2() <= limit );
121 double Hep2Vector::howNear(
const Hep2Vector & p )
const {
122 double d = (*
this - p).mag2();
124 if ( (pdp > 0) && (d < pdp) ) {
125 return std::sqrt (d/pdp);
126 }
else if ( (pdp == 0) && (d == 0) ) {
133 double Hep2Vector::howParallel (
const Hep2Vector & v)
const {
136 double v1v2 = std::fabs(dot(v));
139 return ( (mag2() == 0) && (v.mag2() == 0) ) ? 0 : 1;
141 double abscross = std::fabs ( dx * v.y() - dy - v.x() );
142 if ( abscross >= v1v2 ) {
145 return abscross/v1v2;
149 bool Hep2Vector::isParallel (
const Hep2Vector & v,
150 double epsilon)
const {
153 double v1v2 = std::fabs(dot(v));
156 return ( (mag2() == 0) && (v.mag2() == 0) );
158 double abscross = std::fabs ( dx * v.y() - dy - v.x() );
159 return ( abscross <= epsilon * v1v2 );
162 double Hep2Vector::howOrthogonal (
const Hep2Vector & v)
const {
165 double v1v2 = std::fabs(dot(v));
169 double abscross = std::fabs ( dx * v.y() - dy - v.x() );
170 if ( v1v2 >= abscross ) {
173 return v1v2/abscross;
177 bool Hep2Vector::isOrthogonal (
const Hep2Vector & v,
178 double epsilon)
const {
181 double v1v2 = std::fabs(dot(v));
182 double abscross = std::fabs ( dx * v.y() - dy - v.x() );
183 return ( v1v2 <= epsilon * abscross );
HepLorentzVector operator/(const HepLorentzVector &w, double c)
static const G4float tolerance
std::istream & operator>>(std::istream &is, HepAxisAngle &aa)
void ZMinput2doubles(std::istream &is, const char *type, double &x, double &y)
std::ostream & operator<<(std::ostream &os, const HepAxisAngle &aa)
bool operator<(const CexmcAngularRange &left, const CexmcAngularRange &right)
const G4double x[NPOINTSGL]
double epsilon(double density, double temperature)