| Description | uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables |
Type TBox3d and many operations on it.
| Name | Description |
|---|---|
Class TObjectBBox |
|
Class TDynArray_1 |
function IsEmptyBox3d(const Box: TBox3d): boolean; |
function Box3d(const p0, p1: TVector3Single): TBox3d; |
function Box3dOrderUp(const p0, p1: TVector3Single): TBox3d; |
function Box3dMiddle(const Box: TBox3d): TVector3Single; |
function Box3dAvgSize(const Box: TBox3d): Single; |
function Box3dMaxSize(const box: TBox3d): Single; |
function Box3dMinSize(const box: TBox3d): Single; |
function Box3dSizeX(const box: TBox3d): Single; |
function Box3dSizeY(const box: TBox3d): Single; |
function Box3dSizeZ(const box: TBox3d): Single; |
procedure BoxExpandTo1st(var Box: TBox3d; const Expand: Single); overload; |
procedure BoxExpandTo1st(var box: TBox3d; const Expand: TVector3Single); overload; |
function BoxExpand(var Box: TBox3d; const Expand: Single): TBox3d; overload; |
function BoxExpand(var box: TBox3d; const Expand: TVector3Single): TBox3d; overload; |
function Box3dPointInside(const pt: TVector3Single; const box: TBox3d): boolean; overload; |
function Box3dPointInside(const pt: TVector3Double; const box: TBox3d): boolean; overload; |
function Box3dCubeAroundPoint(const pt: TVector3Single; CubeSize: Single): TBox3d; |
function CalculateBoundingBox( Verts: PVector3Single; VertsCount: Cardinal; VertsStride: Cardinal): TBox3d; overload; |
function CalculateBoundingBox( Verts: PVector3Single; VertsCount: Cardinal; VertsStride: Cardinal; const Transform: TMatrix4Single): TBox3d; overload; |
function CalculateBoundingBox( GetVertex: TGetVertexFromIndexFunc; VertsCount: integer): TBox3d; overload; |
function CalculateBoundingBoxFromIndices( GetVertIndex: TGetIndexFromIndexNumFunc; VertsIndicesCount: integer; GetVertex: TGetVertexFromIndexFunc): TBox3d; overload; |
function CalculateBoundingBoxFromIndices( GetVertIndex: TGetIndexFromIndexNumFunc; VertsIndicesCount: integer; GetVertex: TGetVertexFromIndexFunc; const Transform: TMatrix4Single): TBox3d; overload; |
function Box3dSum(const box1, box2: TBox3d): TBox3d; |
procedure Box3dSumTo1st(var box1: TBox3d; const box2: TBox3d); overload; |
procedure Box3dSumTo1st(var box1: TBox3d; const Point: TVector3Single); overload; |
function Box3dSizes(const box: TBox3d): TVector3Single; |
procedure Box3dGetAllPoints(allpoints: PVector3Single; const box: TBox3d); |
function BoundingBoxTransform(const bbox: TBox3d; const Matrix: TMatrix4Single): TBox3d; |
function Box3dTranslate(const Box: TBox3d; const Translation: TVector3Single): TBox3d; |
function Box3dAntiTranslate(const Box: TBox3d; const Translation: TVector3Single): TBox3d; |
function Box3dToNiceStr(const box: TBox3d): string; |
function Box3dToRawStr(const box: TBox3d): string; |
procedure Box3dClamp(var point: TVector3Single; const box: TBox3d); overload; |
procedure Box3dClamp(var point: TVector3Double; const box: TBox3d); overload; |
function TriangleBoundingBox(const T: TTriangle3Single): TBox3d; |
function TryBoxRayClosestIntersection( out Intersection: TVector3Single; out IntersectionDistance: Single; const Box: TBox3d; const Ray0, RayVector: TVector3Single): boolean; overload; |
function TryBoxRayClosestIntersection( out Intersection: TVector3Single; const Box: TBox3d; const Ray0, RayVector: TVector3Single): boolean; overload; |
function TryBoxRayClosestIntersection( out IntersectionDistance: Single; const Box: TBox3d; const Ray0, RayVector: TVector3Single): boolean; overload; |
function TryBoxRayEntrance(out Entrance: TVector3Single; const Box: TBox3d; const Ray0, RayVector: TVector3Single): boolean; |
function IsBox3dSegmentCollision( const Box: TBox3d; const Segment1, Segment2: TVector3Single): boolean; |
function IsCenteredBox3dPlaneCollision( const BoxHalfSize: TVector3Single; const Plane: TVector4Single): boolean; overload; |
function IsCenteredBox3dPlaneCollision( const BoxHalfSize: TVector3Double; const Plane: TVector4Double): boolean; overload; |
function IsBox3dPlaneCollision(const Box3d: TBox3d; const Plane: TVector4Single): boolean; |
function IsBox3dTriangleCollision( const Box: TBox3d; const Triangle: TTriangle3Single): boolean; |
function FrustumBox3dCollisionPossible(const Frustum: TFrustum; const Box: TBox3d): TFrustumCollisionPossible; |
function FrustumBox3dCollisionPossibleSimple(const Frustum: TFrustum; const Box: TBox3d): boolean; |
procedure Box3dBoundingSphere(const Box3d: TBox3d; var SphereCenter: TVector3Single; var SphereRadiusSqr: Single); |
function Boxes3dCollision(const Box1, Box2: TBox3d): boolean; |
function Boxes3dXYCollision(const Box1, Box2: TBox3d): boolean; |
function Box3dSqrRadius(const Box: TBox3d): Single; |
function Box3dRadius(const Box: TBox3d): Single; |
function Box3dXYSqrRadius(const Box: TBox3d): Single; |
function Box3dXYRadius(const Box: TBox3d): Single; |
function Box3dSphereSimpleCollision(const Box: TBox3d; const SphereCenter: TVector3Single; const SphereRadius: Single): boolean; |
function Box3dSphereCollision(const Box: TBox3d; const SphereCenter: TVector3Single; const SphereRadius: Single): boolean; |
TBox3d = array[0..1]of TVector3Single; |
PBox3d = ˆTBox3d; |
TGetIndexFromIndexNumFunc = function(indexNum: integer): integer of object; |
TGetVertexFromIndexFunc = function(index: integer): TVector3Single of object; |
TDynArrayItem_1 = TBox3d; |
PDynArrayItem_1 = PBox3d; |
TInfiniteArray_1 = array[0..MaxInt div SizeOf(TDynArrayItem_1)-1]of TDynArrayItem_1; |
PInfiniteArray_1 = ˆTInfiniteArray_1; |
TDynArrayItemIsSmallerFunc_1 = function (const a, b: TDynArrayItem_1): boolean; |
TDynArrayItemIsSmallerFuncByObject_1 = function (const a, b: TDynArrayItem_1): boolean of object; |
TArray_Box3d = TInfiniteArray_1; |
PArray_Box3d = PInfiniteArray_1; |
TDynBox3dArray = TDynArray_1; |
EmptyBox3d: TBox3d = ((0, 0, 0), (-1, -1, -1)); |
function IsEmptyBox3d(const Box: TBox3d): boolean; |
|
Check is box empty. You can think of this function as "compare Box with EmptyBox3d". But actually it works a little faster, by utilizing the assumption that EmptyBox3d is the only allowed value that breaks |
function Box3d(const p0, p1: TVector3Single): TBox3d; |
function Box3dOrderUp(const p0, p1: TVector3Single): TBox3d; |
function Box3dMiddle(const Box: TBox3d): TVector3Single; |
|
These functions calculate the middle point, average size, max size and particular sizes of given bounding box. When given Box is empty (IsEmptyBox3d), they raise some exception. |
function Box3dAvgSize(const Box: TBox3d): Single; |
function Box3dMaxSize(const box: TBox3d): Single; |
function Box3dMinSize(const box: TBox3d): Single; |
function Box3dSizeX(const box: TBox3d): Single; |
function Box3dSizeY(const box: TBox3d): Single; |
function Box3dSizeZ(const box: TBox3d): Single; |
procedure BoxExpandTo1st(var Box: TBox3d; const Expand: Single); overload; |
|
This decreases Box[0, 0], Box[0, 1], Box[0, 2] by Expand and increases Box[1, 0], Box[1, 1], Box[1, 2] by Expand. So you get Box with all sizes increased by 2 * Expand. Box must not be empty. Note that Expand may be negative, but then you must be sure that it doesn't make Box empty. |
procedure BoxExpandTo1st(var box: TBox3d; const Expand: TVector3Single); overload; |
|
This decreases Box[0] by Expand, and increases Box[1] by Expand. So you get Box with all sizes increased by 2 * Expand. Box must not be empty. Note that Expand may be negative, but then you must be sure that it doesn't make Box empty. |
function BoxExpand(var Box: TBox3d; const Expand: Single): TBox3d; overload; |
function BoxExpand(var box: TBox3d; const Expand: TVector3Single): TBox3d; overload; |
function Box3dPointInside(const pt: TVector3Single; const box: TBox3d): boolean; overload; |
|
Check is the point inside the box. Always false if Box is empty (obviously, no point is inside an empty box). |
function Box3dPointInside(const pt: TVector3Double; const box: TBox3d): boolean; overload; |
function Box3dCubeAroundPoint(const pt: TVector3Single; CubeSize: Single): TBox3d; |
function CalculateBoundingBox( Verts: PVector3Single; VertsCount: Cardinal; VertsStride: Cardinal): TBox3d; overload; |
|
Calculate bounding box of a set of 3D points. This calculates the smallest possible box enclosing all given points. For VertsCount = 0 this returns EmptyBox3d. Overloaded version with Transform parameter transforms each point by given matrix. Overloaded version with GetVertex as a function uses GetVertex to query for indexes from [0 .. VertsCount - 1] range. As usual, VertsStride = 0 means VertsStride = SizeOf(TVector3Single). |
function CalculateBoundingBox( Verts: PVector3Single; VertsCount: Cardinal; VertsStride: Cardinal; const Transform: TMatrix4Single): TBox3d; overload; |
function CalculateBoundingBox( GetVertex: TGetVertexFromIndexFunc; VertsCount: integer): TBox3d; overload; |
function CalculateBoundingBoxFromIndices( GetVertIndex: TGetIndexFromIndexNumFunc; VertsIndicesCount: integer; GetVertex: TGetVertexFromIndexFunc): TBox3d; overload; |
|
Calculate bounding box of a set of indexed 3D points. This is much like CalculateBoundingBox, except there are two functions: For each number in [0 .. VertsIndicesCount - 1] range, GetVertIndex returns an index. If this index is >= 0 then it's used to query GetVertex function to get actual vertex position. Indexes < 0 are ignored, this is sometimes comfortable. E.g. for VRML models, you often have a list of indexes with -1 in between marking end of faces. Returns smallest box enclosing all vertexes. Overloaded version with Transform parameter transforms each point by given matrix. |
function CalculateBoundingBoxFromIndices( GetVertIndex: TGetIndexFromIndexNumFunc; VertsIndicesCount: integer; GetVertex: TGetVertexFromIndexFunc; const Transform: TMatrix4Single): TBox3d; overload; |
function Box3dSum(const box1, box2: TBox3d): TBox3d; |
|
Sum two TBox3d values. This calculates the smallest box that encloses both Box1 and Box2. Box3dSumTo1st places the result of calculation back in Box1 argument. |
procedure Box3dSumTo1st(var box1: TBox3d; const box2: TBox3d); overload; |
procedure Box3dSumTo1st(var box1: TBox3d; const Point: TVector3Single); overload; |
|
This enlarges Box1 so that it contains given Point. |
function Box3dSizes(const box: TBox3d): TVector3Single; |
|
Three box sizes. |
procedure Box3dGetAllPoints(allpoints: PVector3Single; const box: TBox3d); |
|
Calculates eight corners of the box, placing them in AllPointsˆ[0..7]. |
function BoundingBoxTransform(const bbox: TBox3d; const Matrix: TMatrix4Single): TBox3d; |
|
Transforms the box by given matrix. More precisely, transforms all 8 box corners, and makes new box enclosing these 8 points. Since this is axis-aligned box, rotating etc. of the box usually makes larger box (this is the primary disadvantage of axis-aligned boxes, as opposed to oriented boxes). |
function Box3dTranslate(const Box: TBox3d; const Translation: TVector3Single): TBox3d; |
|
Move Box. Does nothing if Box is empty. |
function Box3dAntiTranslate(const Box: TBox3d; const Translation: TVector3Single): TBox3d; |
|
Move Box, by -Translation. Does nothing if Box is empty. |
function Box3dToNiceStr(const box: TBox3d): string; |
function Box3dToRawStr(const box: TBox3d): string; |
procedure Box3dClamp(var point: TVector3Single; const box: TBox3d); overload; |
procedure Box3dClamp(var point: TVector3Double; const box: TBox3d); overload; |
function TriangleBoundingBox(const T: TTriangle3Single): TBox3d; |
function TryBoxRayClosestIntersection( out Intersection: TVector3Single; out IntersectionDistance: Single; const Box: TBox3d; const Ray0, RayVector: TVector3Single): boolean; overload; |
|
TryBoxRayClosestIntersection calculates intersection between the ray (returns closest intersection to Ray0) and the box. The box is treated just like a set of 6 rectangles in 3D. This means that the intersection will always be placed on one of the box sides, even if Ray0 starts inside the box. See TryBoxRayEntrance for the other version. Returns also IntersectionDistance, which is the distance to the Intersection relative to RayVector (i.e. Intersection is always = Ray0 + IntersectionDistance * RayVector). |
function TryBoxRayClosestIntersection( out Intersection: TVector3Single; const Box: TBox3d; const Ray0, RayVector: TVector3Single): boolean; overload; |
function TryBoxRayClosestIntersection( out IntersectionDistance: Single; const Box: TBox3d; const Ray0, RayVector: TVector3Single): boolean; overload; |
function TryBoxRayEntrance(out Entrance: TVector3Single; const Box: TBox3d; const Ray0, RayVector: TVector3Single): boolean; |
|
This means that if Ray0 is inside the box, |
function IsBox3dSegmentCollision( const Box: TBox3d; const Segment1, Segment2: TVector3Single): boolean; |
function IsCenteredBox3dPlaneCollision( const BoxHalfSize: TVector3Single; const Plane: TVector4Single): boolean; overload; |
|
Tests for collision between box3d centered around (0, 0, 0) and a plane. Note that you can't express empty box3d here: all BoxHalfSize items must be >= 0. The case when size = 0 is considered like infintely small box in some dimension (e.g. if all three sizes are = 0 then the box becomes a point). |
function IsCenteredBox3dPlaneCollision( const BoxHalfSize: TVector3Double; const Plane: TVector4Double): boolean; overload; |
function IsBox3dPlaneCollision(const Box3d: TBox3d; const Plane: TVector4Single): boolean; |
function IsBox3dTriangleCollision( const Box: TBox3d; const Triangle: TTriangle3Single): boolean; |
function FrustumBox3dCollisionPossible(const Frustum: TFrustum; const Box: TBox3d): TFrustumCollisionPossible; |
|
This is equivalent to FrustumSphereCollisionPossible, but here it takes a box instead of a sphere. |
function FrustumBox3dCollisionPossibleSimple(const Frustum: TFrustum; const Box: TBox3d): boolean; |
|
This is like FrustumBox3dCollisionPossible but it returns true when FrustumBox3dCollisionPossible would return fcSomeCollisionPossible or fcInsideFrustum. Otherwise (when FrustumBox3dCollisionPossible would return fcNoCollision) this returns false. So this returns less detailed result, but is a little faster. |
procedure Box3dBoundingSphere(const Box3d: TBox3d; var SphereCenter: TVector3Single; var SphereRadiusSqr: Single); |
|
This calculates smallest possible sphere completely enclosing given Box. SphereRadiusSqr = 0 and SphereCenter is undefined if Box is empty. |
function Boxes3dCollision(const Box1, Box2: TBox3d): boolean; |
function Boxes3dXYCollision(const Box1, Box2: TBox3d): boolean; |
|
This is just like Boxes3dCollision, but it takes into account only XY plane. I.e. it works like Box1 and Box2 are infinitely large in the Z coordinate. Or, in other words, this actually checks collision of 2D rectangles obtained by projecting both boxes on plane XY. |
function Box3dSqrRadius(const Box: TBox3d): Single; |
|
This calculates maximum Sqr(distance) of 8 box points to the (0, 0, 0) point. This can be useful when you want to get bounding sphere, centered in (0, 0, 0), around this Box. |
function Box3dRadius(const Box: TBox3d): Single; |
|
Just like Box3dSqrRadius, but this returns correct value (not it's Sqr). Speed note: you pay here one Sqrt operation. |
function Box3dXYSqrRadius(const Box: TBox3d): Single; |
|
This is like projecting Box on XY plane (that is, we just ignore Z coords of Box points here), and then calculates maximum Sqr(distance) in plane XY of 4 Box corners to point (0, 0). |
function Box3dXYRadius(const Box: TBox3d): Single; |
|
Just like Box3dXYSqrRadius, but this returns correct value (not it's Sqr). Speed note: you pay here one Sqrt operation. |
function Box3dSphereSimpleCollision(const Box: TBox3d; const SphereCenter: TVector3Single; const SphereRadius: Single): boolean; |
|
Check for collision betweeb box and sphere, fast but not entirely correct. This considers a Box enlarged by SphereRadius in each direction. Then checks whether SphereRadius is inside such enlarged Box. So this check will incorrectly report collision while in fact there's no collision in the case when the Sphere is very near the edge of the Box. So this check is not 100% correct. But often this is good enough — in games, if you know that the SphereRadius is going to be relatively small compared to the Box, this may be perfectly acceptable. And it's fast. |
function Box3dSphereCollision(const Box: TBox3d; const SphereCenter: TVector3Single; const SphereRadius: Single): boolean; |
|
Check for box <-> sphere collision. This is a little slower than Box3dSphereSimpleCollision, although still damn fast, and it's a precise check. |
TBox3d = array[0..1]of TVector3Single; |
|
Axis-aligned box. Rectangular prism with all sides parallel to basic planes X = 0, Y = 0 and Z = 0. This is sometimes called AABB, "axis-aligned bounding box". This is a handy type, because it's easy to implement many operations on it in a fast manner. First point always has all the smaller coords, second point has all the larger coords. I.e. always Box[0, 0] <= Box[1, 0] and Box[0, 1] <= Box[1, 1] and Box[0, 2] <= Box[1, 2] The only exception is the special value EmptyBox3d. |
PBox3d = ˆTBox3d; |
TGetIndexFromIndexNumFunc = function(indexNum: integer): integer of object; |
TGetVertexFromIndexFunc = function(index: integer): TVector3Single of object; |
TDynArrayItem_1 = TBox3d; |
PDynArrayItem_1 = PBox3d; |
TInfiniteArray_1 = array[0..MaxInt div SizeOf(TDynArrayItem_1)-1]of TDynArrayItem_1; |
PInfiniteArray_1 = ˆTInfiniteArray_1; |
TDynArrayItemIsSmallerFunc_1 = function (const a, b: TDynArrayItem_1): boolean; |
TDynArrayItemIsSmallerFuncByObject_1 = function (const a, b: TDynArrayItem_1): boolean of object; |
TArray_Box3d = TInfiniteArray_1; |
PArray_Box3d = PInfiniteArray_1; |
TDynBox3dArray = TDynArray_1; |
EmptyBox3d: TBox3d = ((0, 0, 0), (-1, -1, -1)); |
|
Special value for TBox3d meaning "bounding box doesn't exist". This is used when the object has no points, so bounding box doesn't exist. |