Design forum
cancel
Showing results for
Did you mean:

## From tetrahedron to sphere Anonymous
Not applicable
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:
x^2+y^2-r^2=0
A sphere has equation:
x^2+y^2+z^2-r^2=0
By the introduction of a third coordinate w we entry in the hyperspace,
with the hypersphere with four dimensions:
x^2+y^2+z^2+w^2-r^2=0
We can write in other way the equation of a sweep or of a surface, for example with the parametric form.
A curved line, with one dimension and consequently with only one parameter, in 3D has this expression:
x=f(u)
y=g(u)
z=h(u)
In 2D space the third equation is omitted.
For a surface, that have 2 dimension, the parameters are 2 too.
x=f(u,v)
y=g(u,v)
z=h(u,v)
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.
For example a circle centered in O has equations:
x=r*cos(u)
y=r*sin(u)
with 0<=u<360 (u in degree)
The sphere has equation:
x=r*cos(u)*cos(v)
y=r*sin(u) *cos(v)
z=r* sin(v)
with 0<=u<360 (u is azimut or longitude) , - 90<=u<=90 (v is latitude, that assumes value 0 on the equator).
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.
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.

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.

For example the command 2D:
circle2 xc,yc, r
creates a effective circle

On the contrary, the command
resol n !n>3
circle r
don’t create a circle, but a polygon with n sides.
The 3D vector programs cannot builds curved surfaces nor curved lines.
Surfaces in 3D are replaced with a number of plane polygons: the vertices of these polygons belong to the surface.
Lines in 3D are replaced with a number of segments: the vertices of these segments belong to the curved line
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.
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.
Generally the sphere we find in CAD programs is generated from the octahedron, for the surface is built with parallels and meridians.
The command sphere don’t allow to create the octahedron, for the minimum value of resolution is 3:
resol 3
sphere 1
Now I present a script that allow to create a sphere primitive starting from the octahedron.

!!!Instructions that allow to create the GDL-object in the imagine. Name: “sfera primitiva”

!parameters -------------------------------------------------:
m=12 !integer, resolution:m=2 tetrahedron
xc=0
yc=0
zc=0 !sphere center coordinates
j1=0 !bit hide edges
j2=1 !bit smooth surface
mt=12 !index material

!TEXT 2D ----------------------------------------------------:
circle2 xc,yc,r

!TEXT 3D----------------------------------------------------:
if m<2 then end

pen 21
material mt

base

Vert xc,yc,zc+r !polo nord
for j=1 to m-1
for i=0 to 2*m-1
v=90-180/m*j !j=0 polo N: v=90; j=m, polo sud: v=-90
u=180/m*i
Vert xc+ cos(u)* r*cos(v),yc+sin(u)* r*cos(v),zc+r*sin(v)
next i
next j
Vert xc,yc,zc-r !polo sud

for j=0 to m-2
for i=1 to 2*m-1
EDGE 1+2*m*j+i,1+2*m*j+i+1, -1, -1,j1+j2*2
next i
EDGE 1+2*m*j+2*m,1+2*m*j+1, -1, -1,j1+j2*2
next j
for j=0 to m-3
for i=1 to 2*m
EDGE 1+i+2*m*j,1+2*m+i+2*m*j, -1, -1,j1+j2*2
next i
next j
for i=1 to 2*m
EDGE 1+i,1, -1, -1,j1+j2*2
next i
for i=1 to 2*m
EDGE 1+2*m*(m-2)+i,2*m*(m-1)+2, -1, -1,j1+j2*2
next i

for i=1 to 2*m-1
PGON 3, 0, -1, i,2*m*(2*m-3)+1+i,-(2*m*(2*m-3)+i) !calotta nord
PGON 3, 0, -1, -(2*m*(m-2)+i),(2*m*(2*m-2)+i),-(2*m*(2*m-2)+1+i) !calotta sud
next i
PGON 3, 0, -1, 2*m,2*m*(2*m-3)+1,-2*m*(2*m-2) !chiusura calotta nord
PGON 3, 0, -1, -2*m*(m-1),2*m*(2*m-1),-2*m*(2*m-2)-1 !chiusura calotta sud

for j=0 to m-3
for i=1 to 2*m-1
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)
next i
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)
next j

body -1

end

!!!COMMENT
This script allow to apply some variations to the surface, with a change in the script of vertices :
For example a distortion in the distance of the parallels, that introduce a profile that isn't a semi-circle but an arc.

dh=.1

Vert xc,yc,zc+r !polo nord
for j=1 to m-1
for i=0 to 2*m-1
v=90-180/m*j !j=0 polo N: v=90; j=m, polo sud: v=-90
u=180/m*i
Vert xc+ cos(u)* r*cos(v),yc+sin(u)* r*cos(v),zc+r*sin(v)
next i
del 1
next j
Vert xc,yc,zc-r-dh*j !polo sud
0 REPLIES 0 Labels
Latest solutions