36 #include <ringmesh/ringmesh_tests_config.h> 51 GeoModelBuilder3D builder( geomodel );
62 std::vector< index_t > triangles;
63 triangles.push_back( 0 );
64 triangles.push_back( 1 );
65 triangles.push_back( 2 );
66 triangles.push_back( 0 );
67 triangles.push_back( 2 );
68 triangles.push_back( 3 );
70 std::vector< index_t > surface_facet_ptr;
71 surface_facet_ptr.push_back( 0 );
72 surface_facet_ptr.push_back( 3 );
73 surface_facet_ptr.push_back( 6 );
75 std::vector< vec3 > vertices( 4 );
78 id = builder.topology.create_mesh_entity( Surface3D::type_name_static() );
83 builder.geometry.set_surface_geometry(
84 id.index(), vertices, triangles, surface_facet_ptr );
86 id = builder.topology.create_mesh_entity( Surface3D::type_name_static() );
91 builder.geometry.set_surface_geometry(
92 id.index(), vertices, triangles, surface_facet_ptr );
94 id = builder.topology.create_mesh_entity( Surface3D::type_name_static() );
99 builder.geometry.set_surface_geometry(
100 id.index(), vertices, triangles, surface_facet_ptr );
102 id = builder.topology.create_mesh_entity( Surface3D::type_name_static() );
107 builder.geometry.set_surface_geometry(
108 id.index(), vertices, triangles, surface_facet_ptr );
110 id = builder.topology.create_mesh_entity( Surface3D::type_name_static() );
115 builder.geometry.set_surface_geometry(
116 id.index(), vertices, triangles, surface_facet_ptr );
118 id = builder.topology.create_mesh_entity( Surface3D::type_name_static() );
123 builder.geometry.set_surface_geometry(
124 id.index(), vertices, triangles, surface_facet_ptr );
138 vec3 translation_vector( 1., 2.5, -3.5 );
139 translate( geomodel, translation_vector );
141 const GeoModelMeshVertices3D& vertices = geomodel.mesh.vertices;
155 vec3 origin( 1., 2.5, -3.5 );
156 vec3 axis( 0, 0, 1 );
157 rotate( geomodel, origin, axis, 90,
true );
159 const GeoModelMeshVertices3D& vertices = geomodel.mesh.vertices;
171 const GEO::Matrix< 4, double >& lhs,
const GEO::Matrix< 4, double >& rhs )
173 for( index_t mat_i :
range( 4 ) )
175 for( index_t mat_j :
range( 4 ) )
177 double diff = lhs( mat_i, mat_j ) - rhs( mat_i, mat_j );
178 if( std::fabs( diff ) > global_epsilon )
188 const vec3 origin( 0, 0, 0 );
189 const double pi = M_PI;
190 const double step = 0.1;
192 GEO::Matrix< 4, double > rot_mat_degree;
193 GEO::Matrix< 4, double > rot_mat_radian;
194 GEO::Matrix< 4, double > result;
204 vec3 axis( 1, 0, 0 );
205 for(
double angle = 0.; angle <= 360.; angle += step )
209 double angle_rad = angle * pi / 180.;
211 origin, axis, angle_rad,
false );
217 result( 1, 1 ) = std::cos( angle_rad );
218 result( 1, 2 ) = -std::sin( angle_rad );
221 result( 2, 1 ) = std::sin( angle_rad );
222 result( 2, 2 ) = std::cos( angle_rad );
229 axis =
vec3( 0, 1, 0 );
230 for(
double angle = 0.; angle <= 360.; angle += step )
234 double angle_rad = angle * pi / 180.;
236 origin, axis, angle_rad,
false );
237 result( 0, 0 ) = std::cos( angle_rad );
239 result( 0, 2 ) = std::sin( angle_rad );
245 result( 2, 0 ) = -std::sin( angle_rad );
247 result( 2, 2 ) = std::cos( angle_rad );
254 axis =
vec3( 0, 0, 1 );
255 for(
double angle = 0.; angle <= 360.; angle += step )
259 double angle_rad = angle * pi / 180.;
261 origin, axis, angle_rad,
false );
262 result( 0, 0 ) = std::cos( angle_rad );
263 result( 0, 1 ) = -std::sin( angle_rad );
266 result( 1, 0 ) = std::sin( angle_rad );
267 result( 1, 1 ) = std::cos( angle_rad );
298 catch(
const std::exception& e )
void build_geomodel(GeoModel3D &geomodel)
void RINGMESH_API rotate(GeoModel3D &geomodel, const vec3 &origin, const vec3 &axis, double angle, bool degrees=false)
Rotate the boundary geomodel.
void translate(GeoModel< DIMENSION > &geomodel, const vecn< DIMENSION > &translation_vector)
Translates the boundary geomodel by a vector.
void test_rotation(GeoModel3D &geomodel)
GEO::Matrix< 4, double > RINGMESH_API rotation_matrix_about_arbitrary_axis(const vec3 &origin, const vec3 &axis, double theta, bool degrees)
Builds a rotational matrix about an arbitrary axis.
static void err(const std::string &feature, const Args &... args)
void check_matrices(const GEO::Matrix< 4, double > &lhs, const GEO::Matrix< 4, double > &rhs)
static void out(const std::string &feature, const Args &... args)
void check_vertex(const vec3 &in, const vec3 &result)
void test_translate(GeoModel3D &geomodel)
const std::string & category() const
Classes to build GeoModel from various inputs.
This template is a specialization of a gme_id to the GeoModelMeshEntity.
void RINGMESH_API default_configure()
void test_rotation_matrix()