An open source method of characteristics neutron transport code.
Point.h
Go to the documentation of this file.
1 
8 #ifndef POINT_H_
9 #define POINT_H_
10 
11 #ifdef __cplusplus
12 #ifdef SWIG
13 #include "Python.h"
14 #endif
15 #include "log.h"
16 #include <math.h>
17 #include <sstream>
18 #endif
19 
24 class Point {
25 
26 private:
27 
29  double _xyz[3];
30 
31 public:
32  Point();
33  virtual ~Point();
34  void setCoords(const double x, const double y, const double z=0.0);
35  double getX() const;
36  double getY() const;
37  double getZ() const;
38  double* getXYZ();
39  void setX(const double x);
40  void setY(const double y);
41  void setZ(const double z);
42  double distance(const double x, const double y, const double z) const;
43  double distanceToPoint(const Point* point);
44  void copyCoords(Point* point);
45  std::string toString();
46  void setXYZ(double* xyz);
47 };
48 
49 
56 inline void Point::setCoords(const double x, const double y, const double z) {
57  _xyz[0] = x;
58  _xyz[1] = y;
59  _xyz[2] = z;
60 }
61 
62 
67 inline double Point::getX() const {
68  return _xyz[0];
69 }
70 
71 
76 inline double Point::getY() const {
77  return _xyz[1];
78 }
79 
80 
85 inline double Point::getZ() const {
86  return _xyz[2];
87 }
88 
89 
94 inline double* Point::getXYZ() {
95  return _xyz;
96 }
97 
98 
103 inline void Point::setX(const double x) {
104  _xyz[0] = x;
105 }
106 
107 
112 inline void Point::setY(const double y) {
113  _xyz[1] = y;
114 }
115 
116 
121 inline void Point::setZ(const double z) {
122  _xyz[2] = z;
123 }
124 
125 
130 inline void Point::setXYZ(double* xyz) {
131  _xyz[0] = xyz[0];
132  _xyz[1] = xyz[1];
133  _xyz[2] = xyz[2];
134 }
135 
136 
144 inline double Point::distance(const double x, const double y, const double z) const {
145  double deltax = _xyz[0] - x;
146  double deltay = _xyz[1] - y;
147  double deltaz = _xyz[2] - z;
148  return sqrt(deltax*deltax + deltay*deltay + deltaz*deltaz);
149 }
150 
151 
157 inline double Point::distanceToPoint(const Point* point) {
158  double deltax = _xyz[0] - point->getX();
159  double deltay = _xyz[1] - point->getY();
160  double deltaz = _xyz[2] - point->getZ();
161  return sqrt(deltax*deltax + deltay*deltay + deltaz*deltaz);
162 }
163 
164 
169 inline void Point::copyCoords(Point* point) {
170  _xyz[0] = point->getX();
171  _xyz[1] = point->getY();
172  _xyz[2] = point->getZ();
173 }
174 
175 
176 #endif /* POINT_H_ */
void setX(const double x)
Set the Point&#39;s x-coordinate.
Definition: Point.h:103
void setXYZ(double *xyz)
Set the Point&#39;s x, y and z-coordinates.
Definition: Point.h:130
double getY() const
Returns this Point&#39;s y-coordinate.
Definition: Point.h:76
Class to represent a 2D/3D point in space.
Definition: Point.h:24
double getX() const
Returns this Point&#39;s x-coordinate.
Definition: Point.h:67
void copyCoords(Point *point)
Copy the coordinates from another point.
Definition: Point.h:169
virtual ~Point()
Destructor.
Definition: Point.cpp:17
double distance(const double x, const double y, const double z) const
Compute the distance from this Point to another Point of interest.
Definition: Point.h:144
void setZ(const double z)
Set the Point&#39;s z-coordinate.
Definition: Point.h:121
double distanceToPoint(const Point *point)
Compute the distance from this Point to another Point of interest.
Definition: Point.h:157
Point()
Constructor initializes an empty Point.
Definition: Point.cpp:7
double getZ() const
Returns this Point&#39;s z-coordinate.
Definition: Point.h:85
void setCoords(const double x, const double y, const double z=0.0)
Initializes a Point with two-dimensional coordinates.
Definition: Point.h:56
void setY(const double y)
Set the Point&#39;s y-coordinate.
Definition: Point.h:112
Utility functions for writing log messages to the screen.
std::string toString()
Converts this Point to a character representation of its attributes.
Definition: Point.cpp:27
double * getXYZ()
Returns this Point&#39;s coordinates.
Definition: Point.h:94