// We hard-code many of the parameters. static std::tuple<EllipseGeometry, Eigen::MatrixX2f> generate_problem(size_t n, float sigma) { using Eigen::Vector2f; auto g = get_ellipse_generator(Vector2f(MAX_SIZE/4, MAX_SIZE-MAX_SIZE/4), Vector2f(50, MAX_RADIUS), 0.1, 2*M_PI/32, sigma); Eigen::MatrixX2f ret(n, 2); for (size_t i = 0; i < n; ++i) ret.row(i) = g(); return std::make_tuple(g.geometry(), ret); }
static std::tuple<EllipseGeometry, Eigen::MatrixX2f> generate_cv_fail() { using Eigen::Vector2f; EllipseGeometry geom{Vector2f(1094.5, 1225.16), Vector2f(567.041, 365.318), 0.245385}; Eigen::MatrixX2f data(10, 2); data << 924.784, 764.160, 928.388, 615.903, 847.4 , 888.014, 929.406, 741.675, 904.564, 825.605, 926.742, 760.746, 863.479, 873.406, 910.987, 808.863, 929.145, 744.976, 917.474, 791.823; return std::make_tuple(geom, data); }
void Camera::rotate2D(float x, float y) { Vector2f rot = Vector2f(x, y); AngleAxis<float> rotX(rot.x(), Vector3f::UnitY()); // look left right AngleAxis<float> rotY(rot.y(), Vector3f::UnitX()); // look up down rotation_future_ = (rotX * rotY) * rotation_current_; if(roll_correction_){ rotation_future_ = rollcorrect(rotation_future_); } emit modified(); }
/** * Load the vertex and normal information from a obj file * - Clears current information from model * - Currently only supports objs that have one mesh and ignore material of mesh (must be set up somewhere else * - Currently loads face based normals * @param filename (name of obj file) * @param Model (model to load information); * @return bool (if file exists) **/ bool init_model_from_obj(const wchar_t *filename, Model *model){ // Is the model init'd? if (model == NULL) return false; std::ifstream obj_file(filename); //Check if file exists if (!obj_file) { return false; } std::vector<Vector2f> vertex_texture; std::vector<Vector4f> vertex_normal; float x, y, z, w; int a, b, c, d, e, f, g, h, i; std::string line; while (getline(obj_file, line)){ // Found new vertex if (line[0] == 'v' && line[1] == ' '){ sscanf_s(&line[0], "v %f %f %f", &x, &y, &z); model->verts.push_back({ x, y, z * -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }); } // Found new texture mapping coord else if (line[0] == 'v' && line[1] == 't'){ sscanf_s(&line[0], "vt %f %f", &x, &y); vertex_texture.push_back(Vector2f( x, 1.0f - y )); } // Found new normal else if (line[0] == 'v' && line[1] == 'n'){ sscanf_s(&line[0], "vn %f %f %f %f", &x, &y, &z, &w); vertex_normal.push_back(Vector4f( x, y, z * -1.0f, w )); } // Found new face else if (line[0] == 'f'){ sscanf_s(&line[0], "f %d/%d/%d %d/%d/%d %d/%d/%d", &a, &d, &g, &b, &e, &h, &c, &f, &i); model->indices.push_back((a - 1)); model->verts[(a - 1)].tU = vertex_texture[(d - 1)](0); model->verts[(a - 1)].tV = vertex_texture[(d - 1)](1); model->verts[(a - 1)].nX = vertex_normal[(g - 1)](0); model->verts[(a - 1)].nY = vertex_normal[(g - 1)](1); model->verts[(a - 1)].nZ = vertex_normal[(g - 1)](2); model->verts[(a - 1)].nW = vertex_normal[(g - 1)](3); model->indices.push_back((c - 1)); model->verts[(c - 1)].tU = vertex_texture[(f - 1)](0); model->verts[(c - 1)].tV = vertex_texture[(f - 1)](1); model->verts[(c - 1)].nX = vertex_normal[(i - 1)](0); model->verts[(c - 1)].nY = vertex_normal[(i - 1)](1); model->verts[(c - 1)].nZ = vertex_normal[(i - 1)](2); model->verts[(c - 1)].nW = vertex_normal[(i - 1)](3); model->indices.push_back((b - 1)); model->verts[(b - 1)].tU = vertex_texture[(e - 1)](0); model->verts[(b - 1)].tV = vertex_texture[(e - 1)](1); model->verts[(b - 1)].nX = vertex_normal[(h - 1)](0); model->verts[(b - 1)].nY = vertex_normal[(h - 1)](1); model->verts[(b - 1)].nZ = vertex_normal[(h - 1)](2); model->verts[(b - 1)].nW = vertex_normal[(h - 1)](3); } } return true; }