# JoyOfVex10

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

### relpointbbox

I mentioned earlier that normalising values makes a lot of operations easier, saves you having to mentally scale values to match. This is easy for normals, but you can't just do normalize(@P), you'll get unexpected results (try it on a pig or tommy):

```@P = normalize(@P);
```

Vex gives you another handy function, relpointbbox. That mouthful means it puts a bounding box around your shape, sets the lower left corner as 0,0,0, upper right as 1,1,1, and returns where each point is relative to that bounding box. Easier to see mapped to colour than to explain:

```@Cd = relpointbbox(@P);
```

If you store this in an array first, you have a nice quick way to get a clean 0 to 1 gradient across, from top to bottom, or front to back:

```vector bbox = relpointbbox(0,@P);
@Cd = bbox.y;
```

So now its easy to inflate the mesh on its normals, ramped from top to bottom:

```vector bbox = relpointbbox(0,@P);
@P += @N*bbox.y*ch('scale');
```

Or drive it with a chramp, so you can puff it out halfway, and fade it at the ends:

```vector bbox = relpointbbox(0,@P);
float i = chramp('inflate',bbox.y);
@P += @N*i*ch('scale');
```

And whats handy is you can scale the geo before it goes into the wrangle, and the effect will work regardless of scale.

Exercises:

1. A taper effect from top to bottom
2. Noise that scales left to right across a grid