コード例 #1
0
ファイル: glut.c プロジェクト: ifbe/tool
void fixmatrix()
{
	int x;
	GLfloat temp[4*4];

	fixmodel();
	fixview();
	fixprojection();

	for(x=0;x<16;x++)temp[x] = modelmatrix[x];
	matrixmultiply(temp, viewmatrix);
	matrixmultiply(temp, projmatrix);

	GLint pvmmatrix = glGetUniformLocation(programHandle, "modelviewproj");
	glUniformMatrix4fv(pvmmatrix, 1, GL_FALSE, temp);
}
コード例 #2
0
void main()
{
	int a;char str;
	printf("--------------WELCOME TO MATRIX CALCULATION--------------\n");
	printf("::::1.Calulate Addition or Subtraction of matrix::::::::\n");
	printf("::::2.Calculate Determinant of matrix::::\n");
	printf("::::3.Calculate Inverse of a matrix::::::\n");
	printf("::::4.Calculate Multiplication of matrix:\n");
	printf("::::5.Calculate Transpose of matrix::::::\n");
	printf("Enter any choices from 1 to 5::\t");
	scanf("%d",&a);
	switch (a)
	{
		case 1:
			matrixaddsub();
			break;
		case 2:
			 determinant_input();
			 break;
		case 3:
			inverse();
			break;
		case 4:
			matrixmultiply();
			break;
		case 5:
			transpose_input();
			break;
		default:
			printf("Invalid choice\n");
			printf("Do you want to Re-enter.\n");
			printf("Press Y to continue or Press N to exit.\t");
			scanf("%c",&str);
			if (str=='y'||str=='Y')
			{
				main();
			}
			break;

	}

}
コード例 #3
0
ファイル: test_invert.c プロジェクト: Bangybug/sphinxbase
int
main(int argc, char *argv[])
{
	float32 **a, **ainv, **ii;
	int i, j;

	a = (float32 **)ckd_calloc_2d(3, 3, sizeof(float32));
	ainv = (float32 **)ckd_calloc_2d(3, 3, sizeof(float32));
	ii = (float32 **)ckd_calloc_2d(3, 3, sizeof(float32));

	memcpy(a[0], foo, sizeof(float32) * 3 * 3);
	printf("%d\n", invert(ainv, a, 3));
	/* Should see:
	   0.75 -0.25 -0.25 
	   -0.25 0.75 -0.25 
	   -0.25 -0.25 0.75 
	*/
	for (i = 0; i < 3; ++i) {
		for (j = 0; j < 3; ++j) {
			printf("%.2f ", ainv[i][j]);
		}
		printf("\n");
	}
	/* Should see:
	   1.00 0.00 0.00
	   0.00 1.00 0.00
	   0.00 0.00 1.00
	*/
	matrixmultiply(ii, ainv, a, 3);
	for (i = 0; i < 3; ++i) {
		for (j = 0; j < 3; ++j) {
			printf("%.2f ", ii[i][j]);
		}
		printf("\n");
	}

	memcpy(a[0], bar, sizeof(float32) * 3 * 3);
	printf("%d\n", invert(ainv, a, 3));
	/* Should see:
	*/
	for (i = 0; i < 3; ++i) {
		for (j = 0; j < 3; ++j) {
			printf("%.2f ", ainv[i][j]);
		}
		printf("\n");
	}
	/* Should see:
	   1.00 0.00 0.00 
	   0.00 1.00 0.00 
	   0.00 0.00 1.00 
	*/
	memset(ii[0], 0, sizeof(float32) * 3 * 3);
	matrixmultiply(ii, ainv, a, 3);
	for (i = 0; i < 3; ++i) {
		for (j = 0; j < 3; ++j) {
			printf("%.2f ", ii[i][j]);
		}
		printf("\n");
	}

	/* Should see:
	   -1
	*/
	a[0][0] = 1.0;
	printf("%d\n", invert(ainv, a, 3));


	memcpy(a[0], foo, sizeof(float32) * 3 * 3);
	printf("%d\n", invert(a, a, 3));
	/* Should see:
	   0.75 -0.25 -0.25 
	   -0.25 0.75 -0.25 
	   -0.25 -0.25 0.75 
	*/
	for (i = 0; i < 3; ++i) {
		for (j = 0; j < 3; ++j) {
			printf("%.2f ", a[i][j]);
		}
		printf("\n");
	}

	ckd_free_2d((void **)a);
	ckd_free_2d((void **)ainv);
	ckd_free_2d((void **)ii);

	return 0;
}