/* * Matrix operand to add a rotation about the X-axis to the Module. */ void module_rotateX(Module *md, double cth, double sth){ if(!md){ printf("Null md passed to module_rotateX\n"); return; } Element *e; Matrix m; matrix_identity(&m); matrix_rotateX(&m, cth, sth); e = element_init(ObjMatrix, &m); module_insert(md, e); }
void view_rotate_circle(Polygon* poly_vrp, Point* center, int sides, double scale, double thetax, double thetay, double thetaz){ if(NULL != poly_vrp){ //make a unit circle of "sides" number fo sides and store the points in the poly_vrp int i; double x, z; polygon_init(poly_vrp); Point p[sides]; Matrix LTM; matrix_identity(<M); matrix_scale(<M, scale, scale, scale); matrix_rotateX(<M, cos(thetax*M_PI/180), sin(thetax*M_PI/180)); matrix_rotateY(<M, cos(thetay*M_PI/180), sin(thetay*M_PI/180)); matrix_rotateZ(<M, cos(thetaz*M_PI/180), sin(thetaz*M_PI/180)); matrix_translate(<M, center->val[0], center->val[1], center->val[2]); for(i=0; i<sides; i++){ x = cos( i * M_PI * 2.0 / sides ); z = sin( i * M_PI * 2.0 / sides ); point_set3D(&p[i], x, 0.1, z); } polygon_set(poly_vrp, sides, &p[0]); matrix_xformPolygon(<M, poly_vrp); } }