Changeset 1020 for cpp/frams/util/3d.h
- Timestamp:
- 07/24/20 21:44:10 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/util/3d.h
r305 r1020 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 15Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2020 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 29 29 Pt3D() {} ///< coords will be not initialized! 30 30 Pt3D(const Pt3D &p) :x(p.x), y(p.y), z(p.z) {} ///< copy from another point 31 bool operator==(const Pt3D& p) 32 void operator+=(const Pt3D& p) 33 void operator-=(const Pt3D& p) 34 void operator*=(double d) 35 Pt3D operator*(const Pt3D &p) const { return Pt3D(y *p.z - z*p.y, z*p.x - x*p.z, x*p.y - y*p.x); }36 void operator/=(double d) 31 bool operator==(const Pt3D& p) { return (x == p.x) && (y == p.y) && (z == p.z); } 32 void operator+=(const Pt3D& p) { x += p.x; y += p.y; z += p.z; } 33 void operator-=(const Pt3D& p) { x -= p.x; y -= p.y; z -= p.z; } 34 void operator*=(double d) { x *= d; y *= d; z *= d; } 35 Pt3D operator*(const Pt3D &p) const { return Pt3D(y * p.z - z * p.y, z * p.x - x * p.z, x * p.y - y * p.x); } 36 void operator/=(double d) { x /= d; y /= d; z /= d; } 37 37 //Pt3D operator+(const Pt3D& p) const {return Pt3D(x+p.x,y+p.y,z+p.z);} 38 38 //Pt3D operator-(const Pt3D& p) const {return Pt3D(x-p.x,y-p.y,z-p.z);} 39 39 Pt3D operator-() const { return Pt3D(-x, -y, -z); } 40 Pt3D operator*(double d) const { return Pt3D(x *d, y*d, z*d); }40 Pt3D operator*(double d) const { return Pt3D(x * d, y * d, z * d); } 41 41 Pt3D operator/(double d) const { return Pt3D(x / d, y / d, z / d); } 42 bool allCoordsLowerThan(const Pt3D& p) const { return (x < p.x) && (y < p.y) && (z <p.z); }43 bool allCoordsHigherThan(const Pt3D& p) const { return (x >p.x) && (y > p.y) && (z > p.z); }42 bool allCoordsLowerThan(const Pt3D& p) const { return (x < p.x) && (y < p.y) && (z < p.z); } 43 bool allCoordsHigherThan(const Pt3D& p) const { return (x > p.x) && (y > p.y) && (z > p.z); } 44 44 void getMin(const Pt3D& p); 45 45 void getMax(const Pt3D& p); 46 double minComponent() const; 47 double maxComponent() const; 46 48 /** vector length = \f$\sqrt{x^2+y^2+z^2}\f$ */ 47 49 double operator()() const; 48 50 /** vector length = \f$\sqrt{x^2+y^2+z^2}\f$ */ 49 51 double length() const { return operator()(); } 50 double length2() const { return x *x + y*y + z*z; }52 double length2() const { return x * x + y * y + z * z; } 51 53 double distanceTo(const Pt3D& p) const; 52 54 double manhattanDistanceTo(const Pt3D& p) const; … … 56 58 void getAngles(const Pt3D& X, const Pt3D& dir); 57 59 void vectorProduct(const Pt3D& a, const Pt3D& b); 58 Pt3D vectorProduct(const Pt3D& p) const { return (*this) *p; }59 Pt3D entrywiseProduct(const Pt3D &p) const { return Pt3D(x *p.x, y*p.y, z*p.z); } ///< also known as Hadamard product or Schur product60 double dotProduct(const Pt3D& p) const { return x *p.x + y*p.y + z*p.z; }60 Pt3D vectorProduct(const Pt3D& p) const { return (*this) * p; } 61 Pt3D entrywiseProduct(const Pt3D &p) const { return Pt3D(x * p.x, y * p.y, z * p.z); } ///< also known as Hadamard product or Schur product 62 double dotProduct(const Pt3D& p) const { return x * p.x + y * p.y + z * p.z; } 61 63 bool normalize(); 62 64 };
Note: See TracChangeset
for help on using the changeset viewer.