Dynamo
Primer for v2.0
English
English
  • About
  • Introduction
    • What is Dynamo & How Does It Work?
    • Primer User Guide, Dynamo Community & Platform
  • Setup for Dynamo
  • User Interface
    • Workspace
    • Library
  • Nodes and Wires
  • Essential Nodes & Concepts
    • Index of Nodes
    • Geometry for Computational Design
      • Geometry Overview
      • Vector, Plane & Coordinate System
      • Points
      • Curves
      • Surfaces
      • Solids
      • Meshes
    • The Building Blocks of Programs
      • Data
      • Math
      • Logic
      • Strings
      • Color
    • Designing with Lists
      • What's a List
      • Working with Lists
      • Lists of Lists
      • n-Dimensional Lists
    • Dictionaries in Dynamo
      • What is a Dictionary
      • Dictionary Nodes
      • Dictionaries in Code Blocks
      • Revit Use-Cases
  • Custom Nodes & Packages
    • Custom Nodes
      • Custom Node Introduction
      • Creating a Custom Node
      • Publishing to Your Library
    • Packages
      • Package Introduction
      • Package Case Study - Mesh Toolkit
      • Developing a Package
      • Publishing a Package
      • Zero-Touch Importing
  • Dynamo for Revit
    • The Revit Connection
    • Selecting
    • Editing
    • Creating
    • Customizing
    • Documenting
  • Dynamo for Civil 3D
    • The Civil 3D Connection
    • Getting Started
    • Node Library
    • Sample Workflows
      • Roads
        • Light Pole Placement
      • Land
        • Service Placement
      • Utilities
        • Rename Structures
      • Rail
        • Clearance Envelope
      • Surveying
        • Point Group Management
    • Advanced Topics
      • Object Binding
      • Python and Civil 3D
    • Dynamo Player
    • Useful Packages
    • Resources
  • Dynamo in Forma Beta
    • Set Up Dynamo Player in Forma
    • Add and Share Graphs in Dynamo Player
    • Run Graphs in Dynamo Player
    • Dynamo compute service differences with Desktop Dynamo
  • Coding in Dynamo
    • Code Blocks and DesignScript
      • What's a Code Block
      • DesignScript Syntax
      • Shorthand
      • Functions
    • Geometry with DesignScript
      • DesignScript Geometry Basics
      • Geometric Primitives
      • Vector Math
      • Curves: Interpolated and Control Points
      • Translation, Rotation, and Other Transformations
      • Surfaces: Interpolated, Control Points, Loft, Revolve
      • Geometric Parameterization
      • Intersection and Trim
      • Geometric Booleans
      • Python Point Generators
    • Python
      • Python Nodes
      • Python and Revit
      • Setup Your Own Python Template
    • Language Changes
  • Best Practices
    • Graph Strategies
    • Scripting Strategies
    • Scripting Reference
    • Managing Your Program
    • Efficiently Working With Large Data Sets In Dynamo
  • Sample Workflows
    • Getting Started Workflows
      • Parametric Vase
      • Attractor Points
    • Concept Index
  • Developer Primer
    • Build Dynamo from Source
      • Build DynamoRevit from Source
      • Managing and Updating Dependencies in Dynamo
    • Developing for Dynamo
      • Getting Started
      • Zero-Touch Case Study - Grid Node
      • Executing Python Scripts in Zero-Touch Nodes (C#)
      • Going Further with Zero-Touch
      • Advanced Dynamo Node Customization
      • Using COM (interop) types in Dynamo Packages
      • NodeModel Case Study - Custom UI
      • Updating your Packages and Dynamo Libraries for Dynamo 2.x
      • Updating your Packages and Dynamo Libraries for Dynamo 3.x
      • Extensions
      • Defining Custom Package Organization for Dynamo 2.0+
      • Dynamo Command Line Interface
      • Dynamo Integration
      • Developing For Dynamo For Revit
      • Publish a Package
      • Build a Package from Visual Studio
      • Extensions as Packages
    • Pull Requests
    • Testing Expectations
    • Examples
  • Appendix
    • Frequently Asked Questions
    • Visual Programming and Dynamo
    • Resources
    • Release Notes
    • Useful Packages
    • Example Files
    • Host Integration Map
    • Download PDF
    • Dynamo Keyboard Shortcuts
Powered by GitBook
On this page
  • Arithmetic Operators
  • Exercise: The Golden Spiral Formula
  • Part I: Parametric Formula
  • Part II: From Formula to Geometry
  • Part III: From Spiral to Nautilus
  • Part IV: From Nautilus to Phyllotaxis
Edit on GitHub
Export as PDF
  1. Essential Nodes & Concepts
  2. The Building Blocks of Programs

Math

PreviousDataNextLogic

Last updated 2 months ago

If the simplest form of data is numbers, the easiest way to relate those numbers is through Mathematics. From simple operators like divide to trigonometric functions, to more complex formulas, Math is a great way to start exploring numeric relationships and patterns.

Arithmetic Operators

Operators are a set of components that use algebraic functions with two numeric input values, which result in one output value (addition, subtraction, multiplication, division, etc.). These can be found under Operators>Actions.

Icon
Name (Syntax)
Inputs
Outputs

Add (+)

var[]...[], var[]...[]

var[]...[]

Subtract (-)

var[]...[], var[]...[]

var[]...[]

Multiply (*)

var[]...[], var[]...[]

var[]...[]

Divide (/)

var[]...[], var[]...[]

var[]...[]

Exercise: The Golden Spiral Formula

Download the example file by clicking on the link below.

A full list of example files can be found in the Appendix.

Part I: Parametric Formula

Combine operators and variables to form a more complex relationship through Formulas. Use sliders to make a Formula that can be controlled with input parameters.

1.Create Number sequence that represents the 't' in the parametric equation, so we want to use a list that's large enough to define a spiral.

Number Sequence: define a number sequence based on three inputs: start, amount and step.

2. The step above has created a list of numbers to define the parametric domain. Next, create group of Nodes represent the golden spiral equation.

The golden spiral is defined as the equation:

x=rcosθ=acosθebθx = r cos θ = a cos θ e^{bθ}x=rcosθ=acosθebθ
y=rsinθ=asinθebθy = r sin θ = a sin θe^{bθ}y=rsinθ=asinθebθ

The image below represents the golden spiral in in visual programming form. When stepping through the group of Nodes, try to pay attention to the parallel between the visual program and written equation.

a. Number Slider: Add two number sliders to the canvas. These sliders will represent the a and the b variables of the parametric equation. These represent a constant which is flexible, or parameters which we can adjust towards a desired outcome.

b. Multiplication (*) : The multiplication Node is represented by an asterisk. We'll use this repeatedly to connect multiplying variables

c. Math.RadiansToDegrees: The 't' values need to be translated to degrees for their evaluation in the trigonometric functions. Remember, Dynamo defaults to degrees for evaluating these functions.

d. Math.Pow: as a function of the 't' and the number 'e' this creates the Fibonacci sequence.

e. Math.Cos and Math.Sin: These two trigonometric functions will differentiate the x-coordinate and the y-coordinate, respectively, of each parametric point.

f. Watch: We now see that our output is two lists, these will be the x and y coordinates of the points used to generate the spiral.

Part II: From Formula to Geometry

Point.ByCoordinates: Connect the upper multiplication node into the 'x' input and the lower into the 'y' input. We now see a parametric spiral of points on the screen.

Polycurve.ByPoints: Connect Point.ByCoordinates from the previous step into points. We can leave connectLastToFirst without an input because we aren't making a closed curve. This creates a spiral which passes through each point defined in the previous step.

We've now completed the Fibonacci Spiral! Let's take this further into two separate exercises from here, which we'll call the Nautilus and the Sunflower. These are abstractions of natural systems, but the two different applications of the Fibonacci spiral will be well represented.

Part III: From Spiral to Nautilus

Circle.ByCenterPointRadius: We'll use a circle Node here with the same inputs as the previous step. The radius value defaults to 1.0, so we see an immediate output of circles. It becomes immediately legible how the points diverge further from the origin.

Number Sequence: This is the original array of 't'. By plugging this into the radius value of Circle.ByCenterPointRadius, the circle centers are still diverging further from the origin, but the radius of the circles is increasing, creating a funky Fibonacci circle graph.

Bonus points if you make it 3D!

Part IV: From Nautilus to Phyllotaxis

As a jumping-off point, let's start with the same step from the previous exercise: creating a spiral array of points with the Point.ByCoordinates Node.

![](../images/5-3/2/math-part IV-01.jpg)

Next, follow these mini steps to generate a series of spiral at various rotation.

a. Geometry.Rotate: There are several Geometry.Rotate options; be certain you've chosen the Node with geometry,basePlane, and degrees as its inputs. Connect Point.ByCoordinates into the geometry input. Right click on this Node and make sure the lacing is set to 'Cross Product'

b. Plane.XY: Connect to the basePlane input. We will rotate around the origin, which is the same location as the base of the spiral.

c. Number Range: For our degree input, we want to create multiple rotations. We can do this quickly with a Number Range component. Connect this into the degrees input.

d. Number: And to define the range of numbers, add three number nodes to the canvas in vertical order. From top to bottom, assign values of 0.0,360.0, and 120.0 respectively. These are driving the rotation of the spiral. Notice the output results from the Number Range node after connecting the three number nodes to the Node.

Our output is beginning to resemble a whirlpool. Let's adjust some of the Number Range parameters and see how the results change.

Change the step size of the Number Range node from 120.0 to 36.0. Notice that this is creating more rotations and is therefore giving us a denser grid.

Change the step size of the Number Range node from 36.0 to 3.6. This now gives us a much denser grid, and the directionality of the spiral is unclear. Ladies and gentlemen, we've created a sunflower.

Now, the bulk of Nodes from the previous step will work fine, but it is a lot of work. To create a more efficient workflow, have a look at to define a string of Dynamo expressions into one node. In this next series of steps, we'll look at using the parametric equation to draw the Fibonacci spiral.

Pattern Now that we've made a circular Nautilus shell, let's jump into parametric grids. We're going to use a basic rotate on the Fibonacci Spiral to create a Fibonacci grid, and the result is modeled after the .

DesignScript
growth of sunflower seeds
17KB
Building Blocks of Programs - Math.dyn