---
title: "unitVector(for:)"
framework: vision
role: symbol
role_heading: Type Method
path: "vision/vnvector/unitvector(for:)"
---

# unitVector(for:)

Calculates a vector that’s normalized by preserving its direction, so that the vector length equals 1.0.

## Declaration

```swift
class func unitVector(for vector: VNVector) -> VNVector
```

## Parameters

- `vector`: The vector whose unit vector you want to calculate.

## Return Value

Return Value The unit vector.

## See Also

### Inspecting a Vector

- [length](vision/vnvector/length.md)
- [r](vision/vnvector/r.md)
- [theta](vision/vnvector/theta.md)
- [squaredLength](vision/vnvector/squaredlength.md)
- [x](vision/vnvector/x.md)
- [y](vision/vnvector/y.md)
- [dotProduct(of:vector:)](vision/vnvector/dotproduct(of:vector:).md)
