Category : OS/2 Files
Archive   : IRIT-OS2.ZIP
Filename : FREEFORM.IRT

 
Output of file : FREEFORM.IRT contained in archive : IRIT-OS2.ZIP
#
# Some routines to test surface/curve operators
#

#
# Set display to on to view some results, off to view nothing.
#
display = on;

#
# Control the surface to polygons subdivison resolution, and isolines gen.
#
save_res = resolution;
resolution = 20;
if ( machine, "=", msdos, (resolution = 5));
drawctlpt = red;

s45 = sin( pi / 4 );

#
# Circular constructors
#

circ = circle( vector( 0.25, 0.5, 0.5 ), 1.5 );
arc1 = arc( vector( 0.0, 0.0, 0.0 ),
vector( 0.5, 2.0, 0.0 ),
vector( 1.0, 0.0, 0.0 ) );
arc2 = arc( vector( 0.0, 0.0, 0.0 ),
vector( 0.0, 2.0, 0.5 ),
vector( 0.0, 0.0, 1.0 ) );

if ( display, "=", on, interact( list( axes, circ, arc1, arc2 ), 0 ) );

#
# Piecewise linear approximation to a curve using ceval:
#
cb = ceval( circ, 0.0 );
cb_all = list( cb );
for ( (t = 0.2), 0.2, 4.0,
(
(cb = ceval( circ, t ) ):
snoc( cb, cb_all )
)
);
cb_crv = cbspline( 2, cb_all, list( KV_OPEN ) );
color( cb_crv, yellow );
if ( display, "=", on, interact( list( cb_crv, circ, axes ), 0 ) );
free( cb_crv ); free( cb_all ); free( cb );

#
# Ruled surface constructor examples.
#
arc3 = arc( vector( 0.0, 0.0, 1.0 ),
vector( 0.5, -0.2, 1.0 ),
vector( 1.0, 0.0, 1.0 ) );
ruled = ruledsrf( arc3,
ctlpt( E2, 0.0, 0.0 ) + ctlpt( E2, 1.0, 0.0 ) );
if ( display, "=", on, interact( list( axes, ruled ), 0 ) );
free( ruled );

circ = circle( vector( 0.0, 0.0, 0.0 ), 0.25 );
cyl = ruledsrf( circ, circ*trans( vector( 0.0, 0.0, 1.0 ) ) );
if ( display, "=", on, interact( list( axes, cyl ), 0 ) );
free( cyl );

skewcyl = ruledsrf( circ, circ*trans( vector( 0.2, 0.0, 1.0 ) ) );
if ( display, "=", on, interact( list( axes, skewcyl ), 0 ) );
free( skewcyl );

skew2cyl = ruledsrf( circ*rotx( 20 ),
circ*rotx( -20 )* trans( vector( 0.0, 0.0, 1.0 ) ) );
if ( display, "=", on, interact( list( axes, skew2cyl ), 0 ) );
free( skew2cyl );

drawctlpt = 0;
free( arc1 ); free( arc2 ); free( arc3 ); free( circ );

#
# Curve constructors.
#
crv1 = ctlpt( E3, 0.5, 0.0, 1.0 ) +
ctlpt( E3, 0.5, 0.0, 1.2 ) +
ctlpt( E3, 1.0, 0.0, 1.2 );
crv2 = crv1 +
arc( vector( 1.0, 0.0, 0.75 ),
vector( 0.75, 0.0, 0.7 ),
vector( 0.5, 0.0, 0.85 ) ) +
arc( vector( 0.5, 0.0, 0.75 ),
vector( 0.75, 0.0, 0.8 ),
vector( 1.0, 0.0, 0.65 ) );
crv3 = crv2 +
crv2 * trans( vector( -0.5, 0.15, -0.5 ) ) +
crv2 * trans( vector( -1.0, 0.3, -1.0 ) );
resolution = 60;
if ( display, "=", on, interact( list( axes, crv3 ), 0 ) );
resolution = 20;
if ( machine, "=", msdos, (resolution = 5));
free( crv1 ); free( crv2 ); free( crv3 );

cross = arc( vector( 0.2, 0.0, 0.0 ),
vector( 0.2, 0.2, 0.0 ),
vector( 0.0, 0.2, 0.0 ) ) +
arc( vector( 0.0, 0.4, 0.0 ),
vector( 0.1, 0.4, 0.0 ),
vector( 0.1, 0.5, 0.0 ) ) +
arc( vector( 0.8, 0.5, 0.0 ),
vector( 0.8, 0.3, 0.0 ),
vector( 1.0, 0.3, 0.0 ) ) +
arc( vector( 1.0, 0.1, 0.0 ),
vector( 0.9, 0.1, 0.0 ),
vector( 0.9, 0.0, 0.0 ) ) +
ctlpt( E2, 0.2, 0.0 );
if ( display, "=", on, interact( list( axes, cross ), 0 ) );

#
# Curves and surfaces convertions and compatibility.
#
crv1 = cbezier( list( ctlpt( E2, -1, 0 ),
ctlpt( E2, 0, 2 ),
ctlpt( E2, 1, 0 ) ) );
crv2 = cbspline( 4,
list( ctlpt( P3, 1.0, 0.0, 0.1, 1.0 ),
ctlpt( P3, s45, -s45, 1.0, s45 ),
ctlpt( P3, 1.0, 1.0, 0.1, 0.0 ),
ctlpt( P3, s45, -s45, 1.0, -s45 ),
ctlpt( P3, 1.0, 0.0, 0.1, -1.0 ) ),
list( KV_OPEN ) );
color( crv1, yellow );
color( crv2, yellow );

crv1bsp = bzr2bsp( crv1 );
color( crv1bsp, green );
crv2bzr = bsp2bzr( crv2 );
color( crv2bzr, green );
interact( list( crv1bsp, crv1, crv2bzr, crv2 ), 0 );
free( crv1bsp );
free( crv2bzr );

interact( list( crv1, crv2 ), 0 );
ffcompat( crv1, crv2 );
interact( list( crv1, crv2 ), 0 );

srf1 = sbezier( list( list( ctlpt( E2, 0.0, 0.0 ),
ctlpt( E2, 0.0, 1.0 ),
ctlpt( E2, 0.0, 2.0 ) ),
list( ctlpt( E2, 1.0, 0.0 ),
ctlpt( E2, 1.0, 1.0 ),
ctlpt( E2, 1.0, 2.0 ) ) ) );
srf2 = sbspline( 2, 4,
list( list( ctlpt( E3, 0.0, 0.0, 1.0 ),
ctlpt( E3, 0.0, 1.0, 0.0 ),
ctlpt( E3, 0.0, 2.0, 1.0 ) ),
list( ctlpt( E3, 1.0, 0.0, 0.0 ),
ctlpt( E3, 1.0, 1.0, 2.0 ),
ctlpt( E3, 1.0, 2.0, 0.0 ) ),
list( ctlpt( E3, 2.0, 0.0, 2.0 ),
ctlpt( E3, 2.0, 1.0, 0.0 ),
ctlpt( E3, 2.0, 2.0, 2.0 ) ),
list( ctlpt( E3, 3.0, 0.0, 0.0 ),
ctlpt( E3, 3.0, 1.0, 2.0 ),
ctlpt( E3, 3.0, 2.0, 0.0 ) ),
list( ctlpt( E3, 4.0, 0.0, 1.0 ),
ctlpt( E3, 4.0, 1.0, 0.0 ),
ctlpt( E3, 4.0, 2.0, 1.0 ) ) ),
list( list( KV_OPEN ),
list( KV_OPEN ) ) );
color( srf1, yellow );
color( srf2, yellow );

srf1bsp = bzr2bsp( srf1 );
color( srf1bsp, green );
srf2bzr = bsp2bzr( srf2 );
color( srf2bzr, green );
interact( list( srf1bsp, srf1, srf2bzr, srf2 ), 0 );
free( srf1bsp );
free( srf2bzr );

interact( list( srf1, srf2 ), 0 );
ffcompat( srf1, srf2 );
interact( list( srf1, srf2 ), 0 );

#
# Direct control points manipulation.
#
cb = cbezier( list( ctlpt( E3, -1, 0, 0 ),
ctlpt( E3, 0, 0, 0 ),
ctlpt( E3, 1, 0, 0 ) ) );

cb1 = 0; # Define a dummy variable to use in loop.
cb_all = list( axes );
for ( (z = -0.9), 0.3, 0.9,
(
(cb1 = ceditpt( cb, ctlpt( E3, 0, 0, z ), 1 )):
color( cb1, green ):
snoc( cb1, cb_all )
)
);
if ( display, "=", on, interact( cb_all, 0 ) );
free( cb_all ); free( cb ); free( cb1 );


sb = ruledSrf( cbezier( list( ctlpt( E3, -0.5, -0.5, 0.0 ),
ctlpt( E3, 0.5, -0.5, 0.0 ) ) ),
cbezier( list( ctlpt( E3, -0.5, 0.5, 0.0 ),
ctlpt( E3, 0.5, 0.5, 0.0 ) ) ) );
sb = sraise( sraise( sb, row, 3 ),
col, 3 );
sb = srefine( srefine( sb, row, false, list( 0.333, 0.667 ) ),
col, false, list( 0.333, 0.667 ) );
sb1 = 0; # Define a dummy variable to use in loop.
sb_all = list( axes );
for ( (z = -0.9), 0.6, 0.9,
(
(sb1 = seditpt( sb, ctlpt( E3, 0, 0, z ), 2, 2 )):
color( sb1, green ):
snoc( sb1, sb_all )
)
);
if ( display, "=", on, interact( sb_all, 0 ) );
free( sb_all ); free( sb ); free( sb1 );

#
# Curve order raise:
#
cb = cbezier( list( ctlpt( E2, -1, 0 ),
ctlpt( E2, 0, 2 ),
ctlpt( E2, 1, 0 ) ) );

cb1 = 0; # Define a dummy variable to use in loop.
cb_all = list( axes, cb );
for ( (o = 4), 1, 8,
(
(cb1 = craise( cb, o )):
color( cb1, green ):
snoc( cb1, cb_all )
)
);
if ( display, "=", on, interact( cb_all, 0 ) );
free( cb_all ); free( cb ); free( cb1 );

#
# Extrusion examples.
#
cbzr = cbezier( list( ctlpt( E2, 0.0, 0.0 ),
ctlpt( E2, 1.0, 0.0 ),
ctlpt( E2, 1.0, 1.0 ) ) );
color( cbzr, white );

s = extrude( cbzr, vector( 0.0, 0.0, 1.0 ) );

if ( display, "=", on, interact( list( axes, s, cbzr ), 0 ) );
free( cbzr ); free( s );

s = extrude( cross, vector( 0.0, 0.0, 1.0 ) );
if ( display, "=", on, interact( list( axes, s ), 0 ) );

s = extrude( cross, vector( 0.1, 0.2, 1.0 ) );
if ( display, "=", on, interact( list( axes, s ), 0 ) );

resolution = 10;
ps = gpolygon( s );
if ( display, "=", on, interact( list( axes, ps ), 0 ) );
free( ps );
free( s );
resolution = 20;
if ( machine, "=", msdos, (resolution = 5));

#
# Srf of revolution examples
#

cbzr = cbezier( list( ctlpt( E3, 0.0, 0.0, 0.0 ),
ctlpt( E3, 1.0, 0.0, 0.0 ),
ctlpt( E3, 1.0, 0.0, 1.0 ) ) );
color( cbzr, white );

sb = surfrev( cbzr );

interact( list( sb, cbzr ), 0 );

halfcirc = cbspline( 3,
list( ctlpt( P3, 1.0, 0.0, 0.0, 1.0 ),
ctlpt( P3, s45, -s45, 0.0, s45 ),
ctlpt( P3, 1.0, -1.0, 0.0, 0.0 ),
ctlpt( P3, s45, -s45, 0.0, -s45 ),
ctlpt( P3, 1.0, 0.0, 0.0, -1.0 ) ),
list( 0, 0, 0, 1, 1, 2, 2, 2 ) );
color( halfcirc, white );

sp = surfrev( halfcirc );

interact( list( sp, halfcirc ), 0 );

gcross = cbspline( 3,
list( ctlpt( E3, 0.3, 0.0, 0.0 ),
ctlpt( E3, 0.3, 0.0, 0.05 ),
ctlpt( E3, 0.1, 0.0, 0.05 ),
ctlpt( E3, 0.1, 0.0, 0.4 ),
ctlpt( E3, 0.5, 0.0, 0.4 ),
ctlpt( E3, 0.6, 0.0, 0.8 ) ),
list( 0, 0, 0, 1, 2, 3, 4, 4, 4 ) );
color( gcross, white );
glass = surfrev( gcross );
interact(list(axes, glass, gcross), 0);

#
# Sweep examples.
#

arc1 = arc( vector( 1.0, 0.0, 0.0 ),
vector( 0.0, 0.0, 0.0 ),
vector( 0.0, 1.0, 0.0 ) );
s = sweepsrf( cross, arc1, 0.2 );
if ( display, "=", on, interact( list( axes, s ), 0 ) );

arc1 = arc( vector( -1.0, 0.0, 0.0 ),
vector( 0.0, 0.0, 0.1 ),
vector( 1.0, 0.0, 0.0 ) );
arc1 = crefine( arc1, false, list( 0.25, 0.5, 0.75 ) );
scalecrv = cbezier( list( ctlpt( E2, 0.0, 0.1 ),
ctlpt( E2, 1.0, 0.5 ),
ctlpt( E2, 2.0, 0.1 ) ) );
s = sweepsrf( cross, arc1, scalecrv );
if ( display, "=", on, interact( list( axes, s ), 0 ) );

circ = circle( vector( 0.0, 0.0, 0.0 ), 1.0 );

s = sweepsrf( circ, circ, 0.25 );
if ( display, "=", on, interact( list( axes, s ), 0 ) );

resolution = 10;
ps = gpolygon( s );
if ( display, "=", on, interact( list( axes, ps ), 0 ) );
free( ps );
resolution = 20;
if ( machine, "=", msdos, (resolution = 5));

s = sweepsrf( circ, circ, scalecrv );
if ( display, "=", on, interact( list( axes, s ), 0 ) );

free( cross );
free( circ );
free( arc1 );

#
# Boolean sum examples.
#
cbzr1 = cbezier( list( ctlpt( E3, -0.2, 0.1, 0.5 ),
ctlpt( E3, 0.0, 0.5, 1.0 ),
ctlpt( E3, 0.1, 1.0, -0.2 ) ) );
cbzr2 = cbezier( list( ctlpt( E3, 1.0, 0.0, -0.3 ),
ctlpt( E3, 0.8, 0.5, -1.0 ),
ctlpt( E3, 1.0, 1.0, 0.2 ) ) );
cbzr3 = cbezier( list( ctlpt( E3, -0.2, 0.1, 0.5 ),
ctlpt( E3, 0.5, 0.0, -1.0 ),
ctlpt( E3, 1.0, 0.0, -0.3 ) ) );
cbzr4 = cbezier( list( ctlpt( E3, 0.1, 1.0, -0.2 ),
ctlpt( E3, 0.5, 1.0, 1.0 ),
ctlpt( E3, 1.0, 1.0, 0.2 ) ) );

s = boolsum( cbzr1, cbzr2, cbzr3, cbzr4 );
color(s, green);
if ( display, "=", on, interact( list( axes, s, cbzr1, cbzr2, cbzr3, cbzr4 ), 0 ) );

cbzr1 = cbezier( list( ctlpt( E3, -0.1, 0.1, 0.2 ),
ctlpt( E3, 0.0, 0.5, 1.0 ),
ctlpt( E3, 0.1, 1.0, 0.2 ) ) );
cbzr2 = cbezier( list( ctlpt( E3, 1.0, 0.2, -0.1 ),
ctlpt( E3, 1.0, 0.5, -1.0 ),
ctlpt( E3, 1.1, 1.1, 0.1 ) ) );
cbzr3 = cbezier( list( ctlpt( E3, -0.1, 0.1, 0.2 ),
ctlpt( E3, 0.2, 0.1, -1.0 ),
ctlpt( E3, 0.4, 0.0, 2.0 ),
ctlpt( E3, 0.5, -0.1, -1.0 ),
ctlpt( E3, 1.0, 0.2, -0.1 ) ) );
cbzr4 = cbezier( list( ctlpt( E3, 0.1, 1.0, 0.2 ),
ctlpt( E3, 0.5, 0.8, 1.0 ),
ctlpt( E3, 0.7, 0.9, -2.0 ),
ctlpt( E3, 0.8, 1.0, 1.0 ),
ctlpt( E3, 1.1, 1.1, 0.1 ) ) );
s = boolsum( cbzr1, cbzr2, cbzr3, cbzr4 );
color(s, green);
if ( display, "=", on, interact( list( axes, s, cbzr1, cbzr2, cbzr3, cbzr4 ), 0 ) );

cbzr1 = cbezier( list( ctlpt( E3, 0.1, 0.1, 0.1 ),
ctlpt( E3, 0.0, 0.5, 1.0 ),
ctlpt( E3, 0.4, 1.0, 0.4 ) ) );
cbzr2 = cbezier( list( ctlpt( E3, 1.0, 0.2, 0.2 ),
ctlpt( E3, 1.0, 0.5, -1.0 ),
ctlpt( E3, 1.0, 1.0, 0.3 ) ) );
cbsp3 = cbspline( 4,
list( ctlpt( E3, 0.1, 0.1, 0.1 ),
ctlpt( E3, 0.25, 0.0, -1.0 ),
ctlpt( E3, 0.5, 0.0, 2.0 ),
ctlpt( E3, 0.75, 0.0, -1.0 ),
ctlpt( E3, 1.0, 0.2, 0.2 ) ),
list( KV_OPEN ) );
cbsp4 = cbspline( 4,
list( ctlpt( E3, 0.4, 1.0, 0.4 ),
ctlpt( E3, 0.25, 1.0, 1.0 ),
ctlpt( E3, 0.5, 1.0, -2.0 ),
ctlpt( E3, 0.75, 1.0, 1.0 ),
ctlpt( E3, 1.0, 1.0, 0.3 ) ),
list( KV_OPEN ) );

s = boolsum( cbzr1, cbzr2, cbsp3, cbsp4 );
color(s, green);
if ( display, "=", on, interact( list( axes, s, cbzr1, cbzr2, cbsp3, cbsp4 ), 0 ) );

free( cbzr1 ); free( cbzr2 ); free( cbzr3 ); free( cbzr4 );
free( cbsp1 ); free( cbsp2 );

#
# Boolean one examples.
#
s = boolone( circle( vector( 0.0, 0.0, 0.0 ), 1.0 ) );
color(s, green);
if ( display, "=", on, interact( list( axes, s ), 0 ) );

c1 = ctlpt( E3, 0, 0, 0.5 ) +
ctlpt( E3, 1, 0, 0 ) +
ctlpt( E3, 1, 1, 0.5 ) +
ctlpt( E3, 0, 1, 0 ) +
ctlpt( E3, 0, 0, 0.5 );
s = boolone( c1 );
color(s, green);
if ( display, "=", on, interact( list( axes, s, c1 ), 0 ) );

#
# Surface from curves constructor.
#

c1 = cbspline( 3,
list( ctlpt( E3, 0.0, 0.0, 0.0 ),
ctlpt( E3, 1.0, 0.0, 0.0 ),
ctlpt( E3, 1.0, 1.0, 0.0 ) ),
list( KV_OPEN ) );
c2 = cbspline( 3,
list( ctlpt( E3, 0.0, 0.0, 1.0 ),
ctlpt( E3, 1.0, 0.0, 1.0 ),
ctlpt( E3, 1.0, 2.0, 1.0 ) ),
list( KV_OPEN ) );
c3 = cbspline( 3,
list( ctlpt( E3, 0.0, 0.0, 1.5 ),
ctlpt( E3, 2.0, 0.0, 1.5 ),
ctlpt( E3, 1.0, 0.5, 1.5 ),
ctlpt( E3, 1.0, 1.0, 1.5 ) ),
list( KV_OPEN ) );
c4 = cbspline( 3,
list( ctlpt( E3, 0.0, 0.0, 2.5 ),
ctlpt( E3, 1.0, 0.0, 2.5 ),
ctlpt( E3, 1.0, 1.0, 2.5 ) ),
list( KV_OPEN ) );

s = sfromcrvs( list( c1, c2, c3, c4 ) );
color( s, green );
interact( list( s, c1, c2, c3, c4 ), 0 );
free( c1 ); free( c2 ); free( c3 ); free( c4 );

display = off;

resolution = save_res;
drawctlpt = 0;



  3 Responses to “Category : OS/2 Files
Archive   : IRIT-OS2.ZIP
Filename : FREEFORM.IRT

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/