#
# Test file for the macros defined in iritinit.irt
#

save_res = resolution;

min(1, -5);
min(5, min(10, 15));
min(1, sin(45 * Pi / 180));

max(1, -5);
max(5, max(10, 15));
max(1, sin(45 * Pi / 180));

sqr( sin(45 * Pi / 180));
sqr(-sin(45 * Pi / 180) / 2);

normalize( vector( 5, 2, 6 ) );
normalize( point( 1, -2, 5 ) );

midPoint( point( 0, 1, 15 ), point( 10, 2, -5 ) );
midPoint( normalize( vector( 0, 10, 15 ) ),
	  normalize( vector( 10, 2, -5 ) ) );

InterpPoint( point( 0, 1, 15 ), point( 10, 2, -5 ), 0.1 );
InterpPoint( vector( 0, 1, 15 ), vector( 10, 2, -5 ), 1.1 );

ed1 = edge2d(  0,  0,  1,  1 );
ed2 = edge2d( -1, -1, -1,  2 );
ed3 = edge3d(  0,  0,  0,  1,  1,  1 );
ed4 = edge3d( -1,  0,  1,  1,  2, -1 );
interact( list( axes, ed1, ed2, ed3, ed4 ) );
free( ed1 );
free( ed2 );
free( ed3 );
free( ed4 );

Trs = torusSrf( 1.0, 0.2 );
color( Trs, green );
interact( Trs );

resolution = 5;
PolyTrs = SetNormalsInPolyObj( gpolygon( Trs, false ), "1,0,0" );
color( PolyTrs, red );
interact( list( Trs, PolyTrs ) );
free( PolyTrs );

ScaleCrv = cbspline( 3,
		     list( ctlpt( E2, 0.05, 0.25 ),
			   ctlpt( E2, 0.1,  0.0 ),
			   ctlpt( E2, 0.2,  0.5 ),
			   ctlpt( E2, 0.3,  0.0 ),
			   ctlpt( E2, 0.4,  0.5 ),
			   ctlpt( E2, 0.5,  0.0 ),
			   ctlpt( E2, 0.6,  0.5 ),
			   ctlpt( E2, 0.7,  0.0 ),
			   ctlpt( E2, 0.8,  0.5 ),
			   ctlpt( E2, 0.85, 0.25 ) ),
		     list( KV_OPEN ) );
color( ScaleCrv, green );
SclTrs = SwpCircSrf( circle( vector( 0, 0, 0 ), 1 ), ScaleCrv, 2 );
interact( SclTrs );
free( SclTrs );

CtlPts = GetCtlPoints( ScaleCrv, off );
CtlVecs = GetCtlPoints( ScaleCrv, on );
CtlPoly = GetCtlPolygon( ScaleCrv );
interact( list( ScaleCrv, CtlPts, CtlPoly ) );
interact( list( ScaleCrv, CtlVecs, CtlPoly ) );
free( CtlPoly );

ScalePoly = CnvrtCrvToPolygon( ScaleCrv, 50, true );
color( ScalePoly, red );
interact( list( ScalePoly, ScaleCrv ) );
free( ScaleCrv );
free( ScalePoly );

CtlPts = GetCtlMeshPts( Trs, off );
CtlVecs = GetCtlMeshPts( Trs, on );
CtlMesh = GetCtlMesh( Trs );
interact( list( Trs, CtlPts, CtlMesh ) );
interact( list( Trs, CtlVecs, CtlMesh ) );
free( CtlPts );
free( CtlVecs );
free( CtlMesh );

Isos = GetIsoCurves( Trs, 5, 5 );
color( Isos, red );
interact( list( Isos, Trs ) );
Isos = GetIsoCurves( Trs, 11, 11 );
color( Isos, red );
interact( list( Isos, Trs ) );
free( Isos );
free( Trs );

Circ = circle( vector( 0, 0, 0 ), 1 );
Cyl = Extrude( Circ , vector( 0, 0, 1 ), 3 );
interact( list( Cyl, Circ ) );

CircPly = CnvrtCrvToPolygon( Circ, 25, false );
Cyl = Extrude( CircPly , vector( 0, 0, 1 ), 3 );
interact( list( Cyl, CircPly, Circ ) );
free( Circ );
free( CircPly );
free( Cyl );

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 );
CrossPly = CnvrtCrvToPolygon( Cross, 50, false );
Cyl = Extrude( CrossPly, vector( 0, 0, 1 ), 3 );
interact( list( Cyl, CrossPly, Cross ) );
free( CrossPly );
free( Cross );
free( Cyl );

s = planeSrf( -1, -1, 1, 1 );
interact( s );

s = sphereSrf( 0.4 );
interact( s );
s = sphereSrf( 0.7 );
interact( s );

s = torusSrf( 0.5, 0.4 );
interact( s );
s = torusSrf( 0.5, 0.05 );
interact( s );

s = cylinSrf( 0.5, 0.4 );
interact( s );
s = cylinSrf( 0.5, 0.05 );
interact( s );

s = coneSrf( 0.5, 0.4 );
interact( s );
s = coneSrf( 0.5, 0.05 );
interact( s );

s = cone2Srf( 0.5, 0.4, 0.2 );
interact( s );
s = cone2Srf( 0.5, 0.5, 0.05 );
interact( s );

s = boxSrf( 0.5, 0.4, 0.2 );
interact( s );
s = boxSrf( 0.8, 0.4, -0.3 );
interact( s );
free( s );

tx( 1 ) * ty( 1 ) * tz( 1 ) * sx( 2 ) * sy( 2 ) * sz( 3 ) * sc( 3 )
	* rx( 10 ) * ry( 20 ) * rz( -30 );
RotZ2Vec( vector( 1, 0, 0 ) );
RotZ2Vec( vector( 0, 1, 0 ) );
RotZ2Vec( vector( 0, 0, 1 ) );
v = vector( 1, 2, 3 );
RotVec2Z( v );
w = RotVec2Z( v ) * v;
w;
RotZ2Vec( v ) * w;
free( v );
free( w );

a1 = arrow3d( point( 0, 0, 0 ), vector( 1, 1, 1 ), 1.5, 0.05, 0.5, 0.1 );
a2 = arrow3d( point( 1, 0, 0 ), vector( -1.5, 0.5, 1 ), 1, 0.02, 0.2, 0.05 );
a3 = arrow3d( point( 0, 0.6, 0.8 ),
	      vector( 0.5, 0.7, 0.3 ), 0.5, 0.01, 0.2, 0.02 );
interact( list( axes, a1, a2, a3 ) );

#############################################################################

resolution = save_res;

free( a1 );
free( a2 );
free( a3 );
