Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JSphere3D.hh
Go to the documentation of this file.
1#ifndef __JSPHERE3D__
2#define __JSPHERE3D__
3
4#include <istream>
5#include <ostream>
6
9#include "JLang/JManip.hh"
10
11
12/**
13 * \author mdejong
14 */
15
16namespace JGEOMETRY3D {}
17namespace JPP { using namespace JGEOMETRY3D; }
18
19namespace JGEOMETRY3D {
20
21 using JIO::JReader;
22 using JIO::JWriter;
23
24
25 /**
26 * 3D sphere.
27 */
28 class JSphere3D :
29 public JPosition3D
30 {
31 public:
32 /**
33 * Default constructor.
34 */
37 __r(0.0)
38 {}
39
40
41 /**
42 * Constructor.
43 *
44 * \param pos position
45 * \param r radius
46 */
47 JSphere3D(const JVector3D& pos,
48 const double r) :
49 JPosition3D(pos),
50 __r(r)
51 {}
52
53
54 /**
55 * Get radius.
56 *
57 * \return radius
58 */
59 double getRadius() const
60 {
61 return __r;
62 }
63
64
65 /**
66 * Read sphere from input.
67 *
68 * \param in input stream
69 * \param sphere sphere
70 * \return input stream
71 */
72 friend inline std::istream& operator>>(std::istream& in, JSphere3D& sphere)
73 {
74 in >> static_cast<JPosition3D&>(sphere);
75 in >> sphere.__r;
76
77 return in;
78 }
79
80
81 /**
82 * Write sphere to output.
83 *
84 * \param out output stream
85 * \param sphere sphere
86 * \return output stream
87 */
88 friend inline std::ostream& operator<<(std::ostream& out, const JSphere3D& sphere)
89 {
90 const JFormat format(out, getFormat<JPosition3D>(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos)));
91
92 out << static_cast<const JPosition3D&>(sphere);
93 out << ' ';
94 out << format << sphere.__r;
95
96 return out;
97 }
98
99
100 /**
101 * Read sphere from input.
102 *
103 * \param in reader
104 * \param sphere sphere
105 * \return reader
106 */
107 friend inline JReader& operator>>(JReader& in, JSphere3D& sphere)
108 {
109 in >> static_cast<JPosition3D&>(sphere);
110 in >> sphere.__r;
111
112 return in;
113 }
114
115
116 /**
117 * Write sphere to output.
118 *
119 * \param out writer
120 * \param sphere sphere
121 * \return writer
122 */
123 friend inline JWriter& operator<<(JWriter& out, const JSphere3D& sphere)
124 {
125 out << static_cast<const JPosition3D&>(sphere);
126 out << sphere.__r;
127
128 return out;
129 }
130
131 protected:
132 double __r;
133 };
134}
135
136#endif
I/O manipulators.
JFormat_t & getFormat()
Get format for given type.
Definition JManip.hh:682
Data structure for position in three dimensions.
friend std::istream & operator>>(std::istream &in, JSphere3D &sphere)
Read sphere from input.
Definition JSphere3D.hh:72
JSphere3D(const JVector3D &pos, const double r)
Constructor.
Definition JSphere3D.hh:47
double getRadius() const
Get radius.
Definition JSphere3D.hh:59
friend JWriter & operator<<(JWriter &out, const JSphere3D &sphere)
Write sphere to output.
Definition JSphere3D.hh:123
JSphere3D()
Default constructor.
Definition JSphere3D.hh:35
friend std::ostream & operator<<(std::ostream &out, const JSphere3D &sphere)
Write sphere to output.
Definition JSphere3D.hh:88
friend JReader & operator>>(JReader &in, JSphere3D &sphere)
Read sphere from input.
Definition JSphere3D.hh:107
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
Interface for binary input.
Interface for binary output.
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition JAngle3D.hh:19
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Data structure for format specifications.
Definition JManip.hh:524
Auxiliary class to temporarily define format specifications.
Definition JManip.hh:636