Grasshopper Terrain Slope in Degrees

Hey Guys,

I am trying to show terrain parts which have a slope more 45 degrees. Using gradient showing slope every 15 degrees.
I found a way to map vector Z and display its values, but I need to convert them to degrees somehow.
Please see attached images.


1 Like

If you have a normal vector, you compute the angle between it and the World Unit Z vector. Then convert this angle from radians into degrees (there’s a Deg component for this, or you can use an expression: \frac{360 \cdot angle}{\pi}).

1 Like

Thank you David. Now how to know which colour represent what degree ?

You don’t because you initialise your gradient using the angle range. If you unplug the L0 and L1 inputs and just set the values to 0 and 90, you’ll know that green is horizontal and red is vertical.

1 Like

Cool. It works. Last questions:

  1. How to smooth the result? currently it based on actual triangles.
  2. Why area where slope is less then 45 is red as well? Am I doing something wrong?

Thank you

ok found how to blur )

Since you uploaded no files I can’t tell you whether there’s a mistake or not. It does look pretty noisy. Are you sure you’re not conflating face normals and vertex normals?

Oh wait, I can tell from your image that you are in fact conflating face and vertex normals.

Instead of the face normals component, use Deconstruct Mesh . It’ll give you the vertex normals which is what you need since colours are assigned on a per-vertex basis.

Hi David please see attached files.

I think I calculating the angle incorrectly. I am getting an angle between world Z and face normal. But I need to display the actual slope angle relative to world plane.

[David R: attachment removed, missing Rhino file and it locks up your computer for 10 minutes trying to open this].

Yep. It works.

Why does this file take forever to open? It’s still going…

10 minutes for every save/open iteration, dayum.

Works fine on my machine. I have attached an updated version. (465.5 KB)

Thank you David. I solved everything I wanted with your help.
Is there a way to export vertex colour as a texture?


Thank you Guys!

I am trying to get the same diagram but using slope percentage. So I can just find a tng of every vector angle , but what is the best way to colour the mesh?
If I want for example have rages 0-5, 5-25 and so on ?



When you assign mesh vertex colours, they will always interpolate across each triangle. This can lead to messy visualisation when the differences between neighbouring vertices is large. For example imagine that flat areas are coloured green, medium slopes yellow, steep slopes red and vertical cliffs in black. If you have one triangle which goes straight from flat to vertical, it’ll just blend green to black without the intervening yellow and red.

A solution is to use texture coordinates and a gradient bitmap instead, but Grasshopper 1.0 doesn’t understand either of those, so that’ll require custom code.

If you are happy using vertex colours, then you can use ranges by mapping your angles into a domain sequence. (I’ll upload a file after I poured myself some more tea). (22.0 KB)

1 Like

Instead of Consec (18.2 KB)

And instead of a specific palette, random colors, number and hue: (25.6 KB)

Sorted colors: (28.1 KB)


In addition to the suggestions already given, In order to get “percent” VS “degree” you just need to do a little math in between.

This example uses one custom component to explode the mesh. There are a few others around.

Also, depending on the types of surfaces/meshes you are working with, I have found this to help speed things up a bit. Explode the mesh, decompose and measure against another vector(as described in other examples), then average them together. This effectively gives you the face normal as oppose to every vertex. Then process those values. In the workflow I use, when you reconstruct the mesh with the colors, it assigns the same color(1 color) to each vertex of each individual face. Resulting in a “colored by face” mesh. But if you want, just blur it after to get a smoother looking gradient.
For example, in the attached file, there are 10000 vertices. If I explode it, and only operate on the average of those face vertex normals, I get the vertex at the center,( 1 face normal) of the face. This reduces the values that are being operated on down to 2500. Lastly…this is just how I do it, there are other ways as well.
I have found this approach to be the most useful, IF you want to be able to describe a series of slope “ranges”, (which are really domains), and have control over the color of the ranges. Also, by using the find domain component, you can reuse the index to cull the resulting mesh, (isolating your slope zones). (18.9 KB)