# # Silhouette test, Gershon Elber 2002 # save_res = resolution; ############################################################################# SphDirs = list( point( 0.190702792257, -0.981542113237, 0.014405687340 ), point( -0.262428475544, -0.649809330702, -0.713357643224 ), point( -0.757185248658, -0.608582364395, 0.237272003666 ), point( -0.426304692402, -0.610978642479, 0.667060271837 ), point( -0.189071986824, -0.218912631273, 0.957250772975 ), point( 0.182211644948, -0.480793872848, -0.857692349702 ), point( 0.634234739468, -0.476225292310, -0.609061378986 ), point( 0.138573494740, -0.549335450865, 0.824031520635 ), point( -0.850272424519, 0.111690244637, -0.514355996624 ), point( 0.936054584570, -0.269206611440, -0.226560398005 ), point( 0.492522636428, -0.774523432367, 0.396906669252 ), point( 0.788703111932, 0.550208870322, 0.274258271791 ), point( -0.664067581296, 0.737143325619, 0.125035848469 ), point( 0.908638719469, 0.328001374379, -0.258439110592 ), point( -0.006195661612, -0.877383494750, 0.479749742895 ), point( -0.819451977499, 0.333629559726, 0.466036234051 ), point( -0.696725696325, 0.591963326558, -0.405157651752 ), point( 0.414521381259, 0.854920409620, 0.311902415007 ), point( 0.384615663439, -0.031426819973, -0.922541676089 ), point( -0.937710540369, -0.274158137850, -0.213392259553 ), point( -0.430031680502, 0.658785398118, 0.617312361486 ), point( -0.706191943958, -0.216149516404, 0.674219788052 ), point( -0.677302779630, -0.673867987469, -0.295233598910 ), point( 0.664067581296, -0.737143325619, -0.125035848469 ), point( 0.780043087900, 0.018379859626, -0.625455801375 ), point( 0.785617635585, 0.069047058932, 0.614847487770 ), point( -0.385449560359, -0.908763646148, 0.159928955138 ), point( -0.195297921076, -0.124718904495, -0.972781535238 ), point( -0.173958390951, 0.950530200265, 0.257353481837 ), point( 0.865198533051, -0.418355681002, 0.276423626579 ), point( 0.537705024704, 0.487319524400, -0.688035599887 ), point( -0.495700722560, 0.200530692004, 0.845025581308 ), point( 0.185202008113, 0.976284513250, -0.112110496499 ), point( 0.183002784848, 0.796911788173, -0.575709632598 ), point( -0.959049434401, -0.117280879058, 0.257816554978 ), point( 0.512413094752, 0.451499290764, 0.730466431938 ), point( -0.210907729343, -0.928675550967, -0.305089577101 ), point( -0.952798985876, 0.300218523480, -0.045198772103 ), point( 0.261558843777, -0.832393043675, -0.488578336313 ), point( -0.493113175035, 0.232372513972, -0.838356969878 ), point( 0.984755155630, 0.069671915844, 0.159383517690 ), point( 0.645784916356, 0.732241481543, -0.216296676546 ), point( 0.077671655454, 0.342571749352, -0.936275444925 ), point( -0.623813427053, -0.327840173617, -0.709491104819 ), point( 0.306698252447, 0.001059786417, 0.951806208119 ), point( -0.307305398397, 0.917119164951, -0.253881523386 ), point( -0.278146702796, 0.658472941257, -0.699319522828 ), point( 0.076424998231, 0.747313388623, 0.660062055103 ), point( -0.030075983144, 0.348389756866, 0.936867125332 ), point( 0.591635780409, -0.378209760413, 0.711986291222 ) ); c = cbspline( 3, list( ctlpt( e2, 0.8, 1.0 ), ctlpt( e2, 1.0, 0.8 ), ctlpt( e2, 1.0, -0.8 ), ctlpt( e2, 0.8, -1.0 ), ctlpt( e2, -0.8, -1.0 ), ctlpt( e2, -1.0, -0.8 ), ctlpt( e2, -1.0, 0.8 ), ctlpt( e2, -0.8, 1.0 ) ), list( kv_periodic ) ); s = sFromCrvs( list( c, c * sc( 0.7 ) * tz( 0.65 ), c * sx( 0.65 ) * sy( 0.75 ) * tz( 0.7 ), c * sc( 1.7 ) * tz( 1.1 ), c * tz( 1.5 ) ), 3, kv_open ); color( s, yellow ); resolution = 70; Silhs = nil(); # Loop with step one for slower, more complete result. for ( i = 1, 2, sizeof( SphDirs ), # printf( "Processing vector %d\\n", list( i ) ): snoc( silhouette( s, coerce( nth( SphDirs, i ), vector_type ), true ), silhs ) ); interact( list( s, Silhs ) ); save( "silh1", list( s, Silhs ) ); free( i ); free( c ); free( s ); free( Silhs ); free( SphDirs ); ############################################################################# s = torusSrf( 1, 0.3 ); color( s, magenta ); ViewMatFromViewDir = function( V ): return = RotZ2V( V )^-1 * rz( 90 ) * sc( 0.7 ); SilAndSilInfl = function( S, V ): Sil: Pts: E3Pts: i: p: view_mat_sil: Sil = silhouette( S, V, true ): color( Sil, yellow ): Pts = SSilInfl( S, V, 0.5, -1e-6 ): E3Pts = nil(): for (i = 1, 1, sizeof( Pts ), p = nth( Pts, i ): snoc( coerce( seval( S, coord( p, 0 ), coord( p, 1 ) ), E3 ), E3Pts ) ): color( E3Pts, cyan ): printf( "Detected %d silhouette high order contact points.\\n", list( sizeof( E3Pts ) ) ): view_mat_sil = ViewMatFromViewDir( V ): return = list( E3Pts, Sil, view_mat_sil ); interact( All = list( axes, s, SilAndSilInfl( s, vector( 3, 1, 0.8 ) ) ) ); interact( All = list( axes, s, SilAndSilInfl( s, vector( 1, 1, 0.3 ) ) ) ); interact( All = list( axes, s, SilAndSilInfl( s, vector( 1, 2, 0.1 ) ) ) ); save( "silh2", All ); free( All ); free( s ); ############################################################################# resolution = save_res;