Untitled
unknown
plain_text
2 years ago
1.6 kB
6
Indexable
//add necessary changes to wrapper and so on so array of colors and granuarity can be passed from python //change struct Vertex { vec3f p;int tstart,tcount;SymetricMatrix q;int border; int color[3]; double granularity; }; //below double calculate_error(int id_v1, int id_v2, vec3f &p_result) { // compute interpolated vertex SymetricMatrix q = vertices[id_v1].q + vertices[id_v2].q; bool border = vertices[id_v1].border & vertices[id_v2].border; double error=0; double det = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7); if ( det != 0 && !border ) { // q_delta is invertible p_result.x = -1/det*(q.det(1, 2, 3, 4, 5, 6, 5, 7 , 8)); // vx = A41/det(q_delta) p_result.y = 1/det*(q.det(0, 2, 3, 1, 5, 6, 2, 7 , 8)); // vy = A42/det(q_delta) p_result.z = -1/det*(q.det(0, 1, 3, 1, 4, 6, 2, 5, 8)); // vz = A43/det(q_delta) error = vertex_error(q, p_result.x, p_result.y, p_result.z); } else { // det = 0 -> try to find best result vec3f p1=vertices[id_v1].p; vec3f p2=vertices[id_v2].p; float granFac = Granularity[id_v1] vec3f p3=(p1+p2)/2; double error1 = vertex_error(q, p1.x,p1.y,p1.z); double error2 = vertex_error(q, p2.x,p2.y,p2.z); double error3 = vertex_error(q, p3.x,p3.y,p3.z); error = min(error1, min(error2, error3)); if (error1 == error) p_result=p1; if (error2 == error) p_result=p2; if (error3 == error) p_result=p3; } //added if(vertices[id_v1].granularity>0) error /= vertices[id_v1].granularity if(vertices[id_v2].granularity>0) error /= vertices[id_v2].granularity return error; }
Editor is loading...