Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
GenerativeComponents
  • Product Communities
  • More
GenerativeComponents
GenerativeComponents Community Wiki Prime Number Pattern
    • Sign in
    • +An Overview of GenerativeComponents
    • +Addin Content
    • +Bentley BIM Modeler Accreditation – Program Overview
    • +C# Sample Solution and other Add-ins
    • +GenerativeComponents Solutions
    • +Learn GenerativeComponents
    • +Reference Material
    • Support for GenerativeComponents
    • -Tutorials
      • 3D array copy surface
      • Add RFA data as BuildingContent to ABD with GC Extension
      • Cell Feature
      • Create a Set of Random Points
      • Creation of Global function from Custom function
      • Creation of Parabolic curve
      • Free Form Roof Example
      • GC Excel Feature
      • GenerativeComponents Essentials Course
      • How To Create Surface From Lines & Curves
      • How to Export GC elements
      • How to get concrete sections in the cross-section dialog in Generative Components
      • Landscape Bridge Example
      • +LawCurve
      • List Of Points With A Loop Example
      • Mesh feature 3d print
      • Modular Multiplication On Circle
      • +Operation Node
      • +Optimization with the Optimizer node type
      • Palm Tree Modeler
      • Point By Function Example
      • Points On Curve
      • Prime Number Pattern
      • Selection of Points
      • Selection of points based on Query Expressions
      • Selection of points based on range of indices
      • Set a New Property Value to a Set of Selected Nodes
      • Simple Bridge Example
      • Simple Equations To Describe Form Example
      • Simple Free Form Roof Example
      • Sin Tower
      • Skeleton
      • Sunflower Seed Pattern Modelling
      • Surface Division Basic Steps
      • Surface from Rails and Swept Sections
      • The use of Packager in Generative Components
      • +Tools and Techniques
      • Ulam Spiral From A Rectangular Spiral
      • Video Tutorials
      • Video Tutorials - Short Techniques
    • +User Projects
    • +Visualized Parametric Experimentations
    • +zed_Older Content

     
     Questions about this article, topic, or product? Click here. 

    Prime Number Pattern

      Product(s): OpenBuildings Generative Components
      Version(s): 10.06.03.04
      Environment:  N\A

     

    Background

    Prime numbers can be fun to play with. As per Wikipedia, a prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. If all the prime numbers starting from 2 are plotted in polar coordinate system where both the radial coordinate and the angular coordinate are equal to the prime number, we would find an emergence of a beautiful spiral pattern. In the below section we will see how we can create such a pattern in Generative Components with a little help of GC scripting.

    Click here to play this video

    Steps to Accomplish

    Step 1

             We will create a list containing all the prime numbers in first n numbers. For this, we will use the "Function" node and create a         custom function. The script is as follows.
             

    	function (int n)
    	{
    	    int prime= {2,3};               //corner case
    	    for (int j = 5; j < n; ++j)     //check for number from 5 to n-1
    	    {
    	        int a=1;
    	        for (int i = 2; i < j/2; ++i)
    	        {
    	            if(j%i==0)
    	            {
    	                a=0;
    	                break;
    	            }
    	        }
    	         if(a==1)
    	             {
    	             prime.Add(j);      //adding number to list "prime"
    	             }         
    	        
    	    }
    	    return prime;
    	       
        }

            Here, naive algorithm is used for generating the prime numbers with little modification.


    Step 2

    After having the list of prime numbers, we will be using it as input for a Point node with technique ByCylindricalCordinates. The prime number list will be used as input for both the Radius and the Theta. However, for the input Theta prime number list should be converted to its corresponding degrees. For this, we use the function Degrees().



             Please go through the sample file Prime number pattern.gct

    • pattern
    • OBD
    • Tutorial
    • OBD GC
    • OpenBuildings Designer
    • GC CONNECT Edition
    • Point
    • GenerativeComponents
    • GCscript
    • Prime Number
    • Function
    • GenerativeComponents CONNECT Edition
    • gct
    • Share
    • History
    • More
    • Cancel
    • Anik Mal Created by Bentley Colleague Anik Mal
    • When: Tue, Feb 25 2020 5:40 AM
    • Anik Mal Last revision by Bentley Colleague Anik Mal
    • When: Wed, Apr 1 2020 8:56 AM
    • Revisions: 12
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2021 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies