38 Point3(
const double x_,
const double y_,
const double z_):
42 r(0),g(0),b(0),a(0),bHasColor(false)
51 Point3(
const double x_,
const double y_,
const double z_,
unsigned char r_,
unsigned char g_,
unsigned char b_,
unsigned char a_):
68 Point3():coordX(0),coordY(0),coordZ(0),r(0),g(0),b(0),a(0),bHasColor(false)
81 r(p_.r),g(p_.g),b(p_.b),a(p_.a),bHasColor(p_.bHasColor)
98 bHasColor=other.bHasColor;
112 void setColor(
unsigned char r_,
unsigned char g_,
unsigned char b_,
unsigned char a_)
127 void getColor_255(
unsigned char& r_,
unsigned char& g_,
unsigned char& b_,
unsigned char& a_)
const
142 r_=
static_cast<float>(r);
143 g_=
static_cast<float>(g);
144 b_=
static_cast<float>(b);
145 a_=
static_cast<float>(a);
156 std::stringstream ss;
157 ss<<r<<
" "<<g<<
" "<<b<<
" "<<a;
165 void getColor_1(
float& r_,
float& g_,
float& b_,
float& a_)
const
218 void xyz(
double& x_,
double& y_,
double& z_)
const
252 inline void addOwnColor(
float& r_,
float& g_,
float& b_,
float& a_)
const
271 bHasColor=other.bHasColor;
283 r=
static_cast<unsigned char>(.5*(float(other0.r)+float(other1.r))+.5f);
284 g=
static_cast<unsigned char>(.5*(float(other0.g)+float(other1.g))+.5f);
285 b=
static_cast<unsigned char>(.5*(float(other0.b)+float(other1.b))+.5f);
286 a=
static_cast<unsigned char>(.5*(float(other0.a+other1.a))+.5f);
292 copyColorFrom(other0);
297 copyColorFrom(other0);
323 if(coordX<p.coordX)
return true;
324 if(coordX>p.coordX)
return false;
325 if(coordY<p.coordY)
return true;
326 if(coordY>p.coordY)
return false;
327 return coordZ<p.coordZ;
339 if(coordX>p.coordX)
return true;
340 if(coordX<p.coordX)
return false;
341 if(coordY>p.coordY)
return true;
342 if(coordY<p.coordY)
return false;
343 return coordY>p.coordY;
351 if(coordX==p.coordX && coordY==p.coordY && coordZ==p.coordZ)
return true;
360 return (coordX!=p.coordX || coordY!=p.coordY || coordZ!=p.coordZ);
370 void set(
const double x_,
const double y_,
const double z_)
400 double xdiff(x()-other.
x());
401 double ydiff(y()-other.
y());
402 double zdiff(z()-other.
z());
403 return Vector3(xdiff,ydiff,zdiff);
412 return Point3(x()+vec.
x(),y()+vec.
y(),z()+vec.
z());
422 return Point3(x()-vec.
x(),y()-vec.
y(),z()-vec.
z());
426 friend std::ostream &operator<<(std::ostream &stream,
const Point3& pnt);
427 friend std::istream &operator>>(std::istream &stream,
Point3& pnt);
434 unsigned char r,g,b,a;
446 inline std::ostream &operator<<(std::ostream &stream,
const Point3& pnt)
450 stream <<
"Point3 ("<<&pnt<<
"): "<<pnt.x()<<
", "<<pnt.y()<<
", "<<pnt.z()<<
", color("<<int(pnt.r)<<
","<<int(pnt.g)<<
","<<int(pnt.b)<<
","<<int(pnt.a)<<
")";
454 stream <<
"Point3 ("<<&pnt<<
"): "<<pnt.x()<<
", "<<pnt.y()<<
", "<<pnt.z()<<
", no color";
459 inline std::istream &operator>>(std::istream &stream, Point3& pnt)
461 stream >> pnt.coordX >> pnt.coordY >> pnt.coordZ;
470 double deltaX=p1.
x()-p0.
x();
471 double deltaY=p1.
y()-p0.
y();
472 double deltaZ=p1.
z()-p0.
z();
473 return (deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
480 double deltaX=p1->
x()-p0->
x();
481 double deltaY=p1->
y()-p0->
y();
482 double deltaZ=p1->
z()-p0->
z();
483 return (deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
491 double deltaX=p1.
x()-p0.
x();
492 double deltaY=p1.
y()-p0.
y();
493 double deltaZ=p1.
z()-p0.
z();
494 return sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
3D Point
Definition: Point3.h:31
bool operator<(const Point3 &p) const
Less than operator.
Definition: Point3.h:321
void copyColorFrom(const Point3 &other)
Copy the color from another point.
Definition: Point3.h:265
double x() const
Get the x-coordinate.
Definition: Point3.h:185
Point3 & operator=(const Point3 &other)
operator=
Definition: Point3.h:89
Point3 operator-(const Vector3 &vec) const
operator-
Definition: Point3.h:420
double y() const
Get the y-coordinate.
Definition: Point3.h:195
void addOwnCoordsW(double &x, double &y, double &z, double w) const
Add the point's coordinates to x,y,z.
Definition: Point3.h:243
Point3()
Default constructor.
Definition: Point3.h:68
Vector3 operator-(const Point3 &other) const
operator-
Definition: Point3.h:398
void set(const double x_, const double y_, const double z_)
Set the coordiantes.
Definition: Point3.h:370
bool operator!=(const Point3 &p) const
Inequality operator.
Definition: Point3.h:358
Point3 operator+(const Vector3 &vec) const
operator+
Definition: Point3.h:410
void addOwnCoords(double &x, double &y, double &z) const
Add the point's coordinates to x,y,z.
Definition: Point3.h:231
~Point3()
Destructor.
Definition: Point3.h:104
Point3(const double x_, const double y_, const double z_, unsigned char r_, unsigned char g_, unsigned char b_, unsigned char a_)
Constructor with color.
Definition: Point3.h:51
void xyz(double &x_, double &y_, double &z_) const
Get the x-, y- and z-coordinate.
Definition: Point3.h:218
void set(const Point3 &pnt)
Set the coordiantes.
Definition: Point3.h:383
void getColor_255(unsigned char &r_, unsigned char &g_, unsigned char &b_, unsigned char &a_) const
Get color (unsigned char, range=0, ..., 255)
Definition: Point3.h:127
bool hasColor() const
Has color.
Definition: Point3.h:176
bool operator>(const Point3 &p) const
Greater than operator.
Definition: Point3.h:337
bool operator==(const Point3 &p) const
Equality operator.
Definition: Point3.h:349
void copyColorFrom(const Point3 &other0, const Point3 &other1)
Copy the average color from two points.
Definition: Point3.h:279
double z() const
Get the z-coordinate.
Definition: Point3.h:205
void addWeightedOwnCoords(double weight, double &x, double &y, double &z) const
Add the point's weighted coordinates to x,y,z.
Definition: Point3.h:308
void getColor_1(float &r_, float &g_, float &b_, float &a_) const
Get color (float, range=0.0, ..., 1.0)
Definition: Point3.h:165
void getColor_255(float &r_, float &g_, float &b_, float &a_) const
Get color (float, range=0, ..., 255)
Definition: Point3.h:140
Point3(const Point3 &p_)
Copy constructor.
Definition: Point3.h:77
Point3(const double x_, const double y_, const double z_)
Constructor without color.
Definition: Point3.h:38
std::string getColorString()
Get color string (string, range=0.0, ..., 1.0)
Definition: Point3.h:152
void setColor(unsigned char r_, unsigned char g_, unsigned char b_, unsigned char a_)
Set color.
Definition: Point3.h:112
3D Vector
Definition: Vector3.h:27
double z() const
Get the z-value.
Definition: Vector3.h:100
double x() const
Get the x-value.
Definition: Vector3.h:81
double y() const
Get the y-value.
Definition: Vector3.h:90
double sqDistance(const Point3 &p0, const Point3 &p1)
Get the squared distance between two points.
Definition: Point3.h:468
Point3 center(const Point3 &p0, const Point3 &p1)
Midpoint of p0 and p1.
Definition: Point3.h:501
double distance(const Point3 &p0, const Point3 &p1)
Get the distance between two points.
Definition: Point3.h:489