Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "imesh_transform.h"
00008
00009
00010
00011 void imesh_transform_inplace(imesh_mesh& mesh,
00012 const vgl_vector_3d<double>& t)
00013 {
00014 imesh_vertex_array<3>& verts = mesh.vertices<3>();
00015 for(imesh_vertex_array<3>::iterator vi = verts.begin(); vi!= verts.end(); ++vi)
00016 {
00017 imesh_vertex<3>& v = *vi;
00018 v[0] += t.x();
00019 v[1] += t.y();
00020 v[2] += t.z();
00021 }
00022 }
00023
00024
00025
00026 void imesh_transform_inplace(imesh_mesh& mesh,
00027 const vgl_rotation_3d<double>& rotation)
00028 {
00029 imesh_vertex_array<3>& verts = mesh.vertices<3>();
00030 vnl_matrix_fixed<double,3,3> R = rotation.as_matrix();
00031 for(imesh_vertex_array<3>::iterator vi = verts.begin(); vi!= verts.end(); ++vi)
00032 {
00033 imesh_vertex<3>& v = *vi;
00034 v = imesh_vertex<3>(R[0][0]*v[0] + R[0][1]*v[1] + R[0][2]*v[2],
00035 R[1][0]*v[0] + R[1][1]*v[1] + R[1][2]*v[2],
00036 R[2][0]*v[0] + R[2][1]*v[1] + R[2][2]*v[2]);
00037 }
00038
00039 }
00040
00041
00042
00043 void imesh_transform_inplace(imesh_mesh& mesh,
00044 const vgl_rotation_3d<double>& rotation,
00045 const vgl_vector_3d<double>& t)
00046 {
00047 imesh_vertex_array<3>& verts = mesh.vertices<3>();
00048 vnl_matrix_fixed<double,3,3> R = rotation.as_matrix();
00049 for(imesh_vertex_array<3>::iterator vi = verts.begin(); vi!= verts.end(); ++vi)
00050 {
00051 imesh_vertex<3>& v = *vi;
00052 v = imesh_vertex<3>(R[0][0]*v[0] + R[0][1]*v[1] + R[0][2]*v[2] + t.x(),
00053 R[1][0]*v[0] + R[1][1]*v[1] + R[1][2]*v[2] + t.y(),
00054 R[2][0]*v[0] + R[2][1]*v[1] + R[2][2]*v[2] + t.z());
00055 }
00056
00057 }