   SparkSL
SparkSL API
Utils

## Utils

` #import <utils>`

` std`

### Declarations

``` // Functions
vec2 safeNormalize(vec2 v);
vec3 safeNormalize(vec3 v);
vec4 safeNormalize(vec4 v);
float safeLength(vec2 v);
float safeLength(vec3 v);
float safeLength(vec4 v);
float safeDistance(vec2 p0, vec2 p1);
float safeDistance(vec3 p0, vec3 p1);
float safeDistance(vec4 p0, vec4 p1);
float safeAtan(float y, float x);
```

### Functions

safeNormalize

Normalize a vector, protecting against overflow in the intermediate computations.

Declaration(s):

```
vec2 safeNormalize(vec2 v);
vec3 safeNormalize(vec3 v);
vec4 safeNormalize(vec4 v);
```

safeLength

Compute the length of a vector, protecting against overflow in the intermediate computations.

Declaration(s):

```
float safeLength(vec2 v);
float safeLength(vec3 v);
float safeLength(vec4 v);
```

safeDistance

Compute the distance between two points, protecting against overflow in the intermediate computations.

Declaration(s):

```
float safeDistance(vec2 p0, vec2 p1);
float safeDistance(vec3 p0, vec3 p1);
float safeDistance(vec4 p0, vec4 p1);
```

safeAtan

Compute the atan between x and y. Unlike regular atan, this function provides results for x = 0.0.

Declaration(s):

` float safeAtan(float y, float x);`