13 double* newcoords =
new double[
dim]();
17 for(
int i = 0; i <
dim; ++i )
19 ans += ( newcoords[i] - oldcoords[i] ) * ( newcoords[i] - oldcoords[i] );
30 double& linferr )
const
32 l1err = l2err = linferr = 0;
34 for(
int i = 0; i < nverts; ++i )
39 linferr = std::max( linferr, err );
43 l2err = sqrt( l2err / nverts );
49 for(
int i = 0; i <
dim; ++i )
51 ans += vec[i] * vec[i];
61 sphere(
double x = 0,
double y = 0,
double z = 0,
double r = 1 )
69 if( oldcoords == NULL || newcoords == NULL )
71 throw std::invalid_argument(
"NULL pointer" );
74 std::vector< double > direction;
75 direction.push_back( oldcoords[0] -
centerx );
76 direction.push_back( oldcoords[1] -
centery );
80 direction.push_back( oldcoords[2] -
centerz );
86 for(
int i = 0; i <
dim; ++i )
98 derivs[0] = -direction[1];
99 derivs[1] = direction[0];
110 derivs[0] = direction[0];
111 derivs[1] = direction[1];
112 derivs[2] = direction[2];
117 throw std::invalid_argument(
"dim must be 2 or 3" );
128 torus(
double x = 0,
double y = 0,
double z = 0,
double aa = 0.3,
double cc = 1.0 )
131 assert( aa > 0 && cc > 0 );
136 assert(
dim == 3 && oldcoords && newcoords );
140 double direction[3] = { oldcoords[0] - tubecenter[0], oldcoords[1] - tubecenter[1],
141 oldcoords[2] - tubecenter[2] };
150 derivs[0] = direction[0];
151 derivs[1] = direction[1];
152 derivs[2] = direction[2];
155 newcoords[0] = tubecenter[0] +
a * direction[0];
156 newcoords[1] = tubecenter[1] +
a * direction[1];
157 newcoords[2] = tubecenter[2] +
a * direction[2];