List of mathematical shapes and how to create them using Designscript

a simple circle

7 Likes

with little love :slight_smile:

heart shape curve

t=1..500;
x=12 * Math.Sin(t)-4 * Math.Sin(3 * t);
y=13 * Math.Cos(t)-5 * Math.Cos(2 * t)-2 * Math.Cos(3 * t)-Math.Cos(4 * t);
hs=Point.ByCoordinates(x,y);
Point.Translate(hs,Vector.XAxis(),0);
17 Likes

I don’t know if it is appropriate but I had a lot of fun doing this:
http://mathworld.wolfram.com/CannabisCurve.html

16 Likes

Could everyone amend his/her post to include the code to avoid re-typing ?:grinning:

6 Likes

Ha good call - updated mine! :slight_smile:

4 Likes

@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?

image

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: Möbius Strip -- from Wolfram MathWorld

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 :blush:

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 :grinning: after the holidays :beach_umbrella:)


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);

13 Likes

@Vikram_Subbaiah @Dimitar_Venkov Brilliant, thank you both! :smiley:

4 Likes

Hypocycloid, good for generating Astroids and Nephroids.



20 Likes

@Zach_Kron

It’s not in Designscript so it doesn’t count. :slight_smile:
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(
		InitiatingCircleRadius,
		0,
		0
	);

angle =
	360/PointCount;

return =
	Autodesk.Geometry.Rotate(
		Arc.ByThreePoints(
			BasePoint,
			Autodesk.Geometry.Rotate(
				Autodesk.Geometry.Translate(
					BasePoint,
					-InitiatingCircleRadius/(LowOffset..HighOffset..#Steps),
					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

I have no idea what this one is called


cool algorithm1.dyn (6.9 KB)

3 Likes

Random


parametrics3.dyn (5.9 KB)

2 Likes

Random


Parametrics4.dyn (6.3 KB)

4 Likes

6 Likes