3.3. Basic operations
Basic arithmetic operations in Grasshopper
Points
A point is a list of one or more values that are called coordinates.
Points and Vectors are the base in order to build geometry in Grasshopper.
There are different ways how you can create a point:
- Primitive > Geometry > Point
- Vector > Point > Construct Point
Series
We can create series of numbers in Grasshopper in different ways:
- Sets > Sequence > Series
- Sets > Sequence > Range
Operators
Operators in Grasshopper can be found under Math > Operators, and are used to perform arithmetic operations on numbers.
Addition
- Math > Operators > Addition
Subtract
- Math > Operators > Subtraction
Multiplication
- Math > Operators > Multiplication
Division
- Math > Operators > Division
Modulus
Divides two numbers and returns only the remainder. The division of 9 by 3 returns 0 as a reminder:
- Math > Operators > Modulus
The division of 9 by 4 returns 1 as a reminder, since we can contain two times 4 and still have 1 left:
Power
- Math > Operators > Power
Constants
In Grasshopper we can find certain Build-in components with the values of Pi, Natural Logarithm (e) and Golden Ratio:
Comparison operators
Comparison operators are used to compare values.
They return Boolean values based on whether a comparison is True or False.
- Maths > Operators
Booleans
Boleans variables can only store two values:
- TRUE (1)
- FALSE (0)
Boolean Toggle allows you to quickly change between single True or False values:
Grasshopper has components to test conditions and output Boolean values:
Check if a number is contained inside a certain Domain:
- Maths > Domains > Includes
Logical operators
Logical operators mostly work with Booleans.
Gate NOT performs boolean negations.
- Maths > Operators > Gate NOT
AND and OR components takes two arguments as input. Logical operators are used to evaluate something.
- Maths > Operators > Gate AND
Different combinations:
A | B | Result |
---|---|---|
True | True | True |
True | False | False |
False | True | False |
False | False | False |
- Maths > Operators > Gate OR
A | B | Result |
---|---|---|
True | True | True |
True | False | True |
False | True | True |
False | False | False |
Functions
The series of numbers can be easily manipulated with mathematical operators:
At the same time we can combine them with trigonometrical operations, as for example Sine, Cosine… etc:
- Maths > Trig > Sine
- Maths > Polynomials > Square
- Maths > Trig > Sine & Cosine
Grasshopper offers you “Ready to use” components or custom made ones to create your functions:
- Math > Script > Expression
And by using different parametric functions we will be able to reproduce geometries such as circles, spirals… etc.
Example 2 - Spiral 2D:
Example 3 - Helicoid: