3.4. Math and Logic Functions

Math and Logic Functions in Grasshopper

Operators

Operators in Grasshopper can be found under Math > Operators:

Operators

Math operators

Math operators are used to perform arithmetic operations on numbers.

Addition

(Math > Operators > Addition)

Addition

Subtract

(Math > Operators > Subtraction)

Subtract

Multiplication

(Math > Operators > Multiplication)

Multiplication

Division

(Math > Operators > Division)

Division Division

Modulus

(Math > Operators > Modulus)

Divides two numbers and returns only the remainder.

The division of 9 by 3 returns 0 as a reminder.

Modulus

The division of 9 by 4 returns 1 as a reminder, since we can contain two times 4 and still have 1 left.

Modulus

Power

(Math > Operators > Power)

Power

Constants

In Grasshopper we can find certain build-in components with the values of Pi, Natural logarithm (e) and Golden Ratio:

Constants

Comparison operators

Comparison operators are used to compare values. They return True or False based on whether a comparison is true or false.

Booleans

Boleans variable can only store two values: TRUE or FALSE, 1 or 0.

Comparators

Boolean Toggle allows you to quickly change between single True or False values:

Comparators

Grasshopper has components to test conditions and output Boolean values:

Comparators

Check if a number is contained inside a certain Domain:

(Maths > Domains > Includes)

Comparators

Logical operators

Logical operators mostly work with Booleans.

Gate NOT performs boolean negations.

(Maths > Operators > Gate NOT)

Comparators

AND and OR components takes two arguments as input. Logical operators are used to evaluate something.

Comparators

(Maths > Operators > Gate AND)

Comparators

(Maths > Operators > Gate OR)

Points

A point is a list of one or more values that are called coordinates.

Depending on the number of coordinates we can know in which dimension of space resides.

Points, Vectors and Planes are the base in order to build geometry in Grasshopper. There are different ways how you can create a point.

(Primitive > Geometry > Point)

Points

(Vector > Point > Construct Point)

Points

Vectors

A Vector is a geometric quantity describing Direction and Magnitude. They are abstract.

Points and vectors are difficult to distinguish, they are both a list of values.

A vector always starts at (0,0,0) and ends at the specific coordinate.

We can easily manipulate them by using mathematical operators:

Vectors

Series

(See Lists)

We can create series of numbers in Grasshopper in different ways:

(Sets > Sequence > Series)

Series

(Sets > Sequence > Range)

Series Series

Math Functions

The series of values can be easily manipulated with mathematical operators:

Math Functions

At the same time we can combine them with trigonometrical operations, as for example Sine, Cosine… etc:

(Maths > Trig > Sine)

Math Functions

(Maths > Polynomials > Square)

Math Functions

(Maths > Trig > Sine & Cosine)

Math Functions

Grasshopper allows you to use “Ready to use” components or custom made ones to create your functions:

(Math > Script > Expression)

Math Functions

And by using different parametric functions we will be able to reproduce geometries such as circles, spirals… etc.

Math Functions Math Functions Math Functions

Knowledge Checks