---
title: "ray(through:in:to:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/realitycoordinatespaceprojecting/ray(through:in:to:)"
---

# ray(through:in:to:)

Determines the position and direction of a ray through the given point in the 2D space of the view.

## Declaration

```swift
func ray(through point: CGPoint, in space: some CoordinateSpaceProtocol, to realitySpace: some RealityCoordinateSpace) -> (origin: SIMD3<Float>, direction: SIMD3<Float>)?
```

## Parameters

- `point`: A point in the provided coordinate space.
- `space`: The 2D coordinate space in which to interpret the point.
- `realitySpace`: The 3D coordinate space you want the returned ray in.

## Return Value

Return Value A 3D ray, expressed in the realitySpace coordinate space, which starts at the camera position and passes through the specified point.
