Exemplo n.º 1
0
void QRGivensRotations(double ***A, double ***Q, double ***R) {

	double **G;
	int i, j;
	double c, s;

	mallocMatrix(&G);

	copyArray(R, A);
	setEye(Q);


	// Algorytm qr Givens rotations
	for(j=0; j<SIZE; j++) //kolumny
		for(i=SIZE - 1; i > j; i--) { //wiersze

			// #mozna zrownoleglic dwie instrukcje
			setEye(&G);
			givensRotation((*R)[i-1][j], (*R)[i][j], &c, &s);

			setMatrixG(&G, i, j, c, s);

			// #mozna zrownoleglic dwie instrukcje ponizej
			multiplyMatrixToSecondWithTransposition(&G, R);
			multiplyMatrixToFirst(Q, &G);

		}

//	printMatrix(&Q," Q ROZWIAZANIE");
//	printMatrix(&R," R ROZWIAZANIE");

	freeMatrix(&G);

	return;
}
Exemplo n.º 2
0
void Z3DCamera::azimuth(float angle)
{
  glm::vec3 eye = m_eye - m_center;
  eye = glm::rotate(glm::angleAxis(angle, m_upVector), eye);
  eye += m_center;
  setEye(eye);
}
Exemplo n.º 3
0
void Camera::RenderLookAtToCubeMap(const vec3& eye, unsigned int nFace)
{
	assert(nFace < 6);

	// Tableau de vecteurs "Center" pour la caméra :
	vec3 TabCenter[6] = {	vec3(eye.x+1.0f,	eye.y,		eye.z),
							vec3(eye.x-1.0f,	eye.y,		eye.z),

							vec3(eye.x,			eye.y+1.0f,	eye.z),
							vec3(eye.x,			eye.y-1.0f,	eye.z),

							vec3(eye.x,			eye.y,		eye.z+1.0f),
							vec3(eye.x,			eye.y,		eye.z-1.0f) };


	// Tableau de vecteurs "Up" pour la caméra :
	static vec3 TabUp[6] = {	vec3(0.0f,	-1.0f,	0.0f),
								vec3(0.0f,	-1.0f,	0.0f),

								vec3(0.0f,	0.0f,	1.0f),
								vec3(0.0f,	0.0f,	-1.0f),

								vec3(0.0f,	-1.0f,	0.0f),
								vec3(0.0f,	-1.0f,	0.0f) };

	setEye( eye );

	glMatrixMode (GL_MODELVIEW);
	glLoadIdentity ();
	gluLookAt(	eye.x,						eye.y,						eye.z,
				TabCenter[nFace].x,	TabCenter[nFace].y,	TabCenter[nFace].z,
				TabUp[nFace].x,				TabUp[nFace].y,				TabUp[nFace].z		);

	Frustum::getInstance().Extract(eye);
}
Exemplo n.º 4
0
/// creates translation and rotation matrix according to euler angles and transition vector
void CMat44::createTRMatrix(float alpha, float beta, float gamma, float trans_x, float trans_y, float trans_z){
	setEye();

	CMat44 rotX,rotY,rotZ;

	rotX.setEye();
	rotY.setEye();
	rotZ.setEye();


	rotX.setElement(cos(alpha),2,2);
	rotX.setElement(-sin(alpha),2,3);
	rotX.setElement(sin(alpha),3,2);
	rotX.setElement(cos(alpha),3,3);

	rotY.setElement(cos(beta),1,1);
	rotY.setElement(sin(beta),1,3);
	rotY.setElement(-sin(beta),3,1);
	rotY.setElement(cos(beta),3,3);

	rotZ.setElement(cos(gamma),1,1);
	rotZ.setElement(-sin(gamma),1,2);
	rotZ.setElement(sin(gamma),2,1);
	rotZ.setElement(cos(gamma),2,2);

	*this=rotX*rotY*rotZ;
	setElement(trans_x,1,4);
	setElement(trans_y,2,4);
	setElement(trans_z,3,4);

	orientation[0]=alpha; orientation[1]=beta; orientation[2]=gamma;
}
Exemplo n.º 5
0
void display(void)
{
   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   setEye();
   glutSolidSphere (1.0, 20, 16);
   glFlush ();
}
Exemplo n.º 6
0
void Z3DCameraParameter::flipViewDirection()
{
  glm::vec3 referenceCenter = getCenter();
  glm::vec3 eyePosition = getEye();

  glm::vec3 viewVector = eyePosition - referenceCenter;
  setEye(referenceCenter - viewVector);
}
Exemplo n.º 7
0
void Z3DCamera::dolly(float value)
{
  if (value <= 0.f || (m_centerDist < 1.0f && value > 1.f))
    return;
  glm::vec3 pos = m_center - m_viewVector * (m_centerDist / value);
  float maxV = 1e15;
  if (std::abs(pos.x) < maxV && std::abs(pos.y) < maxV  && std::abs(pos.z) < maxV )
    setEye(pos);
}
Exemplo n.º 8
0
Arquivo: Camera.cpp Projeto: otita/cg
void Camera::lookAt(
    const double (&eye)[3],
    const double (&center)[3],
    const double (&up)[3]
    ) {
  setEye(eye);
  setCenter(center);
  setUp(up);
}
Exemplo n.º 9
0
void OrbitCamera::update(float dt)
{
    float r = (_radius + _deltaRadius * dt) * FLT_EPSILON;
    float za = _radZ + _radDeltaZ * dt;
    float xa = _radX + _radDeltaX * dt;

    float i = sinf(za) * cosf(xa) * r + _center.x;
    float j = sinf(za) * sinf(xa) * r + _center.y;
    float k = cosf(za) * r + _center.z;

    setEye(i,j,k);
}
Exemplo n.º 10
0
/*
 *  display()
 *  ------
 *  Display the scene
 */
void display()
{
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glEnable(GL_DEPTH_TEST);
  glLoadIdentity();

  /* setup functions */
  setEye();

  /* draw */
  drawAxes();
  drawValues();

  /* magic here */
  drawShape();

  glFlush();
  glutSwapBuffers();
}
Exemplo n.º 11
0
/*
 *  display()
 *  ------
 *  Display the scene
 */
void display()
{
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glEnable(GL_DEPTH_TEST);
  glLoadIdentity();

  /* setup functions */
  setEye();

  /* draw */
  drawAxes();
  drawValues();

  /* magic here */
  /*
  cube(1,0,1, 1,1,1, 0);
  cube(-1,0,1, 1,1,1, 0);
  cone(0,1,0, 1,1,DEF_D);
  cone(0,-1,0, 1,1,90);
  */

  /* a 'tower' */
  /*
  cube(0,1.5,0, 1,3,1, 0);
  cube(0,3.5,0, 2,1,2, 45);
  spike(0,1,-3.5, 0.5,1, 90, 90,0,0);
  spike(0,1,3.5, 0.5,1, 90, -90,0,0);
  spike(-3.5,1,0, 0.5,1, 90, 0,0,-90);
  spike(3.5,1,0, 0.5,1, 90, 0,0,90);
  */
  tower(0,0,0, 1,1,1, 0);
  tower(4,0,0, 1,1,1.5, 30);

  glFlush();
  glutSwapBuffers();
}
Exemplo n.º 12
0
void CameraForGL::setEye(vect3f v)
{
    setEye(v.x, v.y, v.z);
}
Exemplo n.º 13
0
CMat44::CMat44()
{
    memset(pos, 0, sizeof(pos));
    setEye();
}
Exemplo n.º 14
0
void sgct_core::Viewport::configure(tinyxml2::XMLElement * element)
{
	if (element->Attribute("user") != NULL)
		setUserName(element->Attribute("user"));

	if (element->Attribute("name") != NULL)
		setName(element->Attribute("name"));

	if (element->Attribute("overlay") != NULL)
		setOverlayTexture(element->Attribute("overlay"));

	//for backward compability
	if (element->Attribute("mask") != NULL)
		setBlendMaskTexture(element->Attribute("mask"));

	if (element->Attribute("BlendMask") != NULL)
		setBlendMaskTexture(element->Attribute("BlendMask"));

	if (element->Attribute("BlackLevelMask") != NULL)
		setBlackLevelMaskTexture(element->Attribute("BlackLevelMask"));

	if (element->Attribute("mesh") != NULL)
		setCorrectionMesh(element->Attribute("mesh"));

	if (element->Attribute("hint") != NULL)
		mMeshHint.assign(element->Attribute("hint"));

	if (element->Attribute("tracked") != NULL)
		setTracked(strcmp(element->Attribute("tracked"), "true") == 0 ? true : false);

	//get eye if set
	if (element->Attribute("eye") != NULL)
	{
		if (strcmp("center", element->Attribute("eye")) == 0)
		{
			setEye(Frustum::MonoEye);
		}
		else if (strcmp("left", element->Attribute("eye")) == 0)
		{
			setEye(Frustum::StereoLeftEye);
		}
		else if (strcmp("right", element->Attribute("eye")) == 0)
		{
			setEye(Frustum::StereoRightEye);
		}
	}

	const char * val;
	tinyxml2::XMLElement * subElement = element->FirstChildElement();
	while (subElement != NULL)
	{
		val = subElement->Value();
		float fTmp[2];
		fTmp[0] = 0.0f;
		fTmp[1] = 0.0f;

		if (strcmp("Pos", val) == 0)
		{
			if (subElement->QueryFloatAttribute("x", &fTmp[0]) == tinyxml2::XML_NO_ERROR &&
				subElement->QueryFloatAttribute("y", &fTmp[1]) == tinyxml2::XML_NO_ERROR)
				setPos(fTmp[0], fTmp[1]);
			else
				sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "Viewport: Failed to parse position from XML!\n");
		}
		else if (strcmp("Size", val) == 0)
		{
			if (subElement->QueryFloatAttribute("x", &fTmp[0]) == tinyxml2::XML_NO_ERROR &&
				subElement->QueryFloatAttribute("y", &fTmp[1]) == tinyxml2::XML_NO_ERROR)
				setSize(fTmp[0], fTmp[1]);
			else
				sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "Viewport: Failed to parse size from XML!\n");
		}
		else if (strcmp("PlanarProjection", val) == 0)
		{
			parsePlanarProjection(subElement);
		}//end if planar projection
		else if (strcmp("FisheyeProjection", val) == 0)
		{
			parseFisheyeProjection(subElement);
		}
		else if (strcmp("SphericalMirrorProjection", val) == 0)
		{
			parseSphericalMirrorProjection(subElement);
		}
		else if (strcmp("Viewplane", val) == 0 || strcmp("Projectionplane", val) == 0)
		{
			mProjectionPlane.configure(subElement);
		}

		//iterate
		subElement = subElement->NextSiblingElement();
	}
}
Exemplo n.º 15
0
void Camera::setView(const QVector3D &eye, const QVector3D &center, const QVector3D &up)
{
    setEye(eye);
    setCenter(center);
    setUp(up);
}
Exemplo n.º 16
0
Arquivo: Camera.cpp Projeto: otita/cg
GLCamera::GLCamera() {
  setEye({0., 0., 1.});
  setCenter({0., 0., 0.});
  setUp({0., 1., 0.});
}
Exemplo n.º 17
0
void RenderCamera::update(const GameCamera & camera)
{
    setEye(camera.eye());
    setCenter(camera.center());
    setUp(camera.up());
}