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.
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}).
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.
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.
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].
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).
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). SlopeAnalysis_Basic_CH.gh (18.9 KB)