# List of mathematical shapes and how to create them using Designscript

@Marcel_Rijsmus hope it might be okay to ask about this on this thread, if not I will delete - I wanted to produce a Mobius Strip and have found some strange results; I’m wondering if someone more mathematically inclined than me might have an explanation? A Möbius strip of half-width w with midcircle of radius R and at height z=0 can be represented parametrically by

x = [R+ s cos(1/2 t )] cos t
y = [R+ s cos(1/2 t)] sin t
z = s sin(1/2 t)

Image and formula from: http://mathworld.wolfram.com/MoebiusStrip.html

This is the result in Dynamo:

DesignScript (using number sliders for s and r):

``````s = -n..n..0.001;
t = 1..10000;
x = (r + (s * Math.Cos(t/2))) * Math.Cos(t);
y = (r + (s * Math.Cos(t/2))) * Math.Sin(t);
z = s * Math.Sin(t/2);
points = Autodesk.Point.ByCoordinates(x,y,z);
Mobius = Autodesk.PolyCurve.ByPoints(points);
``````

Any ideas? I know that its meant to be a surface and I am generating points/polycurves so might be the explanation, but I suppose I wasn’t too sure how to generate it otherwise 5 Likes

Getting the lacing to work correctly is really tough. The old formula node set to cross product makes these shapes a lot easier:

17 Likes

``````n = 10;
r = 20;
s = -n..n..#100;
t = 0..360..#100;
x = (r + (s<2> * Math.Cos(t/2)<1>)) * Math.Cos(t);
y = (r + (s<2> * Math.Cos(t/2)<1>)) * Math.Sin(t);
z = s<2> * Math.Sin(t/2)<1>;
points = Autodesk.Point.ByCoordinates(x,y,z);
Mobius = NurbsSurface.ByPoints(points);``````
7 Likes

Koch Curve Snowflake
(I’ll look at optimising the recursion when I’m back in the office after the holidays )

e1=Line.ByStartPointEndPoint(p1,p5);
v1=Vector.ByTwoPoints(p1,p5);
l1=Point.DistanceTo(p1,p5);

d3=l1/3;
p2=Point.Translate(p1,v1,d3);
p4=Point.Translate(p1,v1,d3*2);

v2=Vector.Rotate(v1,Vector.ZAxis(),-60);
v3=Vector.Rotate(v1,Vector.ZAxis(),-120);

e2=Line.ByStartPointDirectionLength(p2,v2,d3);
e3=Line.ByStartPointDirectionLength(p4,v3,d3);

p3=Geometry.Intersect(e2,e3);

plist={DSCore.List.Flatten(p1,5),
DSCore.List.Flatten(p2,5),
DSCore.List.Flatten(p3,5),
DSCore.List.Flatten(p4,5),
DSCore.List.Flatten(p5,5)};

plist2=DSCore.List.Transpose(plist);

pc=PolyCurve.ByPoints(plist2,false);
pcc=PolyCurve.Curves(pc);
Line.PointAtParameter(pcc,0);
Line.PointAtParameter(pcc,1);

12 Likes

@Vikram_Subbaiah @Dimitar_Venkov Brilliant, thank you both! 4 Likes

Hypocycloid, good for generating Astroids and Nephroids.

19 Likes

@Zach_Kron

It’s not in Designscript so it doesn’t count. Node to Code makes a mess of it btw.

Marcel

I managed to re-write everything up until the part which drove the animation, and plan to try and finish the animation portion when I plug back in (going laptopless for the weekend). I can post when done and reconnected.

3 Likes

Thanks for the good learning exercise @Zach_Kron. Note that it lead to a GitHub issue report too, so double win. Enjoy all.

Hypocyclid - DesignScripted.dyn (8.6 KB)

2 Likes

I know this post is old, but @Marcel_Rijsmus this is really cool!

I’ll be throwing in any cool stuff I come across.

I have tried to recreate a Spirograph before, but I haven’t really figured out how to manipulate the inputs to get the desired results.

Spirograph.dyn (9.0 KB)

9 Likes

Bit different from my version:

Yours is a bit ‘purer’ in terms of the math though. Had a twitter post awhile back where I ran this via Refinery to see how many I could make. I haven’t tried it with the faster refinery yet, perhaps a weekend project is in order… Here’s the view of mine with the dials cranked to 11:

And the code:

``````def Spirograph (InitiatingCircleRadius, PointCount, LowOffset, HighOffset, Steps)
{
BasePoint =
Point.ByCoordinates(
0,
0
);

angle =
360/PointCount;

return =
Autodesk.Geometry.Rotate(
Arc.ByThreePoints(
BasePoint,
Autodesk.Geometry.Rotate(
Autodesk.Geometry.Translate(
BasePoint,
0,
0
),
Point.Origin(),
Vector.ZAxis(),
angle
),
Autodesk.Geometry.Rotate(
BasePoint,
Point.Origin(),
Vector.ZAxis(),
angle*2
)
)<1>,
Point.Origin()<2>,
Vector.ZAxis()<3>,
DSCore.List.DropItems(
(0..360..angle),
-1
)<4>
);

};
``````
4 Likes
3 Likes
2 Likes
4 Likes
5 Likes