We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Coons 101

Anonymous
Not applicable
Actually coons are quite a tricky geometric structure, normally only covered in university-level mathematics or mechanical engineering courses. They are a new invention too - first described at the end of the 60's by somebody who obviously had too little tobacco in his cigarettes.

Basically, if you create four (three-dimensional lines, thus) EDGES in space, and the corners of the lines intersect each other, you will have a description for a surface. The points on the surfaces are interpolated from the opposing edges. Think of two people holding a blanket.

The 'tricky' part is working out the formula / points for the four sides.

Note that the end points of each line have to be coincident (the same) otherwise you'll get a gdl error.

In the coil here I 'cheated' by setting two of the lines to zero (thus generating a 'pointed' end.

We'll come back to the 'spiral code' after the following example.
13 REPLIES 13
Anonymous
Not applicable
In the example below we have created four 'edge curves' (two of which are 'straight' curves), labelled 'X1', 'X2', 'Y1' and 'Y2' for reference. There is no need for these curves to have any relation whatsoever to the X, Y or Z axes (see 'spiral' below) - these names are purely for illustrative purposes.

Hopefully the illustration below is clear?

Within the - admittedly clumsy - GDL below we first define the four curves,
and then 'put' them to the stack, in order.

The syntax of the coons command is;

coons PointsOnLines1&3, PointsOnLines2&4, status code,
Line1-X1, Line1-Y1, Line1-Z1,
Line1-X2, Line1-Y2, Line1-Z2,
...
Line4-X8, Line4-Y8, Line4-Z8


Example script:

oX=1 : oY=2 : oZ=3 !=== I do this for convenience

dim oLineX1 [8][3]
dim oLineX2 [8][3]
dim oLineY1 [8][3]
dim oLineY2 [8][3]

!=== calculate edge curves

for i=0 to 7

oLineX1 [i+1][oX] = i
oLineX1 [i+1][oY] = 0
oLineX1 [i+1][oZ] = i * 3/7

oLineX2 [i+1][oX] = i
oLineX2 [i+1][oY] = 7 + sin(i*180/7)
oLineX2 [i+1][oZ] = 3

oLineY1 [i+1][oX] = 0
oLineY1 [i+1][oY] = i
oLineY1 [i+1][oZ] = i * 3/7

oLineY2 [i+1][oX] = 7
oLineY2 [i+1][oY] = i
oLineY2 [i+1][oZ] = 3 + sin(i*180/7)

next i

!=== 'put' coordinates, in order

for i=0 to 7
put oLineX1 [i+1][oX]
put oLineX1 [i+1][oY]
put oLineX1 [i+1][oZ]
next i

for i=0 to 7
put oLineX2 [i+1][oX]
put oLineX2 [i+1][oY]
put oLineX2 [i+1][oZ]
next i

for i=0 to 7
put oLineY1 [i+1][oX]
put oLineY1 [i+1][oY]
put oLineY1 [i+1][oZ]
next i

for i=0 to 7
put oLineY2 [i+1][oX]
put oLineY2 [i+1][oY]
put oLineY2 [i+1][oZ]
next i

!=== perform coons command

coons 8, 8, 32+16+8+4,
get (24),
get (24),
get (24),
get (24)
Anonymous
Not applicable
Here is an 'expanded' version of the coil script from the other thread. Note that I have removed the 'sin(i/oAn*180)' bits - which were used to expand/contract the spirals thus creating a 'pointed' coil.

Hopefully the script + illustration is clear?

oSegments = 0100 !=== no. of segments
oRadius = 0005 !=== helix diameter
oWidth = 0002 !=== width of band
oAngle = 1500 !=== total revolved angle
oLength = 0050 !=== total length

!=== put 'internal spiral' (X1)

for i=0 to oAngle step oAngle/oSegments

put oRadius * cos(i) - oWidth * cos(i)
put oRadius * sin(i) - oWidth * sin(i)
put i/oAngle*oLength

next i

!=== put 'external spiral' (X2)

for i=0 to oAngle step oAngle/oSegments

put oRadius * cos(i) + oWidth * cos(i)
put oRadius * sin(i) + oWidth * sin(i)
put i/oAngle*oLength

next i

!=== put bottom line (Y1) and the top line (Y2)

for i=0 to oAngle step oAngle

!=== internal point (A)
put oRadius * cos(i) - oWidth * cos(i)
put oRadius * sin(i) - oWidth * sin(i)
put i/oAngle*oLength

!=== external point (B)
put oRadius * cos(i) + oWidth * cos(i)
put oRadius * sin(i) + oWidth * sin(i)
put i/oAngle*oLength

next i

!=== note that there are four points (3x4=12 coordinate values) for the top & bottom lines, and six values (three (X,Y,Z) 'inside' and three 'outside') for the 'spiral' lines, hence (nsp-12)/6...

coons (nsp-12)/6, 2, 60, get (nsp)
Anonymous
Not applicable
Notes:

1. Coons are really not supposed to be spiral but the GDL engine allows it, so why not
2. The GDL engine can be quite fussy about the corner points (the 'famous' accuracy issue) so for 'robust' scripts it would be 'a good idea' to set the start/end points of the 'Y' lines to be the same as the end/start points of the 'X' lines (rather than use calculated solutions).

In our next lesson we'll cover vert, edge, vect & the pgon commands NOT !

PS. I haven't checked, but doesn't DnC cover this in his *highly recommended* cookbook??
Durval
Enthusiast
StuartJames wrote:
Hopefully the script + illustration is clear?
As clear as an Efels Pilsen!
Even the 'sin(i/oAn*180)' bit that you omitted is now understandable. Very clever!
Thanks for the lesson. I'll print it and attach to my CookBook.
--- www.dtabach.com.br ---
AC 24 BR – MacBook Pro 2,9 GHz Intel Core i7 16GB RAM Mac OS 10.14
Anonymous
Not applicable
StuartJames wrote:
In our next lesson we'll cover vert, edge, vect & the pgon commands NOT !
Oh Yes, Stuart, Please!
Thanks for these examples and the nice scripts.
My only regret is that coons is only a surface, not a volume, no way for SEO.
Do you have a solution for this?
Durval
Enthusiast
Olivier wrote:
My only regret is that coons is only a surface, not a volume, no way for SEO.
Do you have a solution for this?
Maybe four coons, with similar mathematics, two for the laid down surfaces, and two more for the 'walls'?
--- www.dtabach.com.br ---
AC 24 BR – MacBook Pro 2,9 GHz Intel Core i7 16GB RAM Mac OS 10.14
Karl Ottenstein
Moderator
StuartJames wrote:
1. Coons are really not supposed to be spiral but the GDL engine allows it, so why not
It is remarkable that you discovered this, Stuart! 😉

I finally read through your tutorial today. Really well done and an excellent contribution that belongs in the tips, ArchiGuide or Cookbook 4. Cookbook 3 does talk about Coons, but your lesson and examples are much more clear IMHO.

Thanks!
Karl
One of the forum moderators
AC 28 USA and earlier   •   macOS Sonoma 14.7.1, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Karl Ottenstein
Moderator
I just played with the Coons feature of ArchiForma 2.01 ... what fun!

Not surprisingly, since ArchiForma sends the 3D polyline points to a GDL Coons, spirals/etc can be made here, too. (For a spiral, I think doing the math in GDL is quite a bit easier than trying to draw precisely, and results in the perfection shown by Stuart.)

The cool thing about creating Coons surfaces in ArchiForma is that the resulting surface is editable! In the 3D window, editable hotspots at each point of each line allow you to change the position of that point. One hotspot lets you change the elevation (z), the other lets you move the point in the x-y plane. It's like playing with clay. 😉 Well, infinitely thin clay.

(The 3D polylines that you use to create the 4 edges are similarly editable.)

AF 2.01 also has a 2-D edit mode option for most elements that it creates, allowing graphical hotspot editing of the x/y/z values of every point while in plan. Brilliantly done, Cigraph!

Karl
One of the forum moderators
AC 28 USA and earlier   •   macOS Sonoma 14.7.1, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Anonymous
Not applicable


Thanks for all the flowers, guys!

Olivier; ok, when I have time I will do a 'demonstration' of the primitive 3d commands, promise. Actually they aren't as scary as they look!

Durval; I have never tried SEO's with planar objects (never felt the need to cut up something described geometrically). Does it work?? I would guess that it probably does - but maybe with occasional errors. Risky.

Karl; I don't have ArchiForma (yet?) - but Coons are generally a remarkably simple way to describe many 'objects' and (hollow) volumes. They deserve a better reputation than that which the GS help guide serves to imbue!

- Stuart