This website is made for modern browsers. You are seeing this, because your browser is missing a feature or two. Please install the latest update or switch to a modern browser. See you soon.



This how-to guide is focusing on domains and the various components and component compositions that host valuable functions related to domains. In mathematics, a domain refers to the input values of a function and the range refers to the values that this function can output. In Grasshopper, both terms are often used indistinctly; a range can be a domain or a defined series of numbers. Domains are specified as a domain of numeric range. Despite this vague mathematical description, domains in Grasshopper are well-defined as a data type.

Domains in Grasshopper have defined bounds that are represented by a lower and a upper value, like 0 and 1. Within the domain, all real numbers are possible that exist between the bounds. A domain is written as 0 To 1. Beside this data type Domain, there is also the data type Domain²that represents two domains in one object (this is different from having two domain-items in a list). The domains of Domain² are named u and v and this data construct is useful when working with surfaces.

Construct Domains

The most official way to construct a domain is using the component Construct Domainthat converts two given numbers into bounds of a domain.

Another way is to use a Paneland to write the bounds with a To in the middle: 0 To 5. Whenever a component requests for a domain, this string format will be converted to one.

If a component requests a domain, but only a single number is provided, than this number becomes the upper bound and the lower bound is set to 0, as demonstrated with the Domaincontainer.

The component Boundswill take a list of numbers as input and analyzes it to set the smallest number as lower bound and the largest number as upper bound of a domain.

The component Consecutive Domainswill take a list of numbers as input and creates multiple domains from it. By default, the value of each item relates to the numeric range of each domain, which could also be expressed as a step size between the domains.

If we set input A of Consecutive Domainsto False, then each value will represent the upper bound of the current and the lower bound of the following domain.

To construct the data type Domain², there are two possibilities. The first one is to use Construct Domain², which constructs a Domain² from four numbers; the lower and upper bounds of each domain.

The second possibility is to use Construct Domain², which takes two Domain-objects and converts them into a Domain².

Deconstruct domains

Of course, if domains can be constructed, they can also be deconstructed and Deconstruct Domaindoes this for the data type Domain. At the outputs, we get the lower and upper bound.

For the data type Domain², there are again two possibilities: The component Deconstruct Domain²deconstructs the u and v domain into four numbers (lower and upper bounds).

The alternative is Deconstruct Domain², which deconstructs the Domain² into its two separate domains at output U and V.

Retrieve domains from geometric objects

Domains are often used in combination with geometric objects. At an object’s input, we can use Reparameterize to rewrite the actual domain into a normalized one (0 To 1). Then we relate our operations to the normalized domain and do not need to know the actual domain. This is useful, if the real bounds vary from shape to shape.

If we need to retrieve the real domain of a geometric shape, we can also do this. Curves have one direction and they translate into data type Domain. The component Curve Domainwill retrieve the domain of a curve. Also, inputs that request a domain, but get a curve instead, will translate the curve into a domain, like Domaindoes. In rare cases, because of type conversion, the result of Curve Domainand Domaindiffers. Read Curve and surface parameters for an explanation.

A surface has two directions (u and v) and translates to data type Domain². For retrieving, we can use a Domain²container, because components that request for a Domain² will do the conversion automatically. Thus, we could also use the deconstruct-domain components to extract the two domains and the bounds.

If we have a cloud of points, we can use Bounds 2Dto create a Domain² from the two-dimensional coordinates (x and y) of the points. The z-coordinates are neglected. If we would like to do this for all three coordinates, we can use Deconstructon the list of points and then use Boundsfor each coordinate.

Divide domains

Because domains host a range of numbers, we can also subdivide them into smaller units. The component Divide Domaindivides domains into C smaller domains.

The component Divide Domain²does the same for data type Domain² and the number of segments in each direction can be set individually. The division relates to a grid layout, so the number of domains created is the product U and V.

The operation Divide Domain²is useful in combination with Isotrim: Divide Domain² automatically converts a plugged in surface into a domain² and creates a subset of surface parameters. Then, Isotrim will slice the surface into smaller segments.

The component Rangewill also divide a domain. But not into smaller segmented domains but in real numbers. Input N sets the number of steps that the domain is divided into.

Remap a domain

The component Remap Numberswill remap a given value V, which is part of the source domain S, to the correlating value in the target domain T. Given the target domain 0 To 1, we can use this component to normalize numbers. See how-to Curve and surface parameters for more about reparameterization.

Check domains

To test a number for its relation to one or more domains, there are two components present in Grasshopper. Includeswill check if a given value V is part of the domain D.

In case that the number is not part of the domain, output D will state the distance between the given number and the nearest bound of the domain.

The component Find Domainis similar, but here we provide a collection of domains at input D and the function will find the domain in which the number is included.

If the number is not part of any domain, then we can find the nearest domain at output N.

If we set input S (strict) of Find Domainto True, the given number N has to be part of the interior of the domain and can not be equal to one of the bounds.

This page is open source. Edit it on GitHub or see how you can contribute.

Up next