Beispiel #1
0
int main()
{
    double* m1,*m2;
    int m1rowCount=0,m1colCount=0,m2rowCount=0,m2colCount=0;
    m1=loadMatrix("m1.txt",&m1rowCount,&m1colCount);
    m2=loadMatrix("m2.txt",&m2rowCount,&m2colCount);
    printf("m1:\n");
    printMatrix(m1rowCount,m1colCount,m1);
    printf("\nm2:\n");
    printMatrix(m2rowCount,m2colCount,m2);
    printf("\n");
    if(m1colCount==m2rowCount)
    {
	double* m3 = product(m1rowCount,m1colCount,m2rowCount,m2colCount, m1,m2);
	printf("m1*m2:\n");
	printMatrix(m1rowCount,m2colCount,m3);
	saveMatrix("m3.txt",m1rowCount,m2colCount,m3);
	free(m3);
    }
    else
	printf("Nie mozna pomnozyc tych macierzy");
    free(m1);
    free(m2);
    return 0;
}
//----------------------------------------------------------
void ofGLRenderer::setupScreenPerspective(float width, float height, float fov, float nearDist, float farDist) {
	ofRectangle currentViewport = getCurrentViewport();

	float viewW = currentViewport.width;
	float viewH = currentViewport.height;

	float eyeX = viewW / 2;
	float eyeY = viewH / 2;
	float halfFov = PI * fov / 360;
	float theTan = tanf(halfFov);
	float dist = eyeY / theTan;
	float aspect = (float) viewW / viewH;

	if(nearDist == 0) nearDist = dist / 10.0f;
	if(farDist == 0) farDist = dist * 10.0f;


	matrixMode(OF_MATRIX_PROJECTION);
	ofMatrix4x4 persp;
	persp.makePerspectiveMatrix(fov, aspect, nearDist, farDist);
	loadMatrix( persp );

	matrixMode(OF_MATRIX_MODELVIEW);
	ofMatrix4x4 lookAt;
	lookAt.makeLookAtViewMatrix( ofVec3f(eyeX, eyeY, dist),  ofVec3f(eyeX, eyeY, 0),  ofVec3f(0, 1, 0) );
	loadMatrix(lookAt);
}
Beispiel #3
0
// This is called to set up the Camera-View
void Camera::look() {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    updateFrustum();
    loadMatrix(getFrustumMatrix());
    //getProjectionMatrix();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    updateVM();
    loadMatrix(viewMatrix_);
}
Beispiel #4
0
void initGame(int lv0, int sc0){
	gfield_init();
	gobstacle_init();
	gjump_initFlag();
	
	SCORE = sc0;
	LEVEL = lv0;
	
	PLAYER_JHEIGHT = 0;
	PLAYER_MATRIX = loadMatrix("player.mat");
	PLAYER_MATRIX_LOSE = loadMatrix("player_lose.mat");
	SCORE_HIGH = getHighScore();
	
}
Beispiel #5
0
void Scene::render(Renderer* renderer)
{
    auto director = Director::getInstance();
    Camera* defaultCamera = nullptr;
    const auto& transform = getNodeToParentTransform();

    for (const auto& camera : getCameras())
    {
        if (!camera->isVisible())
            continue;
        
        Camera::_visitingCamera = camera;
        if (Camera::_visitingCamera->getCameraFlag() == CameraFlag::DEFAULT)
        {
            defaultCamera = Camera::_visitingCamera;
        }
        
        director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
        director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, Camera::_visitingCamera->getViewProjectionMatrix());
        camera->apply();
        //clear background with max depth
        camera->clearBackground();
        //visit the scene
        visit(renderer, transform, 0);
#if CC_USE_NAVMESH
        if (_navMesh && _navMeshDebugCamera == camera)
        {
            _navMesh->debugDraw(renderer);
        }
#endif
        
        renderer->render();
        
        director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
    }
    
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
    if (_physics3DWorld && _physics3DWorld->isDebugDrawEnabled())
    {
        director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
        director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, _physics3dDebugCamera != nullptr ? _physics3dDebugCamera->getViewProjectionMatrix() : defaultCamera->getViewProjectionMatrix());
        _physics3DWorld->debugDraw(renderer);
        renderer->render();
        director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
    }
#endif

    Camera::_visitingCamera = nullptr;
    experimental::FrameBuffer::applyDefaultFBO();
}
void GLNode::onDraw(Mat4 &transform, uint32_t flags)
{
    JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();

    js_type_class_t *typeClass = js_get_type_from_native<cocos2d::GLNode>(this);
    JS::RootedObject jsObj(cx, jsb_ref_get_or_create_jsobject(cx, this, typeClass, "cocos2d::GLNode"));

    if (jsObj.get())
    {
         bool found = false;
         JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET

         JS_HasProperty(cx, jsObj, "draw", &found);
         if (found) {
             auto director = Director::getInstance();
             director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
             director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform);

             JS::RootedValue rval(cx);
             JS::RootedValue fval(cx);
             JS_GetProperty(cx, jsObj, "draw", &fval);

             JS_CallFunctionValue(cx, jsObj, fval, JS::HandleValueArray::empty(), &rval);

             director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
        }
    }
}
Beispiel #7
0
int main(int argc, char *argv[]) {
	int num;
	Matrix *m;
	for ( int i = 1; i < argc; i++ ) {
		num = findNumber( argv[i] );
		if ( num == -1 )
			FileNameError();

		jacobi( loadMatrix( argv[i] ), num );
		printf( " : finish!\n" );
	}

	if ( argc == 1 ) {
		printf(
			"コマンドライン引数で固有値を求めたい対称行列を入力してください.(複数可)\n"
			"入力:\n"
			"   ファイル名:sigmaxx.txt\n"
			"   中身:n*nの対称行列\n"
			"         x.x x.x x.x ... x.x\n"
			"          :               : \n"
			"         x.x x.x x.x ... x.x\n"
			"出力:\n"
			"   ファイル名:eigenxx.txt\n"
			"   中身:固有値とそれに対応する固有ベクトル(λk > λk+1)\n"
			"         λ1 v1-1 v1-2 ... v1-n\n"
			"         :                  : \n"
			"         λn vn-1 vn-2 ... vn-n\n"
		);
	}

	return 0;
}
void ofMatrixStack::loadViewMatrix(const glm::mat4 & matrix){
	auto lastMatrixMode = currentMatrixMode;
	currentMatrixMode = OF_MATRIX_MODELVIEW;
	viewMatrix = matrix;
	loadMatrix(matrix);
	currentMatrixMode = lastMatrixMode;
}
Beispiel #9
0
void testSaveMatrix(void) {
    FILE *matrixFile = fopen("test/matrix_to_save","wb");
    if(matrixFile == NULL) {
        return;
    } 
    
    size_t columns = 3;
    size_t rows = 3;
    floattype **matrix = AllocMatrix(rows, columns);
    floattype **expected = AllocMatrix(rows, columns);
    
    CU_ASSERT(CODE_OK == saveMatrix(matrix, matrixFile, rows, columns));
    FreeMatrix(matrix, rows);
    fclose(matrixFile);
    
    Matrix *matrixLoaded;
    FILE *loadFile = fopen("test/matrix_to_save","rb");
    matrixLoaded = loadMatrix(loadFile);
    fclose(loadFile);
    
    CU_ASSERT(NULL != matrixLoaded);
    if(NULL == matrixLoaded) {
        FreeMatrix(expected, rows);
        return;
    }
    
    CU_ASSERT(3 == matrixLoaded->header.colcount);
    CU_ASSERT(3 == matrixLoaded->header.rowcount);
    
    assertMatricesAreSame(expected, matrixLoaded->matrix, &(matrixLoaded->header));
    
    FreeMatrix(matrixLoaded->matrix, matrixLoaded->header.rowcount);
    free(matrixLoaded);
    FreeMatrix(expected, rows);
}
//----------------------------------------------------------
void ofGLRenderer::popView() {
	matrixStack.popView();

	ofMatrix4x4 m;
	ofMatrixMode currentMode = matrixStack.getCurrentMatrixMode();

	matrixMode(OF_MATRIX_PROJECTION);
	loadMatrix(matrixStack.getProjectionMatrix());

	matrixMode(OF_MATRIX_MODELVIEW);
	loadMatrix(matrixStack.getModelViewMatrix());

	matrixMode(currentMode);

	viewport(matrixStack.getCurrentViewport());
}
Beispiel #11
0
void myGlScalef(GLfloat x, GLfloat y, GLfloat z) {
	if (!callingMyGl) {
		glScalef(x, y, z);

	} else {
		GLfloat* scalingMatrix = new GLfloat[16];
		scalingMatrix[0] = x;
		scalingMatrix[1] = 0.0;
		scalingMatrix[2] = 0.0;
		scalingMatrix[3] = 0.0;

		scalingMatrix[4] = 0.0;
		scalingMatrix[5] = y;
		scalingMatrix[6] = 0.0;
		scalingMatrix[7] = 0.0;

		scalingMatrix[8] = 0.0;
		scalingMatrix[9] = 0.0;
		scalingMatrix[10] = z;
		scalingMatrix[11] = 0.0;

		scalingMatrix[12] = 0.0;
		scalingMatrix[13] = 0.0;
		scalingMatrix[14] = 0.0;
		scalingMatrix[15] = 1.0;

		loadMatrix(scalingMatrix);
	}
}
Beispiel #12
0
void Scene::render(Renderer* renderer)
{
    auto director = Director::getInstance();
    Camera* defaultCamera = nullptr;
    const auto& transform = getNodeToParentTransform();
    if (_cameraOrderDirty)
    {
        stable_sort(_cameras.begin(), _cameras.end(), camera_cmp);
        _cameraOrderDirty = false;
    }

    for (const auto& camera : _cameras)
    {
        if (!camera->isVisible())
            continue;

        Camera::_visitingCamera = camera;
        if (Camera::_visitingCamera->getCameraFlag() == CameraFlag::DEFAULT)
        {
            defaultCamera = Camera::_visitingCamera;
        }

        director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
        director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, Camera::_visitingCamera->getViewProjectionMatrix());

        //visit the scene
        visit(renderer, transform, 0);
        renderer->render();

        director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
    }

    Camera::_visitingCamera = nullptr;
}
Beispiel #13
0
void myGlTranslatef(GLfloat x, GLfloat y, GLfloat z) {
	if (!callingMyGl) {
		glTranslatef(x, y, z);

	} else {
		GLfloat* translationMatrix = new GLfloat[16];
		translationMatrix[0] = 1.0;
		translationMatrix[1] = 0.0;
		translationMatrix[2] = 0.0;
		translationMatrix[3] = 0.0;

		translationMatrix[4] = 0.0;
		translationMatrix[5] = 1.0;
		translationMatrix[6] = 0.0;
		translationMatrix[7] = 0.0;

		translationMatrix[8] = 0.0;
		translationMatrix[9] = 0.0;
		translationMatrix[10] = 1.0;
		translationMatrix[11] = 0.0;

		translationMatrix[12] = x;
		translationMatrix[13] = y;
		translationMatrix[14] = z;
		translationMatrix[15] = 1.0;

		loadMatrix(translationMatrix);
	}
}
Beispiel #14
0
int opencl_run_kernel(char* fileName) {
  size_t work_dim[2];
  char entrada[32];
  float *Matriz;
  int i, j, numberShift = 0;

  Matriz = loadMatrix(fileName);
  prepare_kernel();
  work_dim[0] = sizeR;
  work_dim[1] = sizeC;   
  
  while (1) {
    printf("Digite 0 para column-shift, 1 para row-shift ou q para sair:\n");
    gets(entrada);
    if (strcmp(entrada, "q") == 0 ) break;
    axis = atoi(entrada);
    printf("Digite o número de shifts:\n");
    gets(entrada);
    numberShift = atoi(entrada);
    clEnqueueWriteBuffer(queue, opclMatrizInicial, CL_TRUE, 0, sizeOfMatrix, Matriz, 0, NULL, &event);
    clEnqueueWriteBuffer(queue, shifts, CL_TRUE, 0, sizeof(int), &numberShift, 0, NULL, &event);
    clEnqueueWriteBuffer(queue, axisShift, CL_TRUE, 0, sizeof(int), &axis, 0, NULL, &event);
    clEnqueueNDRangeKernel(queue, kernel, 2, NULL, work_dim, NULL, 0, NULL, &event);
    clReleaseEvent(event);
    clFinish(queue);

    if( clEnqueueReadBuffer(queue, opclMatriz, CL_TRUE, 0, sizeOfMatrix, Matriz, 0, NULL, &event) 
        != CL_SUCCESS ) printf("ERRROROOO\n");
    clReleaseEvent(event);

    printMatrix(Matriz, "Matriz Shift-Row:");
  }
  free(Matriz);
  return 1;
}
Beispiel #15
0
int main() {
    struct Matrix key, hole;
    FILE* file = fopen("data", "r");
    hole = loadMatrix(file);
    key = loadMatrix(file);
    fclose(file);
    
    printf("Hole:\n");
    printMatrix(hole);
    printf("\nKey:\n");
    printMatrix(key);
    printf("\n");
    
    printf(matchMatrixRotated(&hole,&key) ? "Matches\n" : "Doesn't match\n");
    disposeMatrix(&hole);
    disposeMatrix(&key);
}
Beispiel #16
0
void GLContext::drawFrame(long long delta)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    loadMatrix();

    cube_->draw(shaderProgram_);
}
Beispiel #17
0
void SkyboxShader::loadViewMatrix(glm::mat4 matrix, float rotation) {
    matrix[3].x = 0;
    matrix[3].y = 0;
    matrix[3].z = 0;
    matrix = rotate(matrix, rotation);

    loadMatrix(this->viewMatrix, matrix);
}
Beispiel #18
0
void me_o(double *X, int *N, char **labels, char **treeStr, int *nni)
{
  double **D, **A;
  set *species, *slooper;
  node *addNode;
  tree *T;
  char *str;
  int n, nniCount;

  n = *N;
  T = NULL;
  nniCount = 0;
  species = (set *) malloc(sizeof(set));
  species->firstNode = NULL;
  species->secondNode = NULL;
  str = (char *)R_alloc(MAX_INPUT_SIZE, sizeof(char));
  /* added by EP */
  if (strlen(str))
    strncpy(str, "", strlen(str));
  /* end */

  D = loadMatrix (X, labels, n, species);
  A = initDoubleMatrix(2 * n - 2);

  for(slooper = species; NULL != slooper; slooper = slooper->secondNode)
  {
    addNode = copyNode(slooper->firstNode);
    T = GMEaddSpecies(T,addNode,D,A);
  }
  makeOLSAveragesTable(T,D,A);
  // Compute NNI
  if (*nni == 1)
    NNI(T,A,&nniCount,D,n);
  assignOLSWeights(T,A);

  NewickPrintTreeStr(T,str);

  if (strlen (str) < MAX_INPUT_SIZE -1)
    {
      *treeStr = (char *)R_alloc(MAX_INPUT_SIZE, sizeof(char));
      /* added by EP */
      if (strlen(*treeStr))
	strncpy(*treeStr, "", strlen(*treeStr));
      /* end */
      strncpy (*treeStr, str, strlen (str));
    }

 /*  free (str); */
  freeMatrix(D,n);
  freeMatrix(A,2*n - 2);
  freeSet(species);
  freeTree(T);
  T = NULL;

  return;
}
Beispiel #19
0
void GLRenderer::setCamera(const Matrix4x4 &proj, const Matrix4x4 &view) {
	glMatrixMode(GL_PROJECTION);
	loadMatrix(proj);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	/* Apply a rotation to account for the difference in camera
	   conventions. In OpenGL, forward is z=-1, in Mitsuba it is z=+1 */
	glScalef(-1.0f, 1.0f, -1.0f);
	multMatrix(view);
}
Beispiel #20
0
int main(int argc, char *argv[]){
	MATRIX *mat;
	
	if( argc < 2 ){
		mat = loadMatrix("test.mat");
	}else{
		mat = loadMatrix(argv[1]);
	}
	if( mat == NULL ){
		fprintf(stderr, "test_matrix: return NULL\n");
		return 1;
	}
	rs_initscr();
	drawMatrix(0, 0, mat);
	refresh();
	sleep(3);
	freeMatrix(mat);
	rs_endwin();
	return 0;
}
Beispiel #21
0
int main(int argc, char** argv)
{
    if(argc != 6) {
        printf("Usage: binary <size> <input1_file> <input2_file> <output_file> <coefficient>\n");
        return -1;
    }
    unsigned int size = atoi(argv[1]);
    float coef = atof(argv[5]);
    float* a = loadMatrix(argv[2], 1, size);
    float* b = loadMatrix(argv[3], 1, size);
    float* m = (float*) malloc (sizeof(float)*size);

    triad(m, a, b, coef, size);

    saveMatrix(argv[4], m, 1, size);
    free(a);
    free(b);
    free(m);
    systamp();
    return 0;
}
Beispiel #22
0
int main(int argc, char *argv[])
{
    time_t now  = time(0);
	
		printf("chisq p = 0.05 cutoff = %f",chidist(3.84, 1.0));
    printf("Start analysis at %s \n", ctime(&now));
	
	
	/*
	Matrix a(2,2);
	a[0][0] = 1.0;
	a[1][1] = 1.0;
	a[0][1] = a[1][0] = 0.5;
		
	SVD svd;
	svd.InvertInPlace(a);
	for (int i = 0; i < a.rows; i ++) {
		for (int j = 0; j < a.cols; j ++) {
			std::cout << "a[" << i << "]" << "[" << j << "]" << a[i][j] << "\t";
		}
		std::cout << "\n";
	}
	
	return 0;
	 */

    Matrix X;
    String Xinput = "ExampleX.test";
    Vector Y;
    String Yinput = "ExampleY.test";

    if (loadMatrix(X,Xinput) || loadVector(Y, Yinput)) {
        fprintf(stderr, "Data loading problem!\n");
        exit(1);
    }

    LogisticRegression lr;
    if (lr.FitLogisticModel(X, Y, 30) ) {
        printf("fit all right!\n");
    } else {
        printf("fit failed\n");
    }
    now = time(0);
    printf("Finsihed analysis at %s \n", ctime(&now));

    LogisticRegressionScoreTest lrst;
    int Xcol = 1;
    lrst.FitLogisticModel(X,Y,Xcol,30);
    printf("score p-value is: %lf \n", lrst.getPvalue());
    Vector& pvalue = lr.GetAsyPvalue();
    printf("wald p-value is: %lf \n", pvalue[Xcol]);
    return 0;
}
Beispiel #23
0
int main(int argc, char *argv[]) {
	int num;
	Matrix *m;
	for ( int i = 1; i < argc; i++ ) {
		num = findNumber( argv[i] );
		if ( num == -1 )
			FileNameError();

		jacobi( loadMatrix( argv[i] ), num );
	}

	return 0;
}
void VirtualCamera::loadCameraMatrix(std::string path)
{
	cv::Mat camMatrix;
	loadMatrix(camMatrix,3,3,path);

	cc.x = Utilities::matGet2D(camMatrix,2,0);
	cc.y = Utilities::matGet2D(camMatrix,2,1);
	
	fc.x = Utilities::matGet2D(camMatrix,0,0);
	fc.y = Utilities::matGet2D(camMatrix,1,1);

	cameraMatrix = camMatrix;
}
Beispiel #25
0
vector< vector< double > > loadMatrix(string filename)
{
    assert(fileExists(filename));
    std::ifstream in(filename.c_str());
    if(!in.good())
    {
        printf("loadMatrix::The file %s can not be opened\n",filename.c_str());
        exit(0);
    }
    vector< vector< double > > toReturn = loadMatrix(in);
    in.close();
    return toReturn;
}
Beispiel #26
0
void Scene::render(Renderer* renderer)
{
    auto director = Director::getInstance();
    Camera* defaultCamera = nullptr;
    const auto& transform = getNodeToParentTransform();
    for (const auto& camera : _cameras)
    {
        Camera::_visitingCamera = camera;
        if (Camera::_visitingCamera->getCameraFlag() == CameraFlag::DEFAULT)
        {
            defaultCamera = Camera::_visitingCamera;
            continue;
        }
        
        director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
        director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, Camera::_visitingCamera->getViewProjectionMatrix());
        
        //visit the scene
        visit(renderer, transform, 0);
        renderer->render();
        
        director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
    }
    //draw with default camera
    if (defaultCamera)
    {
        Camera::_visitingCamera = defaultCamera;
        director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
        director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, Camera::_visitingCamera->getViewProjectionMatrix());
        
        //visit the scene
        visit(renderer, transform, 0);
        renderer->render();
        
        director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
    }
    Camera::_visitingCamera = nullptr;
}
Beispiel #27
0
void GLRenderer::setCamera(const ProjectiveCamera *camera,
		const Point2 &apertureSample, const Point2 &aaSample, Float timeSample) {
	Float time = camera->getShutterOpen() + camera->getShutterOpenTime() * timeSample;

	glMatrixMode(GL_PROJECTION);
	loadMatrix(camera->getProjectionTransform(
		apertureSample, aaSample).getMatrix());
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	/* Apply a rotation to account for the difference in camera
	   conventions. In OpenGL, forward is z=-1, in Mitsuba it is z=+1 */
	glScalef(-1.0f, 1.0f, -1.0f);
	multMatrix(camera->getViewTransform(time).getMatrix());
}
Beispiel #28
0
int main(int argc, char** argv)
{
    if(argc != 7){
        printf("Usage: matmul <heightA> <widthA> <widthB> <file_MA> <file_MB> <output_file>\n");
        return -1;
    }
    unsigned int HA, WA, WB;
    HA = atoi(argv[1]);
    WA = atoi(argv[2]);
    WB = atoi(argv[3]);
    float* h_A = loadMatrix(argv[4], HA, WA);
    float* h_B = loadMatrix(argv[5], WA, WB);
    float* h_C = (float*) malloc(sizeof(float)*HA*WB);
    
    computeGold(h_C, h_A, h_B, HA, WA, WB);

    saveMatrix(argv[6], h_C, HA, WB);

    free(h_A);
    free(h_B);
    free(h_C);
    systamp();
    return 0;
}
void SoftmaxLayer::runReverseImplementation(Bundle& bundle)
{
    auto& inputDeltasVector  = bundle[ "inputDeltas"].get<MatrixVector>();
    auto& outputDeltasVector = bundle["outputDeltas"].get<MatrixVector>();

    // Get the output activations
    auto outputActivations = loadMatrix("outputActivations");

    // Get the output deltas
    auto outputDeltas = foldTime(outputDeltasVector.front());

    auto inputDeltas = softmaxGradient(outputActivations, outputDeltas);

    inputDeltasVector.push_back(unfoldTime(inputDeltas, outputDeltasVector.front().size()));
}
Beispiel #30
0
void myGlRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
	if (!callingMyGl) {
		glRotatef(angle, x, y, z);

	} else {
		GLfloat norm = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));

		if (norm != 0) {
			GLfloat xx = x / norm;
			GLfloat yy = y / norm;
			GLfloat zz = z / norm;
			GLfloat mMatrix[] = {xx * xx, yy * xx, zz * xx, xx * yy, yy * yy, zz * yy, xx * zz, yy * zz, zz * zz};
			GLfloat iMatrix[] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
			GLfloat sMatrix[] = {0.0, zz, -yy, -zz, 0.0, xx, yy, -xx, 0.0};
			GLfloat angleInRadians = angle / 180 * M_PI;
			GLfloat cosA = cos(angleInRadians);
			GLfloat sinA = sin(angleInRadians);

			for (int i = 0; i < 9; i++) {
				mMatrix[i] += cosA * (iMatrix[i] - mMatrix[i]) + sinA * sMatrix[i];
			}

			GLfloat* rotationMatrix = new GLfloat[16];
			rotationMatrix[0] = mMatrix[0];
			rotationMatrix[1] = mMatrix[1];
			rotationMatrix[2] = mMatrix[2];
			rotationMatrix[3] = 0.0;

			rotationMatrix[4] = mMatrix[3];
			rotationMatrix[5] = mMatrix[4];
			rotationMatrix[6] = mMatrix[5];
			rotationMatrix[7] = 0.0;

			rotationMatrix[8] = mMatrix[6];
			rotationMatrix[9] = mMatrix[7];
			rotationMatrix[10] = mMatrix[8];
			rotationMatrix[11] = 0.0;

			rotationMatrix[12] = 0.0;
			rotationMatrix[13] = 0.0;
			rotationMatrix[14] = 0.0;
			rotationMatrix[15] = 1.0;

			loadMatrix(rotationMatrix);
		}
	}
}