<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/UnitPoint3D",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11UnitPoint3DV"
  },
  "title" : "UnitPoint3D"
}
-->

# UnitPoint3D

A normalized 3D point in a view’s coordinate space.

```
@frozen struct UnitPoint3D
```

## Overview

Use a 3D unit point to represent a three-dimensional location in a view
without having to know the view’s rendered size. The point stores a value
in each dimension that indicates the fraction of the view’s size in that
dimension — measured from the view’s origin — where the point appears.
For example, you can create a unit point that represents the center of any
view by using the value `0.5` for each dimension:

```
let unitPoint = UnitPoint3D(x: 0.5, y: 0.5, z: 0.5)
```

> Note: If you need a two-dimensional unit point, use ``doc://com.apple.SwiftUI/documentation/SwiftUI/UnitPoint`` instead.

To project the unit point into the rendered view’s coordinate space,
multiply each component of the unit point with the corresponding
component of the view’s size:

```
let projectedPoint = Point3D(
    x: unitPoint.x * size.width,
    y: unitPoint.y * size.height,
    z: unitPoint.z * size.depth
)
```

You can perform this calculation yourself if you happen to know a view’s
size, or if you want to use a unit point for some custom purpose, but
SwiftUI typically does this for you to carry out operations that
you request, like when you rotate a view with the
[`rotation3DEffect(_:anchor:)`](/documentation/SwiftUI/View/rotation3DEffect(_:anchor:)) modifier and indicate the anchor point
that you want to rotate the view around.

You can create custom unit points with explicit values, like the example
above, or you can use one of the built-in unit points that SwiftUI provides,
like [`zero`](/documentation/SwiftUI/UnitPoint3D/zero), [`center`](/documentation/SwiftUI/UnitPoint3D/center), or [`topTrailing`](/documentation/SwiftUI/UnitPoint3D/topTrailing). The built-in values
correspond to common anchor points that you might want to refer to, like
the center of one of a view’s edges.

> Note: A unit point with one or more components outside the range `[0, 1]`
> projects to a point outside of the view.

### Layout direction

When a person configures their device to use a left-to-right language like
English, the system places the view’s origin in its top-left-back corner,
with positive x toward the right, positive y toward the bottom of the
view, and positive z toward the front. In a right-to-left environment, the
origin moves to the upper-right-back corner, and the positive x direction
changes to be toward the left. You don’t typically need to do anything to
handle this change, because SwiftUI applies the change to all aspects of the
system. For example, see the discussion about layout direction in
[`HorizontalAlignment`](/documentation/SwiftUI/HorizontalAlignment).

It’s important to test your app for the different locales that you
distribute your app in. For more information about the localization process,
see <doc://com.apple.documentation/documentation/Xcode/localization>.

## Topics

### Getting the origin

[`origin`](/documentation/SwiftUI/UnitPoint3D/origin)

The origin of a view.

[`zero`](/documentation/SwiftUI/UnitPoint3D/zero)

A 3D unit point with all components equal to zero.

### Getting top points

[`topLeadingBack`](/documentation/SwiftUI/UnitPoint3D/topLeadingBack)

A point that’s in the top-leading-back corner of a view.

[`topLeading`](/documentation/SwiftUI/UnitPoint3D/topLeading)

A point that’s centered in the depth dimension on the top-leading
edge of a view.

[`topLeadingFront`](/documentation/SwiftUI/UnitPoint3D/topLeadingFront)

A point that’s in the top-leading-front corner of a view.

[`topBack`](/documentation/SwiftUI/UnitPoint3D/topBack)

A point that’s centered horizontally on the top-back edge of a view.

[`top`](/documentation/SwiftUI/UnitPoint3D/top)

A point that’s centered horizontally and in the depth dimension
on the top face of a view.

[`topFront`](/documentation/SwiftUI/UnitPoint3D/topFront)

A point that’s centered horizontally on the top-front edge of a view.

[`topTrailingBack`](/documentation/SwiftUI/UnitPoint3D/topTrailingBack)

A point that’s in the top-trailing-back corner of a view.

[`topTrailing`](/documentation/SwiftUI/UnitPoint3D/topTrailing)

A point that’s centered in the depth dimension on the top-trailing
edge of a view.

[`topTrailingFront`](/documentation/SwiftUI/UnitPoint3D/topTrailingFront)

A point that’s in the top-trailing-front corner of a view.

### Getting middle points

[`leadingBack`](/documentation/SwiftUI/UnitPoint3D/leadingBack)

A point that’s centered vertically on the leading-back edge of a view.

[`leading`](/documentation/SwiftUI/UnitPoint3D/leading)

A point that’s centered vertically and in the depth dimension
on the leading face of a view.

[`leadingFront`](/documentation/SwiftUI/UnitPoint3D/leadingFront)

A point that’s centered vertically on the leading-front edge of a view.

[`back`](/documentation/SwiftUI/UnitPoint3D/back)

A point that’s centered horizontally and vertically
on the back face of a view.

[`center`](/documentation/SwiftUI/UnitPoint3D/center)

A point that’s centered in a view.

[`front`](/documentation/SwiftUI/UnitPoint3D/front)

A point that’s centered horizontally and vertically
on the front face of a view.

[`trailingBack`](/documentation/SwiftUI/UnitPoint3D/trailingBack)

A point that’s centered vertically on the trailing-back edge of a view.

[`trailing`](/documentation/SwiftUI/UnitPoint3D/trailing)

A point that’s centered vertically and in the depth dimension
on the trailing face of a view.

[`trailingFront`](/documentation/SwiftUI/UnitPoint3D/trailingFront)

A point that’s centered vertically on the trailing-front edge of a
view.

### Getting bottom points

[`bottomLeadingBack`](/documentation/SwiftUI/UnitPoint3D/bottomLeadingBack)

A point that’s in the bottom-leading-back corner of a view.

[`bottomLeading`](/documentation/SwiftUI/UnitPoint3D/bottomLeading)

A point that’s centered in the depth dimension on the bottom-leading
edge of a view.

[`bottomLeadingFront`](/documentation/SwiftUI/UnitPoint3D/bottomLeadingFront)

A point that’s in the bottom-leading-front corner of a view.

[`bottomBack`](/documentation/SwiftUI/UnitPoint3D/bottomBack)

A point that’s centered horizontally on the bottom-back edge of a view.

[`bottom`](/documentation/SwiftUI/UnitPoint3D/bottom)

A point that’s centered horizontally and in the depth dimension
on the bottom face of a view.

[`bottomFront`](/documentation/SwiftUI/UnitPoint3D/bottomFront)

A point that’s centered horizontally on the bottom-front edge of a view.

[`bottomTrailingBack`](/documentation/SwiftUI/UnitPoint3D/bottomTrailingBack)

A point that’s in the bottom-trailing-back corner of a view.

[`bottomTrailing`](/documentation/SwiftUI/UnitPoint3D/bottomTrailing)

A point that’s centered in the depth dimension on the bottom-trailing
edge of a view.

[`bottomTrailingFront`](/documentation/SwiftUI/UnitPoint3D/bottomTrailingFront)

A point that’s in the bottom-trailing-front corner of a view.

### Creating a point

[`init()`](/documentation/SwiftUI/UnitPoint3D/init())

Creates a 3D unit point at the origin.

[`init(x:y:z:)`](/documentation/SwiftUI/UnitPoint3D/init(x:y:z:))

Creates a 3D unit point with the specified offsets.

### Getting the point’s coordinates

[`x`](/documentation/SwiftUI/UnitPoint3D/x)

The normalized distance from the origin to the point in the horizontal
direction.

[`y`](/documentation/SwiftUI/UnitPoint3D/y)

The normalized distance from the origin to the point in the vertical
dimension.

[`z`](/documentation/SwiftUI/UnitPoint3D/z)

The normalized distance from the origin to the point in the depth
dimension.



---

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)