Index: cpp/frams/util/3d.cpp
===================================================================
--- cpp/frams/util/3d.cpp	(revision 1018)
+++ cpp/frams/util/3d.cpp	(revision 1020)
@@ -1,4 +1,4 @@
 // This file is a part of Framsticks SDK.  http://www.framsticks.com/
-// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
+// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
 // See LICENSE.txt for details.
 
@@ -6,4 +6,5 @@
 #include <common/log.h>
 #include "3d.h"
+#include <algorithm> // std::min(), std::max()
 
 Pt3D operator+(const Pt3D &p1, const Pt3D &p2) { return Pt3D(p1.x + p2.x, p1.y + p2.y, p1.z + p2.z); }
@@ -16,5 +17,5 @@
 double Pt3D::operator()() const
 {
-	double q = x*x + y*y + z*z;
+	double q = x * x + y * y + z * z;
 	if (q < 0) { if (report_errors) logPrintf("Pt3D", "operator()", LOG_ERROR, "sqrt(%g): domain error", q); return 0; }
 	return sqrt(q);
@@ -34,5 +35,5 @@
 	double dy = y - p.y;
 	double dz = z - p.z;
-	return sqrt(dx*dx + dy*dy + dz*dz);
+	return sqrt(dx * dx + dy * dy + dz * dz);
 }
 
@@ -48,6 +49,6 @@
 {
 	double s = sin(k), c = cos(k);
-	double t = c*x - s*y;
-	y = s*x + c*y;
+	double t = c * x - s * y;
+	y = s * x + c * y;
 	x = t;
 }
@@ -55,6 +56,6 @@
 void rotate2D(double s, double c, double &x, double &y)
 {
-	double t = c*x - s*y;
-	y = s*x + c*y;
+	double t = c * x - s * y;
+	y = s * x + c * y;
 	x = t;
 }
@@ -105,9 +106,19 @@
 }
 
+double Pt3D::minComponent() const
+{
+	return std::min(x, std::min(y, z));
+}
+
+double Pt3D::maxComponent() const
+{
+	return std::max(x, std::max(y, z));
+}
+
 void Pt3D::vectorProduct(const Pt3D& a, const Pt3D& b)
 {
-	x = a.y*b.z - a.z*b.y;
-	y = a.z*b.x - a.x*b.z;
-	z = a.x*b.y - a.y*b.x;
+	x = a.y * b.z - a.z * b.y;
+	y = a.z * b.x - a.x * b.z;
+	z = a.x * b.y - a.y * b.x;
 }
 
@@ -146,5 +157,5 @@
 double d2(double x, double y)
 {
-	double q = x*x + y*y;
+	double q = x * x + y * y;
 	if (q < 0) { if (Pt3D::report_errors) logPrintf("", "d2()", LOG_ERROR, "sqrt(%g): domain error", q); return 0; }
 	return sqrt(q);
@@ -192,14 +203,14 @@
 void Orient::transform(Pt3D& target, const Pt3D &s) const
 {
-	target.x = s.x*x.x + s.y*y.x + s.z*z.x;
-	target.y = s.x*x.y + s.y*y.y + s.z*z.y;
-	target.z = s.x*x.z + s.y*y.z + s.z*z.z;
+	target.x = s.x * x.x + s.y * y.x + s.z * z.x;
+	target.y = s.x * x.y + s.y * y.y + s.z * z.y;
+	target.z = s.x * x.z + s.y * y.z + s.z * z.z;
 }
 
 void Orient::revTransform(Pt3D& target, const Pt3D &s) const
 {
-	target.x = s.x*x.x + s.y*x.y + s.z*x.z;
-	target.y = s.x*y.x + s.y*y.y + s.z*y.z;
-	target.z = s.x*z.x + s.y*z.y + s.z*z.z;
+	target.x = s.x * x.x + s.y * x.y + s.z * x.z;
+	target.y = s.x * y.x + s.y * y.y + s.z * y.z;
+	target.z = s.x * z.x + s.y * z.y + s.z * z.z;
 }
 
Index: cpp/frams/util/3d.h
===================================================================
--- cpp/frams/util/3d.h	(revision 1018)
+++ cpp/frams/util/3d.h	(revision 1020)
@@ -1,4 +1,4 @@
 // This file is a part of Framsticks SDK.  http://www.framsticks.com/
-// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
+// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
 // See LICENSE.txt for details.
 
@@ -29,24 +29,26 @@
 	Pt3D() {} ///< coords will be not initialized!
 	Pt3D(const Pt3D &p) :x(p.x), y(p.y), z(p.z) {} ///< copy from another point
-	bool 	operator==(const Pt3D& p)	{ return (x == p.x) && (y == p.y) && (z == p.z); }
-	void 	operator+=(const Pt3D& p)	{ x += p.x; y += p.y; z += p.z; }
-	void 	operator-=(const Pt3D& p)	{ x -= p.x; y -= p.y; z -= p.z; }
-	void  	operator*=(double d)	{ x *= d; y *= d; z *= d; }
-	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); }
-	void 	operator/=(double d)	{ x /= d; y /= d; z /= d; }
+	bool 	operator==(const Pt3D& p) { return (x == p.x) && (y == p.y) && (z == p.z); }
+	void 	operator+=(const Pt3D& p) { x += p.x; y += p.y; z += p.z; }
+	void 	operator-=(const Pt3D& p) { x -= p.x; y -= p.y; z -= p.z; }
+	void  	operator*=(double d) { x *= d; y *= d; z *= d; }
+	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); }
+	void 	operator/=(double d) { x /= d; y /= d; z /= d; }
 	//Pt3D 	operator+(const Pt3D& p) const {return Pt3D(x+p.x,y+p.y,z+p.z);}
 	//Pt3D 	operator-(const Pt3D& p) const {return Pt3D(x-p.x,y-p.y,z-p.z);}
 	Pt3D 	operator-() const { return Pt3D(-x, -y, -z); }
-	Pt3D 	operator*(double d) const { return Pt3D(x*d, y*d, z*d); }
+	Pt3D 	operator*(double d) const { return Pt3D(x * d, y * d, z * d); }
 	Pt3D 	operator/(double d) const { return Pt3D(x / d, y / d, z / d); }
-	bool    allCoordsLowerThan(const Pt3D& p) const { return (x < p.x) && (y < p.y) && (z<p.z); }
-	bool    allCoordsHigherThan(const Pt3D& p) const { return (x>p.x) && (y > p.y) && (z > p.z); }
+	bool    allCoordsLowerThan(const Pt3D& p) const { return (x < p.x) && (y < p.y) && (z < p.z); }
+	bool    allCoordsHigherThan(const Pt3D& p) const { return (x > p.x) && (y > p.y) && (z > p.z); }
 	void getMin(const Pt3D& p);
 	void getMax(const Pt3D& p);
+	double minComponent() const;
+	double maxComponent() const;
 	/** vector length = \f$\sqrt{x^2+y^2+z^2}\f$  */
 	double operator()() const;
 	/** vector length = \f$\sqrt{x^2+y^2+z^2}\f$  */
 	double length() const { return operator()(); }
-	double length2() const { return x*x + y*y + z*z; }
+	double length2() const { return x * x + y * y + z * z; }
 	double distanceTo(const Pt3D& p) const;
 	double manhattanDistanceTo(const Pt3D& p) const;
@@ -56,7 +58,7 @@
 	void getAngles(const Pt3D& X, const Pt3D& dir);
 	void vectorProduct(const Pt3D& a, const Pt3D& b);
-	Pt3D vectorProduct(const Pt3D& p) const { return (*this)*p; }
-	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
-	double dotProduct(const Pt3D& p) const { return x*p.x + y*p.y + z*p.z; }
+	Pt3D vectorProduct(const Pt3D& p) const { return (*this) * p; }
+	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
+	double dotProduct(const Pt3D& p) const { return x * p.x + y * p.y + z * p.z; }
 	bool normalize();
 };
