Ejemplo n.º 1
0
/*
 * 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);
}
Ejemplo n.º 2
0
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(&LTM);
		matrix_scale(&LTM, scale, scale, scale);
		matrix_rotateX(&LTM, cos(thetax*M_PI/180), sin(thetax*M_PI/180));
		matrix_rotateY(&LTM, cos(thetay*M_PI/180), sin(thetay*M_PI/180));
		matrix_rotateZ(&LTM, cos(thetaz*M_PI/180), sin(thetaz*M_PI/180));
		matrix_translate(&LTM, 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(&LTM, poly_vrp);
	}
}