<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic From tetrahedron to sphere in Libraries &amp; objects</title>
    <link>https://community.graphisoft.com/t5/Libraries-objects/From-tetrahedron-to-sphere/m-p/195523#M15287</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;T&gt;There is a difference from the computer assisted design 2D and 3D. A curved line 2D in mathematics is written f(x,y)=0,  when a 3D surface is written  f(x,y,z)=0.  Both formulae represent a continuous group of points, in the plane 2D or in the space 3D. For example a circle with radius r and center O has equation:&lt;BR /&gt;
x^2+y^2-r^2=0&lt;BR /&gt;
A sphere has  equation:&lt;BR /&gt;
x^2+y^2+z^2-r^2=0&lt;BR /&gt;
By the introduction of a third coordinate w we entry in the hyperspace,&lt;BR /&gt;
with the hypersphere with four dimensions:&lt;BR /&gt;
x^2+y^2+z^2+w^2-r^2=0&lt;BR /&gt;
We can write in other way the equation of a sweep or of a surface, for example with the parametric form.&lt;BR /&gt;
A curved line, with one dimension and consequently with only one parameter, in 3D has this expression:&lt;BR /&gt;
x=f(u)&lt;BR /&gt;
y=g(u)&lt;BR /&gt;
z=h(u)&lt;BR /&gt;
In 2D space the third equation is omitted.&lt;BR /&gt;
For a surface, that have 2 dimension, the parameters are 2 too.&lt;BR /&gt;
x=f(u,v)&lt;BR /&gt;
y=g(u,v)&lt;BR /&gt;
z=h(u,v)&lt;BR /&gt;
We can notice in this formula that, if a parameter is fixed, for example v=vo (real number), we don’t have a surface, but a line.  For we can choose an infinity of real values to  assign to the parameter v, we can imagine the surface as composed of an infinity of curved lines, each near one the other: a bundle of lines. The bundles we can imagine are two: we can have a bundle with the parameter v fixed, we can have the other bundle with the other parameter u fixed.&lt;BR /&gt;
For example a circle centered in O has equations:&lt;BR /&gt;
x=r*cos(u)&lt;BR /&gt;
y=r*sin(u)&lt;BR /&gt;
with  0&amp;lt;=u&amp;lt;360  (u in degree)&lt;BR /&gt;
The sphere has equation:&lt;BR /&gt;
x=r*cos(u)*cos(v)&lt;BR /&gt;
y=r*sin(u) *cos(v)&lt;BR /&gt;
z=r* sin(v)&lt;BR /&gt;
with  0&amp;lt;=u&amp;lt;360  (u is azimut  or  longitude) ,  - 90&amp;lt;=u&amp;lt;=90  (v is  latitude, that assumes value 0 on the equator).&lt;BR /&gt;
If we fix the value v, while u is a parameter that assumes values from -90 to 90 or from 0 to 180, we have a parallel of the sphere. With many values of v, that is with many parallels, we can build a form that have the same structure of the sphere.&lt;BR /&gt;
If we fix the value u, and if we consider v as parameter,  we have a meridian of the sphere. With many values of v, that is with many meridians that cross the pole, we can build in other way the structure of the sphere.&lt;BR /&gt;
&lt;BR /&gt;
The majority of 2D vector  programs can build line 2D as circles or ellipses, that are effective curved lines and if we expand with the zoom the image, the line has not discontinuity, for the computer calculate every time the number and the position of the points.&lt;BR /&gt;
&lt;BR /&gt;
For example the command 2D:&lt;BR /&gt;
circle2  xc,yc, r&lt;BR /&gt;
creates a effective circle&lt;BR /&gt;
&lt;BR /&gt;
On the contrary, the command&lt;BR /&gt;
resol n   !n&amp;gt;3&lt;BR /&gt;
circle r&lt;BR /&gt;
don’t create a circle, but a polygon with n sides.&lt;BR /&gt;
The 3D vector programs cannot builds curved surfaces nor curved lines.&lt;BR /&gt;
Surfaces in 3D are replaced with a number of plane polygons: the vertices of these polygons belong to the surface.&lt;BR /&gt;
Lines in 3D are replaced with a number of segments: the vertices of these segments belong to the curved line&lt;BR /&gt;
The computer cannot bring at the outside, at the infinity, this number of polygons or segments: the concept of infinity is an abstraction.  The computer cannot build a soft surface or a continuous line, without  corner, as we imagine them, the computer can only build a substitute.&lt;BR /&gt;
For this reason we can build with a CAD program a "sphere" in many ways: the shape we build isn’t really a sphere, but an approximation.  We can build a sphere starting from different shapes, for example with the platonic bodies, that are tetrahedron, cube, octahedron, dodecahedron, icosahedron.&lt;BR /&gt;
Generally the sphere we find in CAD programs is generated from the octahedron, for the surface is built with parallels and meridians.&lt;BR /&gt;
The command sphere don’t allow to create the octahedron, for the minimum value of resolution is 3:&lt;BR /&gt;
resol 3&lt;BR /&gt;
sphere 1&lt;BR /&gt;
Now I present a script that allow to create a sphere primitive starting from the octahedron.&lt;BR /&gt;
&lt;BR /&gt;
!!!Instructions that allow to create the GDL-object in the imagine. Name: “sfera primitiva”&lt;BR /&gt;
&lt;BR /&gt;
!parameters -------------------------------------------------:&lt;BR /&gt;
m=12 !integer, resolution:m=2 tetrahedron&lt;BR /&gt;
xc=0&lt;BR /&gt;
yc=0&lt;BR /&gt;
zc=0 !sphere center coordinates&lt;BR /&gt;
r=1  !radius&lt;BR /&gt;
j1=0  !bit hide edges&lt;BR /&gt;
j2=1  !bit smooth surface&lt;BR /&gt;
mt=12 !index material&lt;BR /&gt;
&lt;BR /&gt;
!TEXT 2D ----------------------------------------------------:&lt;BR /&gt;
circle2 xc,yc,r&lt;BR /&gt;
&lt;BR /&gt;
!TEXT 3D----------------------------------------------------:&lt;BR /&gt;
if m&amp;lt;2 then end&lt;BR /&gt;
&lt;BR /&gt;
pen 21&lt;BR /&gt;
material mt&lt;BR /&gt;
&lt;BR /&gt;
base&lt;BR /&gt;
&lt;BR /&gt;
Vert xc,yc,zc+r   !polo nord&lt;BR /&gt;
for j=1 to m-1&lt;BR /&gt;
for i=0 to 2*m-1&lt;BR /&gt;
v=90-180/m*j    !j=0 polo N: v=90; j=m, polo sud: v=-90&lt;BR /&gt;
u=180/m*i&lt;BR /&gt;
Vert xc+ cos(u)* r*cos(v),yc+sin(u)* r*cos(v),zc+r*sin(v)&lt;BR /&gt;
next i&lt;BR /&gt;
next j&lt;BR /&gt;
Vert xc,yc,zc-r   !polo sud&lt;BR /&gt;
&lt;BR /&gt;
for j=0 to m-2&lt;BR /&gt;
for i=1 to 2*m-1&lt;BR /&gt;
EDGE 1+2*m*j+i,1+2*m*j+i+1, -1, -1,j1+j2*2&lt;BR /&gt;
next i&lt;BR /&gt;
EDGE 1+2*m*j+2*m,1+2*m*j+1, -1, -1,j1+j2*2&lt;BR /&gt;
next j&lt;BR /&gt;
for j=0 to m-3&lt;BR /&gt;
for i=1 to 2*m&lt;BR /&gt;
EDGE 1+i+2*m*j,1+2*m+i+2*m*j, -1, -1,j1+j2*2&lt;BR /&gt;
next i&lt;BR /&gt;
next j&lt;BR /&gt;
for i=1 to 2*m&lt;BR /&gt;
EDGE 1+i,1, -1, -1,j1+j2*2&lt;BR /&gt;
next i&lt;BR /&gt;
for i=1 to 2*m&lt;BR /&gt;
EDGE 1+2*m*(m-2)+i,2*m*(m-1)+2, -1, -1,j1+j2*2&lt;BR /&gt;
next i&lt;BR /&gt;
&lt;BR /&gt;
for i=1 to 2*m-1&lt;BR /&gt;
PGON 3, 0, -1, i,2*m*(2*m-3)+1+i,-(2*m*(2*m-3)+i) !calotta nord&lt;BR /&gt;
PGON 3, 0, -1, -(2*m*(m-2)+i),(2*m*(2*m-2)+i),-(2*m*(2*m-2)+1+i) !calotta sud&lt;BR /&gt;
next i&lt;BR /&gt;
PGON 3, 0, -1, 2*m,2*m*(2*m-3)+1,-2*m*(2*m-2) !chiusura calotta nord&lt;BR /&gt;
PGON 3, 0, -1, -2*m*(m-1),2*m*(2*m-1),-2*m*(2*m-2)-1 !chiusura calotta sud&lt;BR /&gt;
&lt;BR /&gt;
for j=0 to m-3&lt;BR /&gt;
for i=1 to 2*m-1&lt;BR /&gt;
PGON 4, 0, -1, -i-j*2*m,2*m*(m-1)+i+j*2*m ,2*m+i+j*2*m,-(2*m*(m-1)+1+i+j*2*m)&lt;BR /&gt;
next i&lt;BR /&gt;
PGON 4, 0, -1, -2*m-j*2*m, 2*m^2+j*2*m ,4*m+j*2*m,-(2*m*(m-1)+1+j*2*m)&lt;BR /&gt;
next j&lt;BR /&gt;
&lt;BR /&gt;
body -1&lt;BR /&gt;
&lt;BR /&gt;
end&lt;BR /&gt;
&lt;BR /&gt;
!!!COMMENT&lt;BR /&gt;
This script allow to apply some variations to the surface, with a change in the script of vertices :&lt;BR /&gt;
For example a distortion in the distance of the parallels, that introduce a profile that isn't a semi-circle but an arc.&lt;BR /&gt;
&lt;BR /&gt;
dh=.1&lt;BR /&gt;
&lt;BR /&gt;
Vert xc,yc,zc+r   !polo nord&lt;BR /&gt;
for j=1 to m-1&lt;BR /&gt;
addz -dh*j&lt;BR /&gt;
for i=0 to 2*m-1&lt;BR /&gt;
v=90-180/m*j    !j=0 polo N: v=90; j=m, polo sud: v=-90&lt;BR /&gt;
u=180/m*i&lt;BR /&gt;
Vert xc+ cos(u)* r*cos(v),yc+sin(u)* r*cos(v),zc+r*sin(v)&lt;BR /&gt;
next i&lt;BR /&gt;
del 1&lt;BR /&gt;
next j&lt;BR /&gt;
Vert xc,yc,zc-r-dh*j   !polo sud&lt;/T&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;IMG src="http://community.graphisoft.com/t5/image/serverpage/image-id/67440i7970CCF25B90F2E9/image-size/large?v=v2&amp;amp;px=999" border="0" alt="sfera primitiva.jpg" title="sfera primitiva.jpg" /&gt;</description>
    <pubDate>Thu, 20 Sep 2012 15:42:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-09-20T15:42:36Z</dc:date>
    <item>
      <title>From tetrahedron to sphere</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/From-tetrahedron-to-sphere/m-p/195523#M15287</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;T&gt;There is a difference from the computer assisted design 2D and 3D. A curved line 2D in mathematics is written f(x,y)=0,  when a 3D surface is written  f(x,y,z)=0.  Both formulae represent a continuous group of points, in the plane 2D or in the space 3D. For example a circle with radius r and center O has equation:&lt;BR /&gt;
x^2+y^2-r^2=0&lt;BR /&gt;
A sphere has  equation:&lt;BR /&gt;
x^2+y^2+z^2-r^2=0&lt;BR /&gt;
By the introduction of a third coordinate w we entry in the hyperspace,&lt;BR /&gt;
with the hypersphere with four dimensions:&lt;BR /&gt;
x^2+y^2+z^2+w^2-r^2=0&lt;BR /&gt;
We can write in other way the equation of a sweep or of a surface, for example with the parametric form.&lt;BR /&gt;
A curved line, with one dimension and consequently with only one parameter, in 3D has this expression:&lt;BR /&gt;
x=f(u)&lt;BR /&gt;
y=g(u)&lt;BR /&gt;
z=h(u)&lt;BR /&gt;
In 2D space the third equation is omitted.&lt;BR /&gt;
For a surface, that have 2 dimension, the parameters are 2 too.&lt;BR /&gt;
x=f(u,v)&lt;BR /&gt;
y=g(u,v)&lt;BR /&gt;
z=h(u,v)&lt;BR /&gt;
We can notice in this formula that, if a parameter is fixed, for example v=vo (real number), we don’t have a surface, but a line.  For we can choose an infinity of real values to  assign to the parameter v, we can imagine the surface as composed of an infinity of curved lines, each near one the other: a bundle of lines. The bundles we can imagine are two: we can have a bundle with the parameter v fixed, we can have the other bundle with the other parameter u fixed.&lt;BR /&gt;
For example a circle centered in O has equations:&lt;BR /&gt;
x=r*cos(u)&lt;BR /&gt;
y=r*sin(u)&lt;BR /&gt;
with  0&amp;lt;=u&amp;lt;360  (u in degree)&lt;BR /&gt;
The sphere has equation:&lt;BR /&gt;
x=r*cos(u)*cos(v)&lt;BR /&gt;
y=r*sin(u) *cos(v)&lt;BR /&gt;
z=r* sin(v)&lt;BR /&gt;
with  0&amp;lt;=u&amp;lt;360  (u is azimut  or  longitude) ,  - 90&amp;lt;=u&amp;lt;=90  (v is  latitude, that assumes value 0 on the equator).&lt;BR /&gt;
If we fix the value v, while u is a parameter that assumes values from -90 to 90 or from 0 to 180, we have a parallel of the sphere. With many values of v, that is with many parallels, we can build a form that have the same structure of the sphere.&lt;BR /&gt;
If we fix the value u, and if we consider v as parameter,  we have a meridian of the sphere. With many values of v, that is with many meridians that cross the pole, we can build in other way the structure of the sphere.&lt;BR /&gt;
&lt;BR /&gt;
The majority of 2D vector  programs can build line 2D as circles or ellipses, that are effective curved lines and if we expand with the zoom the image, the line has not discontinuity, for the computer calculate every time the number and the position of the points.&lt;BR /&gt;
&lt;BR /&gt;
For example the command 2D:&lt;BR /&gt;
circle2  xc,yc, r&lt;BR /&gt;
creates a effective circle&lt;BR /&gt;
&lt;BR /&gt;
On the contrary, the command&lt;BR /&gt;
resol n   !n&amp;gt;3&lt;BR /&gt;
circle r&lt;BR /&gt;
don’t create a circle, but a polygon with n sides.&lt;BR /&gt;
The 3D vector programs cannot builds curved surfaces nor curved lines.&lt;BR /&gt;
Surfaces in 3D are replaced with a number of plane polygons: the vertices of these polygons belong to the surface.&lt;BR /&gt;
Lines in 3D are replaced with a number of segments: the vertices of these segments belong to the curved line&lt;BR /&gt;
The computer cannot bring at the outside, at the infinity, this number of polygons or segments: the concept of infinity is an abstraction.  The computer cannot build a soft surface or a continuous line, without  corner, as we imagine them, the computer can only build a substitute.&lt;BR /&gt;
For this reason we can build with a CAD program a "sphere" in many ways: the shape we build isn’t really a sphere, but an approximation.  We can build a sphere starting from different shapes, for example with the platonic bodies, that are tetrahedron, cube, octahedron, dodecahedron, icosahedron.&lt;BR /&gt;
Generally the sphere we find in CAD programs is generated from the octahedron, for the surface is built with parallels and meridians.&lt;BR /&gt;
The command sphere don’t allow to create the octahedron, for the minimum value of resolution is 3:&lt;BR /&gt;
resol 3&lt;BR /&gt;
sphere 1&lt;BR /&gt;
Now I present a script that allow to create a sphere primitive starting from the octahedron.&lt;BR /&gt;
&lt;BR /&gt;
!!!Instructions that allow to create the GDL-object in the imagine. Name: “sfera primitiva”&lt;BR /&gt;
&lt;BR /&gt;
!parameters -------------------------------------------------:&lt;BR /&gt;
m=12 !integer, resolution:m=2 tetrahedron&lt;BR /&gt;
xc=0&lt;BR /&gt;
yc=0&lt;BR /&gt;
zc=0 !sphere center coordinates&lt;BR /&gt;
r=1  !radius&lt;BR /&gt;
j1=0  !bit hide edges&lt;BR /&gt;
j2=1  !bit smooth surface&lt;BR /&gt;
mt=12 !index material&lt;BR /&gt;
&lt;BR /&gt;
!TEXT 2D ----------------------------------------------------:&lt;BR /&gt;
circle2 xc,yc,r&lt;BR /&gt;
&lt;BR /&gt;
!TEXT 3D----------------------------------------------------:&lt;BR /&gt;
if m&amp;lt;2 then end&lt;BR /&gt;
&lt;BR /&gt;
pen 21&lt;BR /&gt;
material mt&lt;BR /&gt;
&lt;BR /&gt;
base&lt;BR /&gt;
&lt;BR /&gt;
Vert xc,yc,zc+r   !polo nord&lt;BR /&gt;
for j=1 to m-1&lt;BR /&gt;
for i=0 to 2*m-1&lt;BR /&gt;
v=90-180/m*j    !j=0 polo N: v=90; j=m, polo sud: v=-90&lt;BR /&gt;
u=180/m*i&lt;BR /&gt;
Vert xc+ cos(u)* r*cos(v),yc+sin(u)* r*cos(v),zc+r*sin(v)&lt;BR /&gt;
next i&lt;BR /&gt;
next j&lt;BR /&gt;
Vert xc,yc,zc-r   !polo sud&lt;BR /&gt;
&lt;BR /&gt;
for j=0 to m-2&lt;BR /&gt;
for i=1 to 2*m-1&lt;BR /&gt;
EDGE 1+2*m*j+i,1+2*m*j+i+1, -1, -1,j1+j2*2&lt;BR /&gt;
next i&lt;BR /&gt;
EDGE 1+2*m*j+2*m,1+2*m*j+1, -1, -1,j1+j2*2&lt;BR /&gt;
next j&lt;BR /&gt;
for j=0 to m-3&lt;BR /&gt;
for i=1 to 2*m&lt;BR /&gt;
EDGE 1+i+2*m*j,1+2*m+i+2*m*j, -1, -1,j1+j2*2&lt;BR /&gt;
next i&lt;BR /&gt;
next j&lt;BR /&gt;
for i=1 to 2*m&lt;BR /&gt;
EDGE 1+i,1, -1, -1,j1+j2*2&lt;BR /&gt;
next i&lt;BR /&gt;
for i=1 to 2*m&lt;BR /&gt;
EDGE 1+2*m*(m-2)+i,2*m*(m-1)+2, -1, -1,j1+j2*2&lt;BR /&gt;
next i&lt;BR /&gt;
&lt;BR /&gt;
for i=1 to 2*m-1&lt;BR /&gt;
PGON 3, 0, -1, i,2*m*(2*m-3)+1+i,-(2*m*(2*m-3)+i) !calotta nord&lt;BR /&gt;
PGON 3, 0, -1, -(2*m*(m-2)+i),(2*m*(2*m-2)+i),-(2*m*(2*m-2)+1+i) !calotta sud&lt;BR /&gt;
next i&lt;BR /&gt;
PGON 3, 0, -1, 2*m,2*m*(2*m-3)+1,-2*m*(2*m-2) !chiusura calotta nord&lt;BR /&gt;
PGON 3, 0, -1, -2*m*(m-1),2*m*(2*m-1),-2*m*(2*m-2)-1 !chiusura calotta sud&lt;BR /&gt;
&lt;BR /&gt;
for j=0 to m-3&lt;BR /&gt;
for i=1 to 2*m-1&lt;BR /&gt;
PGON 4, 0, -1, -i-j*2*m,2*m*(m-1)+i+j*2*m ,2*m+i+j*2*m,-(2*m*(m-1)+1+i+j*2*m)&lt;BR /&gt;
next i&lt;BR /&gt;
PGON 4, 0, -1, -2*m-j*2*m, 2*m^2+j*2*m ,4*m+j*2*m,-(2*m*(m-1)+1+j*2*m)&lt;BR /&gt;
next j&lt;BR /&gt;
&lt;BR /&gt;
body -1&lt;BR /&gt;
&lt;BR /&gt;
end&lt;BR /&gt;
&lt;BR /&gt;
!!!COMMENT&lt;BR /&gt;
This script allow to apply some variations to the surface, with a change in the script of vertices :&lt;BR /&gt;
For example a distortion in the distance of the parallels, that introduce a profile that isn't a semi-circle but an arc.&lt;BR /&gt;
&lt;BR /&gt;
dh=.1&lt;BR /&gt;
&lt;BR /&gt;
Vert xc,yc,zc+r   !polo nord&lt;BR /&gt;
for j=1 to m-1&lt;BR /&gt;
addz -dh*j&lt;BR /&gt;
for i=0 to 2*m-1&lt;BR /&gt;
v=90-180/m*j    !j=0 polo N: v=90; j=m, polo sud: v=-90&lt;BR /&gt;
u=180/m*i&lt;BR /&gt;
Vert xc+ cos(u)* r*cos(v),yc+sin(u)* r*cos(v),zc+r*sin(v)&lt;BR /&gt;
next i&lt;BR /&gt;
del 1&lt;BR /&gt;
next j&lt;BR /&gt;
Vert xc,yc,zc-r-dh*j   !polo sud&lt;/T&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;IMG src="http://community.graphisoft.com/t5/image/serverpage/image-id/67440i7970CCF25B90F2E9/image-size/large?v=v2&amp;amp;px=999" border="0" alt="sfera primitiva.jpg" title="sfera primitiva.jpg" /&gt;</description>
      <pubDate>Thu, 20 Sep 2012 15:42:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/From-tetrahedron-to-sphere/m-p/195523#M15287</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-20T15:42:36Z</dc:date>
    </item>
  </channel>
</rss>

