<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Spatial",
  "identifier" : "/documentation/Spatial/Rect3D",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Spatial"
    ],
    "preciseIdentifier" : "c:@SA@SPRect3D"
  },
  "title" : "Rect3D"
}
-->

# Rect3D

A rectangle in a 3D coordinate system.

```
struct Rect3D
```

## Topics

### Creating a 3D rectangle structure

[`init()`](/documentation/Spatial/Rect3D/init())

Creates a rectangle structure.

[`init(center: Point3D, size: Size3D)`](/documentation/Spatial/Rect3D/init(center:size:)-133fy)

Creates a rectangle with the specified center and the specified size from Spatial structures.

[`init(center: simd_double3, size: simd_double3)`](/documentation/Spatial/Rect3D/init(center:size:)-77l0z)

Creates a rectangle with the specified center and the specified size from double-precision vectors.

[`init(center: Vector3D, size: Vector3D)`](/documentation/Spatial/Rect3D/init(center:size:)-9cfq7)

Creates a rectangle with the specified center and the specified size from Spatial vectors.

[`init(center: simd_float3, size: simd_float3)`](/documentation/Spatial/Rect3D/init(center:size:)-zr2x)

Creates a rectangle with the specified center and the specified size from single-precision vectors.

[`init(origin: simd_double3, size: simd_double3)`](/documentation/Spatial/Rect3D/init(origin:size:)-5xyrs)

Creates a rectangle at the specified origin with the specified size from double-precision vectors.

[`init(origin: simd_float3, size: simd_float3)`](/documentation/Spatial/Rect3D/init(origin:size:)-7fnuf)

Creates a rectangle at the specified origin with the specified size from single-precision vectors.

[`init(origin: Vector3D, size: Vector3D)`](/documentation/Spatial/Rect3D/init(origin:size:)-7o8ad)

Creates a rectangle with the specified origin and the specified size from Spatial vectors.

[`init(origin: Point3D, size: Size3D)`](/documentation/Spatial/Rect3D/init(origin:size:)-7v73)

Creates a rectangle at the specified origin and the specified size from Spatial structures.

[`init(origin: Point3D, size: Size3D)`](/documentation/Spatial/Rect3D/init(origin:size:)-9a089)

Creates a rectangle structure.

[`init(points: [Point3D])`](/documentation/Spatial/Rect3D/init(points:))

Creates a rectangle that’s the bounding box of the specified points.

[`static SPRect3D SPRect3DMakeAtCenterWithVector(simd_double3 center, simd_double3 size);`](/documentation/Spatial/SPRect3DMakeAtCenterWithVector-9118a)

Creates a rectangle with the specified center and the specified size from double-precision vectors.

[`static SPRect3D SPRect3DMakeAtCenterWithVector(SPVector3D center, SPVector3D size);`](/documentation/Spatial/SPRect3DMakeAtCenterWithVector-9doe4)

[`static SPRect3D SPRect3DMakeAtOriginWithVector(simd_double3 origin, simd_double3 size);`](/documentation/Spatial/SPRect3DMakeAtOriginWithVector-36awh)

Creates a rectangle at the specified origin and the specified size from double-precision vectors.

[`static SPRect3D SPRect3DMakeAtOriginWithVector(SPVector3D origin, SPVector3D size);`](/documentation/Spatial/SPRect3DMakeAtOriginWithVector-7m66h)

[`static SPRect3D SPRect3DMakeBoundingFromPoints(SPPoint3D points[], int pointCount);`](/documentation/Spatial/SPRect3DMakeBoundingFromPoints)

Creates a rectangle that’s the bounding box of the specified points.

### Constants

[`static const SPRect3D SPRect3DNull;`](/documentation/Spatial/SPRect3DNull)

The null rectangle that represents an invalid value.

[`static const SPRect3D SPRect3DInfinity;`](/documentation/Spatial/SPRect3DInfinity)

The rectangle structure with infinite origin and size.

[`static const SPRect3D SPRect3DZero;`](/documentation/Spatial/SPRect3DZero)

The rectangle structure with the zero value.

### Inspecting a 3D rectangle’s properties

[`var center: Point3D`](/documentation/Spatial/Rect3D/center)

The center of the rectangle.

[`var cornerPoints: [Point3D]`](/documentation/Spatial/Rect3D/cornerPoints)

The corner points of the rectangle.

[`var max: Point3D`](/documentation/Spatial/Rect3D/max)

A point that represents the corner of the rectangle with the largest x-, y-, and z-coordinates.

[`var min: Point3D`](/documentation/Spatial/Rect3D/min)

A point that represents the corner of the rectangle with the smallest x-, y-, and z-coordinates.

[`var origin: Point3D`](/documentation/Spatial/Rect3D/origin)

The origin of the rectangle.

[`SPSize3D size;`](/documentation/Spatial/SPRect3D/size)

The size of the rectangle.

[`static void SPRect3DGetCornerPoints(SPRect3D rect, SPPoint3D points[]);`](/documentation/Spatial/SPRect3DGetCornerPoints)

Returns the corner points of the rectangle.

### Transforming a 3D rectangle structure

[`func applying(Pose3D) -> Rect3D`](/documentation/Spatial/Rect3D/applying(_:)-3qdiy)

Returns a rectangle that results from applying the specified pose.

[`func applying(ScaledPose3D) -> Rect3D`](/documentation/Spatial/Rect3D/applying(_:)-5hnif)

Returns a rectangle that’s transformed by the specified scaled pose.

[`func applying(ScaledPose3D) -> Rect3D`](/documentation/Spatial/Rect3D/applying(_:)-5hnif)

Returns a rectangle that’s transformed by the specified scaled pose.

[`func rotated(by: Rotation3D, around: Point3D) -> Rect3D`](/documentation/Spatial/Rect3D/rotated(by:around:)-3ih62)

Returns a rectangle that results from applying the specified rotation around a pivot point.

[`func rotated(by: simd_quatd, around: Point3D) -> Rect3D`](/documentation/Spatial/Rect3D/rotated(by:around:)-8g1c9)

Returns a rectangle that results from rotating with the specified quaternion around a pivot point.

[`func scaledBy(x: Double, y: Double, z: Double) -> Rect3D`](/documentation/Spatial/Rect3D/scaledBy(x:y:z:))

Returns a rectangle that results from scaling with the specified double-precision values.

[`func sheared(AxisWithFactors) -> Rect3D`](/documentation/Spatial/Rect3D/sheared(_:))

Returns a rectangle that results from shearing over an axis by shear factors for the other two axes.

[`static SPRect3D SPRect3DApplyAffineTransform(SPRect3D rect, SPAffineTransform3D transform);`](/documentation/Spatial/SPRect3DApplyAffineTransform)

Returns a rectangle that results from applying the specified affine transform.

[`static SPRect3D SPRect3DApplyPose(SPRect3D rect, SPPose3D pose);`](/documentation/Spatial/SPRect3DApplyPose)

Returns a rectangle that results from applying the specified pose.

[`static SPRect3D SPRect3DApplyProjectiveTransform(SPRect3D rect, SPProjectiveTransform3D transform);`](/documentation/Spatial/SPRect3DApplyProjectiveTransform)

[`static SPRect3D SPRect3DApplyScaledPose(SPRect3D rect, SPScaledPose3D pose);`](/documentation/Spatial/SPRect3DApplyScaledPose)

Returns a rectangle that’s transformed by the specified scaled pose.

[`static SPRect3D SPRect3DRotate(SPRect3D rect, SPRotation3D rotation);`](/documentation/Spatial/SPRect3DRotate)

Returns a rectangle that results from applying the specified rotation.

[`static SPRect3D SPRect3DRotateByQuaternion(SPRect3D rect, simd_quatd quaternion);`](/documentation/Spatial/SPRect3DRotateByQuaternion)

Returns a rectangle that results from rotating with the specified quaternion.

[`static SPRect3D SPRect3DScaleBy(SPRect3D rect, double x, double y, double z);`](/documentation/Spatial/SPRect3DScaleBy)

Returns a rectangle that results from scaling with the specified double-precision values.

[`static SPRect3D SPRect3DScaleBySize(SPRect3D rect, SPSize3D scale);`](/documentation/Spatial/SPRect3DScaleBySize)

Returns a rectangle that results from scaling with the specified size structure.

[`static SPRect3D SPRect3DScaleUniform(SPRect3D rect, double scale);`](/documentation/Spatial/SPRect3DScaleUniform)

Returns a rectangle that results from uniformly scaling with the specified double-precision value.

[`static SPRect3D SPRect3DShear(SPRect3D rect, SPAxis shearAxis, double shearFactor0, double shearFactor1);`](/documentation/Spatial/SPRect3DShear)

Returns a rectangle that results from shearing over an axis by shear factors for the other two axes.

[`static SPRect3D SPRect3DTranslate(SPRect3D rect, SPVector3D offset);`](/documentation/Spatial/SPRect3DTranslate-88ujj)

Returns a rectangle with an origin that’s offset by the specified vector.

[`static SPRect3D SPRect3DTranslate(SPRect3D rect, SPSize3D offset);`](/documentation/Spatial/SPRect3DTranslate-8amf1)

Returns a rectangle with an origin that’s offset by the specified size.

[`static SPRect3D SPRect3DUnapplyAffineTransform(SPRect3D rect, SPAffineTransform3D transform);`](/documentation/Spatial/SPRect3DUnapplyAffineTransform)

Returns a rectangle that results from unapplying the specified affine transform.

[`static SPRect3D SPRect3DUnapplyPose(SPRect3D rect, SPPose3D pose);`](/documentation/Spatial/SPRect3DUnapplyPose)

Returns a rectangle that results from unapplying the specified pose.

[`static SPRect3D SPRect3DUnapplyProjectiveTransform(SPRect3D rect, SPProjectiveTransform3D transform);`](/documentation/Spatial/SPRect3DUnapplyProjectiveTransform)

Returns a rectangle that results from applying the specified projective transform.

[`static SPRect3D SPRect3DUnapplyScaledPose(SPRect3D rect, SPScaledPose3D pose);`](/documentation/Spatial/SPRect3DUnapplyScaledPose)

Returns a rectangle that’s transformed by the inverse of the specified scaled pose.

[`func unapplying(ProjectiveTransform3D) -> Rect3D`](/documentation/Spatial/Rect3D/unapplying(_:)-1j6g7)

Returns a rectangle that results from unapplying the specified projective transform.

[`func unapplying(ScaledPose3D) -> Rect3D`](/documentation/Spatial/Rect3D/unapplying(_:)-1pbfn)

Returns a rectangle that’s transformed by the inverse of the specified scaled pose.

[`func unapplying(Pose3D) -> Rect3D`](/documentation/Spatial/Rect3D/unapplying(_:)-2he5i)

Returns a rectangle that results from unapplying the specified pose.

[`func unapplying(AffineTransform3D) -> Rect3D`](/documentation/Spatial/Rect3D/unapplying(_:)-7eglq)

Returns a rectangle that results from unapplying the specified affine transform.

### Checking characteristics

[`func contains(anyOf: [Point3D]) -> Bool`](/documentation/Spatial/Rect3D/contains(anyOf:))

Returns a Boolean value that indicates whether the rectangle contains any of the specified points.

[`func intersects(Rect3D) -> Bool`](/documentation/Spatial/Rect3D/intersects(_:))

Returns a Boolean value that indicates whether two rectangles intersect.

[`var isEmpty: Bool`](/documentation/Spatial/Rect3D/isEmpty)

A Boolean value that indicates whether two or three of the dimensions are zero.

[`static bool SPRect3DContainsAnyPoint(SPRect3D rect, const SPPoint3D *points, int pointCount);`](/documentation/Spatial/SPRect3DContainsAnyPoint)

Returns a Boolean value that indicates whether the rectangle contains any of the specified points.

[`static bool SPRect3DContainsPoint(SPRect3D rect, SPPoint3D other);`](/documentation/Spatial/SPRect3DContainsPoint)

Returns a Boolean value that indicates whether the rectangle contains the specified point.

[`static bool SPRect3DContainsRect(SPRect3D rect, SPRect3D other);`](/documentation/Spatial/SPRect3DContainsRect)

Returns a Boolean value that indicates whether the rectangle contains the specified rectangle.

[`static double SPRect3DDistanceToRect(SPRect3D rect, SPRect3D other);`](/documentation/Spatial/SPRect3DDistanceToRect)

[`static bool SPRect3DIsFinite(SPRect3D rect);`](/documentation/Spatial/SPRect3DIsFinite)

A Boolean value that indicates whether all of the coordinates and dimensions of the rectangle are finite.

[`static bool SPRect3DIsNaN(SPRect3D rect);`](/documentation/Spatial/SPRect3DIsNaN)

A Boolean value that indicates whether any of the coordinates and dimensions of the rectangle are NaN.

[`static bool SPRect3DIsNull(SPRect3D rect);`](/documentation/Spatial/SPRect3DIsNull)

A Boolean value that indicates whether the rectangle is equal to the null rectangle.

[`static bool SPRect3DIsZero(SPRect3D rect);`](/documentation/Spatial/SPRect3DIsZero)

A Boolean value that indicates whether the rectangle’s origin and size are zero.

### Creating derived 3D rectangles

[`var integral: Rect3D`](/documentation/Spatial/Rect3D/integral)

Returns the smallest rectangle after converting the source rectangle values to integers.

[`func formInset(by: Size3D)`](/documentation/Spatial/Rect3D/formInset(by:))

Insets the rectangle by the specified size.

[`func inset(by: Size3D) -> Rect3D`](/documentation/Spatial/Rect3D/inset(by:))

Returns a new rectangle with the same center point after applying the specified inset amount.

[`func intersection(Rect3D) -> Rect3D?`](/documentation/Spatial/Rect3D/intersection(_:))

Returns the intersection of two rectangles.

[`var standardized: Rect3D`](/documentation/Spatial/Rect3D/standardized)

A rectangle with positive dimensions.

[`static SPRect3D SPRect3DIntersection(SPRect3D rect, SPRect3D other);`](/documentation/Spatial/SPRect3DIntersection)

Returns the intersection of two rectangles.

[`static SPRect3D SPRect3DUnion(SPRect3D rect, SPRect3D other);`](/documentation/Spatial/SPRect3DUnion)

Returns the smallest rectangle that contains two rectangles.

### Comparing values

[`static func == (Rect3D, Rect3D) -> Bool`](/documentation/Spatial/Rect3D/==(_:_:))

Returns a Boolean value that indicates whether two values are equal.

[`static bool SPRect3DEqualToRect(SPRect3D rect1, SPRect3D rect2);`](/documentation/Spatial/SPRect3DEqualToRect)

Returns a Boolean value that indicates whether two values are equal.

### Applying arithmetic operations

[`static func * (AffineTransform3D, Rect3D) -> Rect3D`](/documentation/Spatial/Rect3D/*(_:_:)-8710d)

Returns the rectangle that results from applying the affine transform to the rectangle.

[`static func * (ProjectiveTransform3D, Rect3D) -> Rect3D`](/documentation/Spatial/Rect3D/*(_:_:)-8vu0)

Returns the rectangle that results from applying the projective transform to the rectangle.

[`static func * (Pose3D, Rect3D) -> Rect3D`](/documentation/Spatial/Rect3D/*(_:_:)-5lqdv)

Returns a new rectangle after applying the pose to the rectangle.

### Deprecated symbols

[`func distance(to: Rect3D) -> Double`](/documentation/Spatial/Rect3D/distance(to:))

Returns the distance between the origins of two rectangle.

[`func containsAny(of: [Point3D]) -> Bool`](/documentation/Spatial/Rect3D/containsAny(of:))

Returns a Boolean value that indicates whether the rectangle contains any of the specified points.

[`func rotation(to: Rect3D) -> Rotation3D`](/documentation/Spatial/Rect3D/rotation(to:))

Returns the rotation around @p (0,0,0)  from the first rectangle to the second rectangle.

[`var maxX: Double`](/documentation/Spatial/Rect3D/maxX)

[`var maxY: Double`](/documentation/Spatial/Rect3D/maxY)

[`var maxZ: Double`](/documentation/Spatial/Rect3D/maxZ)

[`var midX: Double`](/documentation/Spatial/Rect3D/midX)

[`var midY: Double`](/documentation/Spatial/Rect3D/midY)

[`var midZ: Double`](/documentation/Spatial/Rect3D/midZ)

[`var minX: Double`](/documentation/Spatial/Rect3D/minX)

[`var minY: Double`](/documentation/Spatial/Rect3D/minY)

[`var minZ: Double`](/documentation/Spatial/Rect3D/minZ)

[`static SPRect3D SPRect3DTranslate(SPRect3D rect, SPSize3D offset);`](/documentation/Spatial/SPRect3DTranslate-8amf1)

Returns a rectangle with an origin that’s offset by the specified size.

[`static double SPRect3DDistanceBetweenOrigins(SPRect3D rect, SPRect3D other);`](/documentation/Spatial/SPRect3DDistanceBetweenOrigins)

Returns the distance between the origins of two rectangles.

[`static SPRotation3D SPRect3DRotationToRect(SPRect3D rect, SPRect3D other);`](/documentation/Spatial/SPRect3DRotationToRect)

Returns the rotation around the origin from the first rectangle to the second rectangle.

### Initializers

[`init(Rect3DFloat)`](/documentation/Spatial/Rect3D/init(_:)-3wm4y)

Returns a double-precision rectangle from a single-precision rectangle.

[`init(BoundingBox)`](/documentation/Spatial/Rect3D/init(_:)-b16k)

### Default Implementations

[CustomReflectable Implementations](/documentation/Spatial/Rect3D/CustomReflectable-Implementations)

[Decodable Implementations](/documentation/Spatial/Rect3D/Decodable-Implementations)

[Encodable Implementations](/documentation/Spatial/Rect3D/Encodable-Implementations)

[Equatable Implementations](/documentation/Spatial/Rect3D/Equatable-Implementations)

[Hashable Implementations](/documentation/Spatial/Rect3D/Hashable-Implementations)

[Primitive3DProtocol Implementations](/documentation/Spatial/Rect3D/Primitive3DProtocol-Implementations)

[Scalable3DProtocol Implementations](/documentation/Spatial/Rect3D/Scalable3DProtocol-Implementations)

[Shearable3D Implementations](/documentation/Spatial/Rect3D/Shearable3D-Implementations)

[Volumetric Implementations](/documentation/Spatial/Rect3D/Volumetric-Implementations)

[VolumetricProtocol Implementations](/documentation/Spatial/Rect3D/VolumetricProtocol-Implementations)

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Equatable`](/documentation/Swift/Equatable)

[`Rotatable3D`](/documentation/Spatial/Rotatable3D)

[`Sendable`](/documentation/Swift/Sendable)

[`Primitive3D`](/documentation/Spatial/Primitive3D)

[`Encodable`](/documentation/Swift/Encodable)

[`SpatialTypeProtocol`](/documentation/Spatial/SpatialTypeProtocol)

[`Escapable`](/documentation/Swift/Escapable)

[`Hashable`](/documentation/Swift/Hashable)

[`Translatable3D`](/documentation/Spatial/Translatable3D)

[`Volumetric`](/documentation/Spatial/Volumetric)

[`Rotatable3DProtocol`](/documentation/Spatial/Rotatable3DProtocol)

[`Translatable3DProtocol`](/documentation/Spatial/Translatable3DProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Scalable3D`](/documentation/Spatial/Scalable3D)

[`ProjectiveTransformable3D`](/documentation/Spatial/ProjectiveTransformable3D)

[`Copyable`](/documentation/Swift/Copyable)

[`Scalable3DProtocol`](/documentation/Spatial/Scalable3DProtocol)

[`CustomReflectable`](/documentation/Swift/CustomReflectable)

[`Shearable3D`](/documentation/Spatial/Shearable3D)

[`Primitive3DProtocol`](/documentation/Spatial/Primitive3DProtocol)

[`Decodable`](/documentation/Swift/Decodable)

[`VolumetricProtocol`](/documentation/Spatial/VolumetricProtocol)

[`Animatable`](/documentation/SwiftUI/Animatable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)