Class: QgsBox3D¶
- class qgis.core.QgsBox3D¶
Bases:
sip.wrapper
A 3-dimensional box composed of x, y, z coordinates.
A box composed of x/y/z minimum and maximum values. It is often used to return the 3D extent of a geometry or collection of geometries.
Note
In QGIS 3.34 this class was renamed from
QgsBox3d
toQgsBox3D
. The oldQgsBox3d
name remains available in PyQGIS for compatibility.See also
New in version 3.0.
QgsBox3D(x: Optional[Union[
QgsPoint
,QgsRectangle
, float]] = Py_None, y: Optional[QgsPoint
, float] = Py_None, z: Optional[Union[bool, float]] = Py_None, x2: Optional[Union[bool, float]] = Py_None, y2: Optional[float] = Py_None, z2: Optional[float] = Py_None, n: Optional[bool] = Py_None) Constructor forQgsBox3D
which accepts the ranges of x/y/z coordinates. Ifnormalize
isFalse
then the normalization step will not be applied automatically.QgsBox3D(
QgsBox3D
)Methods
Returns the center of the box as a vector.
Expands the bbox so that it covers both the original rectangle and the given rectangle.
Returns
True
when box contains other box.Returns an array of all box corners as 3D vectors.
Returns the depth of the box.
Returns the smallest distance between the box and the point
point
(returns 0 if the point is inside the box)Returns the height of the box.
Returns the intersection of this box and another 3D box.
Returns
True
if box intersects with another box.Returns
True
if the box can be considered a 2-dimensional box, i.e. it has equal minimum and maximum z values.Returns
True
if the box can be considered a 3-dimensional box, i.e. it has valid minimum and maximum z values.Returns
True
if the box is empty.Test if the box is null (all coordinates NaN or after call to
setMinimal()
).Normalize the box so it has non-negative width/height/depth.
Scale the rectangle around a
center
QgsPoint
.Set a box so that min corner is at std.numeric_limits<double>.max() and max corner is at -std.numeric_limits<double>.max().
Sets the maximum
x
value.Sets the minimum
x
value.Sets the maximum
y
value.Sets the minimum
y
value.Sets the maximum
z
value.Sets the minimum
z
value.Converts the box to a 2D rectangle.
Returns a string representation of form xmin,ymin,zmin : xmax,ymax,zmax Coordinates will be truncated to the specified precision.
Returns the volume of the box.
Returns the width of the box.
Returns the maximum x value.
Returns the minimum x value.
Returns the maximum y value.
Returns the minimum y value.
Returns the maximum z value.
Returns the minimum z value.
Attributes
- center(self) QgsVector3D ¶
Returns the center of the box as a vector.
New in version 3.34.
- Return type:
- combineWith(self, box: QgsBox3D)¶
Expands the bbox so that it covers both the original rectangle and the given rectangle.
New in version 3.34.
combineWith(self, x: float, y: float, z: float) Expands the bbox so that it covers both the original rectangle and the given point.
New in version 3.34.
- Parameters:
box (QgsBox3D) –
- contains(self, other: QgsBox3D) bool ¶
Returns
True
when box contains other box.contains(self, point:
QgsPoint
) -> bool ReturnsTrue
when box contains apoint
.If the point is a 2D point (no z-coordinate), then the containment test will be performed on the x/y extent of the box only.
contains(self, x: float, y: float, z: float) -> bool Returns
True
when box contains a point (x
,y
,z
). A point on the border of the box will also returnTrue
If the point is a 2D point (no z-coordinate), then the containment test will be performed on the x/y extent of the box only.
New in version 3.34.
- Parameters:
other (QgsBox3D) –
- Return type:
bool
- corners(self) List[QgsVector3D] ¶
Returns an array of all box corners as 3D vectors.
- Return type:
List[QgsVector3D]
- depth(self) float ¶
Returns the depth of the box.
See also
See also
- Return type:
float
- distanceTo(self, point: QVector3D) float ¶
Returns the smallest distance between the box and the point
point
(returns 0 if the point is inside the box)New in version 3.18.
- Parameters:
point (QVector3D) –
- Return type:
float
- height(self) float ¶
Returns the height of the box.
See also
See also
- Return type:
float
- intersect(self, other: QgsBox3D) QgsBox3D ¶
Returns the intersection of this box and another 3D box.
- intersects(self, other: QgsBox3D) bool ¶
Returns
True
if box intersects with another box.- Parameters:
other (QgsBox3D) –
- Return type:
bool
- is2d(self) bool ¶
Returns
True
if the box can be considered a 2-dimensional box, i.e. it has equal minimum and maximum z values.- Return type:
bool
- is3D(self) bool ¶
Returns
True
if the box can be considered a 3-dimensional box, i.e. it has valid minimum and maximum z values. If the box is not normalized, this returnsFalse
.New in version 3.34.
- Return type:
bool
- isEmpty(self) bool ¶
Returns
True
if the box is empty. An empty box may still be non-null if it contains valid information (e.g. bounding box of a point).New in version 3.34.
- Return type:
bool
- isNull(self) bool ¶
Test if the box is null (all coordinates NaN or after call to
setMinimal()
). A null box is also an empty box.New in version 3.34.
- Return type:
bool
- normalize(self)¶
Normalize the box so it has non-negative width/height/depth.
- scale(self, scaleFactor: float, center: QgsPoint = QgsPoint())¶
Scale the rectangle around a
center
QgsPoint
.If no
center
point is specified then the current center of the box will be used.New in version 3.26.
scale(self, scaleFactor: float, centerX: float, centerY: float, centerZ: float) Scale the rectangle around a center coordinates.
New in version 3.26.
- Parameters:
scaleFactor (float) –
center (
QgsPoint
= QgsPoint()) –
- setMinimal(self)¶
Set a box so that min corner is at std.numeric_limits<double>.max() and max corner is at -std.numeric_limits<double>.max(). It is NOT normalized.
New in version 3.34.
- setXMaximum(self, x: float)¶
Sets the maximum
x
value.See also
See also
- Parameters:
x (float) –
- setXMinimum(self, x: float)¶
Sets the minimum
x
value.See also
See also
- Parameters:
x (float) –
- setYMaximum(self, y: float)¶
Sets the maximum
y
value.See also
See also
- Parameters:
y (float) –
- setYMinimum(self, y: float)¶
Sets the minimum
y
value.See also
See also
- Parameters:
y (float) –
- setZMaximum(self, z: float)¶
Sets the maximum
z
value.See also
See also
- Parameters:
z (float) –
- setZMinimum(self, z: float)¶
Sets the minimum
z
value.See also
See also
- Parameters:
z (float) –
- staticMetaObject = <PyQt5.QtCore.QMetaObject object>¶
- toRectangle(self) QgsRectangle ¶
Converts the box to a 2D rectangle.
- Return type:
- toString(self, precision: int = 16) str ¶
Returns a string representation of form xmin,ymin,zmin : xmax,ymax,zmax Coordinates will be truncated to the specified precision. If the specified precision is less than 0, a suitable minimum precision is used.
New in version 3.34.
- Parameters:
precision (int = 16) –
- Return type:
str
- volume(self) float ¶
Returns the volume of the box.
- Return type:
float
- width(self) float ¶
Returns the width of the box.
See also
See also
- Return type:
float
- xMaximum(self) float ¶
Returns the maximum x value.
See also
See also
- Return type:
float
- xMinimum(self) float ¶
Returns the minimum x value.
See also
See also
- Return type:
float
- yMaximum(self) float ¶
Returns the maximum y value.
See also
See also
- Return type:
float
- yMinimum(self) float ¶
Returns the minimum y value.
See also
See also
- Return type:
float
- zMaximum(self) float ¶
Returns the maximum z value.
See also
See also
- Return type:
float
- zMinimum(self) float ¶
Returns the minimum z value.
See also
See also
- Return type:
float