In this second post on the Touch Gesture shapes construction I thought I’d look at a method for constraining the angle of a shape…

Default behaviour when you drag the rotation handle (blue circle in the above image) is for the shape to rotate with sub-degree accuracy. Often the angle will snap to various points such as the grid, shape geometry and extensions depending on what you have set in your Snap and Glue settings (2007 – *Tools / Snap and Glue *or 2010 - *View / Visual Aids / Snap and Glue*).

If, however, you want to constrain the angle to a particular step value then you can use the following formula:

The formula uses three functions:- CEILING, ANG360 and SETATREFEXPR and I’ll look at what each of these do now.

- SETATREFEXPR – The role of this function is to receive the incoming value, and make use of it rather than the cell formula being overwritten as it changes. If you watch the ShapeSheet, you can see the value (0 deg) changing as you rotate the shape.
- ANG360 – This function normalises the angle to fall between 0 and 360 degrees.
- CEILING – Finally, the CEILING function rounds the resulting value
*up*to the next multiple (15 degrees in the above case) thereby giving you the constrained angle. So, for example, an angle of 14 degrees becomes 15 and an angle of 16 degrees becomes 30.

Of course there are lots of ways to tackle this problem and Chris Roth, over at VisGuy.com, has a post about an alternative method.

If you’re interested in the SETATREF family of functions you might want to have look at the Visio Insights blog.