3.1. Algorithms and Data Types

Algorithms and Data Types in Grasshopper

Structure of an Algorithm

An algorithm are series of intructions that are followed, in steps, to solve a problem.

Algorithms

Example in Grasshopper:

Algorithm

Common Data Types

In Computer Science and Computer Programming, a Data Type or simply Type is an attribute of data which tells the compiler or interpreter how the programmer intends to use the data.

The most commonly used Data Types in Grasshopper are:

  • Strings
  • Numbers
  • Booleans

String

A string represent text.

String

Numbers

The most commonly used number Data Types in Grasshopper are:

  • Integers
  • Float

Integers

Are whole numbers that range from -2,147,483,647 to 2,147,483,647 (up to 10 digits of precision):

Number

Floats

Represent values as high-precision fractional values:

Number float

Booleans

Booleans can represent only two different values:

  • True (1)
  • False (0).
Boolean

Geometry Data Types

Some of the most common geometry Data Types are points and lines, but you can also find circles, planes, boxes…etc:

Point

Point

Line

Line

Circle

Circle

Plane

Contains a collection of 3D axis-systems, in this case an origin and a Z vector:

Plane

etc…

Computer Graphics Types

The computer graphics contains two main types:

  • Raster (Bitmap) graphics
  • Vector graphics
Raster-Vector

Knowledge Checks