Jump to content
Developer Wiki and Function Reference Links ×

Create and Rotate a line in polar coordinates. Primes

Benson Shaw

Recommended Posts

Total Marionette beginner here.

Spiral pattern of dots in polar coordinates looks like a thing that could be done in vwx with marionette:


Therefore, trying to make a bunch of lines in polar coordinate that start at Origin and have

Length = R, Angle = θ (radians about the origin)

such that R=θ

eg 2,2 represents a line of length 2 that is rotated 2 radians.


This is my attempted network to make any one of the lines:



This net returns a line on x axis of Length = value in the Int node (eg 2, or 5, or other integer). But no rotation.

Perhaps because the pEnd needs both x,y?  With only 1 input (x) from the Int node it assumes y =0 and ignores the rotation.

Strange, but the net returns nothing if I name any of the nodes. eg if I name the Point2 node 0_0 to indicate the origin.


If I ever get the line part, I would then try to replace the Int node with a network made to step through a range of prime numbers and return a line for each prime, and place a dot at the end point of each line, to produce the fun spiral pattern. Oiy, so much to learn!



Maybe a better approach is to forget the lines and directly place dots based on sine & cosine of the polar coords?

Have to think about that one.


Also I see no prime number node.

What is technique for accessing external list of primes (eg in a worksheet or text block )?


Any suggestions or help or pointers to resources welcome.




Link to comment

Here's a quick network that will rotate a line. The bottom version uses a manually entered list of primes to generate a series of lines.




@Marissa Farrell may be able to help with a node to generate prime numbers in a certain range. There's lots of info online about using Python code and/or Python libraries with functions to generate prime numbers.





Rotate Line.vwx

  • Like 1
Link to comment

OK, continuing my journey.

1st a mystery in the single line test. The 1st part of the network returns a rotated line, but the rotation seems to use negative value of the angle developed by the polar conversion.  Same flip if angle is directly called with an Integer Node or a Real Node instead of the polar.



Ignoring that for now, some success!

Veterans may snigger. But baby steps!

Now looking for way to input a few 1000 primes.  Access an external list?

@Kevin McAllister I'm not code experienced since cursory X Basic use about 50 years ago (if 26, then go to line 14, if 27, then go to @#$%), but will try looking through some of the Python resources.

Might also mean customizing a copy of the Ordered List node.






Link to comment

OK, switched to Integers for now. Makes really nice swirls with about 5K dots.  But another mystery ensues:


Set up the network to produce the dots by integer pairs, and at end added nodes to transfer the dots to different layer and class.  This slows the network runtime.  Without the transfer nodes at end, runtime for 5000 dots is a few seconds.  Layer/Class change makes runtime about 30sec.  At 50K dots, the runtime is maybe 30 seconds with no layer/class change and about 15 min with the layer change.  Seems the layer change is acting on individual dots rather than on the group created by network.


Do I need a different strategy for layer/class designation? Manually moving the resulting group to different layer and class requires only about 10 seconds.







Swirls v2019.vwx

Edited by Benson Shaw
v2019 file
  • Like 1
Link to comment
  • 3 weeks later...
  • Vectorworks, Inc Employee

Perhaps you could try using the group node to group all of your points before changing their layer? In general however, I would recommend simply running the network with the layer that you want the objects to end up on as the active layer. 


I also assume that it is the act of setting the layer that eats up the most time and not setting the class. Have you experimented with only changing the class?

Link to comment

@sbarrett Thanks for looking!  The time lag is indeed mainly with the layer.  But, I want to keep the network out of view and have the result isolated on its own layer, so for now I will just have to put up with the lag.  Will try a group node before the class/layer change.


Horsing around this this more in last few days. File attached.

• Added nodes to incrementally increase dot diameter.

• Modified a Series node to produce series of Primes (will add to resources for hive mind improvements).

• New layer with network for prime pairs.  Sort of works, but not quite like the video at start, so needs trouble shooting.

• Saved views for Integer Network 


Here's the network made with 5000 integers (about 15 seconds)



Here's Primes btw 0>10000

Note: There are only 1229 primes in that range, so the dot size count uses manual adjust.

Need to figure out a count from the Prime series and wire that to the count.



Swirls v2019.vwx

Link to comment

Here's the network with dot radius controlled by a Series node.  Radius increases by the step increment and the series count is equal to the number of primes found in the range.

Anyone suggest some efficiencies/improvements?




 Here's primes btw 0>500000.  Run time is 10 min to 15 min for this vs only a few seconds for range of 100000.


  • Like 1
Link to comment
6 hours ago, sbarrett said:

Is there a reason why you can't substitute . . .

This is why you are in management and I'm a clerk in the mail room.  I'm just starting to explore Marionette. Great to have comment and mods from a master. I tried several ways to find/report the length of list (number of items). I might have tried (possibly incorrectly) the Add List. I think it was returning a value of 1 for each item in the list, but not adding the ones.  Or something.


7 hours ago, sbarrett said:

Do values in the prime series repeat? 

No, the prime numbers are uniques in the list.  Any item in the list has a greater value than all of its preceeders and smaller value than all of its followers.  Same behavior in the integer list.


If I change parameters, via slider or key, in your cool modified SB Marionette object, an error dialog is generated.  If I choose either Close, or Select Node, the dialog closes and the M Object updates to the new values.  ??? 


Note, just started using v2020, so looking at translated file.



Link to comment
  • Vectorworks, Inc Employee

I realized what was wrong. In your original script in the 2019 version, you had the prime value input into the Line node, instead of converting it to a point first. For some weird reason, this worked in 2019. I have updated the script so it works in 2019 and 2020. The other exciting thing is that in 2020 there is a big improvement in graphics performance.


Swirls v2019-SB.vwx

Swirls v2020-SB.vwx

  • Like 3
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...