Пример #1
0
//deltaX and deltaY are in degrees
static void turn(double *eyeVec, double *atVec, double *upVec, double deltaX, double deltaY) {
  //The idea is to have the camera swivel left when you move the mouse left, and swivel up and down when you move the mouse up and down, without gimbol locking.
  //We accomplish this by having at-eye and up be perpendicular to each other, and keep track of the up orientation outside of this function.
	double upDownRotate[16];
	double leftRightRotate[16];
	double toTransform[16];

	double sideAxis[4] = {0,0,0,0};

	//get sideAxis from up and at (all three should be perpendicular)
	mcross(
		upVec[0],upVec[1],upVec[2],
		atVec[0]-eyeVec[0],atVec[1]-eyeVec[1],atVec[2]-eyeVec[2],
		&sideAxis[0],&sideAxis[1],&sideAxis[2]);
  
	rotateAboutAxis(upDownRotate, deltaY, sideAxis);
    
	setMatTranslation(toTransform, eyeVec[0],eyeVec[1],eyeVec[2]);
	multMatMat(toTransform, upDownRotate, toTransform);
	addMatTranslation(toTransform, -eyeVec[0],-eyeVec[1],-eyeVec[2]);
	multMatVec3(toTransform, atVec, atVec, 1);

	multMatVec3(upDownRotate, upVec,upVec, 0);

	////printf("ud: (%.1lf,%.1lf,%.1lf), ca: (%.1lf,%.1lf,%.1lf) cu: (%.1lf,%.1lf,%.1lf)\n", globalUpDownAxis[0], globalUpDownAxis[1], globalUpDownAxis[2], gCameraAt[0], gCameraAt[1], gCameraAt[2], gCameraUp[0], gCameraUp[1], gCameraUp[2]);

	rotateAboutAxis(leftRightRotate, deltaX, upVec);

	setMatTranslation(toTransform, eyeVec[0],eyeVec[1],eyeVec[2]);
	multMatMat(toTransform, leftRightRotate, toTransform);
	addMatTranslation(toTransform, -eyeVec[0],-eyeVec[1],-eyeVec[2]);
	multMatVec3(toTransform, atVec, atVec, 1);
}
Пример #2
0
void randomCorrelation( double (&R)[NS][NS], uint32_t &seed )
{
  double T[NS][NS];
  for ( size_t i=0; i<NS; ++i )
  {
    for ( size_t j=0; j<NS; ++j )
    {
      T[i][j] = randomNormal( seed );
    }
  }

  for ( size_t j=0; j<NS; ++j )
  {
    double sqSum = 0.0;
    for ( size_t i=0; i<NS; ++i )
    {
      sqSum += T[i][j] * T[i][j];
    }
    double norm = sqrt( sqSum );
    for ( size_t i=0; i<NS; ++i )
      T[i][j] /= norm;
  }

  double TTrans[NS][NS];
  trans( T, TTrans );

  multMatMat( TTrans, T, R );
}
Пример #3
0
static double* addMatCameraAntiRotation(double *mat) {
	setMatCameraAntiRotation(tempMatAdd);
	return multMatMat(mat,tempMatAdd, mat);
}
Пример #4
0
static double* addMatAntiLook(double* mat, double x,double y,double z, double nx,double ny,double nz, double upx,double upy,double upz) {
	setMatAntiLook(tempMatAdd, x,y,z, nx,ny,nz, upx,upy,upz);
	return multMatMat(mat, tempMatAdd, mat);
}
Пример #5
0
static double* addMatPerspective(double *mat, double fov) {
	setMatPerspective(tempMatPersp, fov);
	return multMatMat(mat, tempMatPersp, mat);
}
Пример #6
0
static void compileMats(void) {
	setMatIdentity(completeMat);
	multMatMat(completeMat, projMat,		completeMat);
	multMatMat(completeMat, modelviewMat,	completeMat);
	multMatMat(completeMat, transMat,		completeMat);
}