void main(){
int dim1=3,dim2=3,dim3=3;
int a[dim1][dim2], b[dim2][dim3], c[dim1][dim3];
int i,j;


for(i=0;i<dim1;i++){
 for(j=0;j<dim2;j++){
  a[i][j]=2;
 }
}

for(i=0;i<dim2;i++){
 for(j=0;j<dim3;j++){
  b[i][j]=-5;
 }
}


impMat(dim1,dim2,a);

impMat(dim1,dim2,b);

multMat(dim1,dim2,dim3,a,b,c);

impMat(dim1,dim2,c);


}
示例#2
0
 void TransformTraverser::visit(Transformation *trans)
 {
     if (!foundRef) {
         multInvMat( trans->getInvMatrix() );
     }
     if (!foundObj) {
         multMat(trans->getMatrix());
     }
     traverseChildrenNodes(tmpNode);
     if(!foundRef) {
         multInvMat( trans->getMatrix() );	
     }
     if(!foundObj) {
         multMat(trans->getInvMatrix());
     }
 }
示例#3
0
void rotateTrackball(int dx, int dy, float rotation[4])
{
    float dist;
    float oldMat[9];
    float rotMat[9];
    float newRot[4];

    dist = (float)sqrt((double)(dx * dx + dy * dy));
    if(fabs(dist) < 0.99)
        return;

    newRot[0] = (float) dy / dist;
    newRot[1] = (float) dx / dist;
    newRot[2] = 0.0f;
    newRot[3] = (float)M_PI * dist / winWidth;

    axisamountToMat(rotation, oldMat);
    axisamountToMat(newRot, rotMat);
    multMat(oldMat, rotMat, oldMat);
    matToAxisamount(oldMat, rotation);

    dist = (float)sqrt(rotation[0] * rotation[0] + rotation[1] * rotation[1] +
        rotation[2] * rotation[2]);

    rotation[0] /= dist;
    rotation[1] /= dist;
    rotation[2] /= dist;
}
void main(){
int dim1=3,dim2=3,dim3=3;

double *a,*b,*c;

a=malloc(sizeof(double)*dim1*dim2);

b=malloc(sizeof(double)*dim2*dim3);

c=malloc(sizeof(double)*dim1*dim3);

matrizAleatoria(dim1,dim2,a);

impMat(dim1,dim2,a);


matrizAleatoria(dim2,dim3,b);

impMat(dim2,dim3,b);

multMat(dim1,dim2,dim3,a,b,c);


impMat(dim1,dim3,c);




}
示例#5
0
void Camera::setZRotation(const float angle)
{
	float sourceRot[16], rotZMat[16];
	memcpy_s(sourceRot,sizeof(float) * 16,m_rotMatrix,sizeof(float) * 16);
	rotZ( rad2deg(m_zMov),rotZMat);
	multMat(rotZMat, sourceRot, m_rotMatrix);
}
示例#6
0
/**
 * @brief Iterações do método de gradiente
 * @param *A Matriz.
 * @param *r Vetor de resíduos.
 * @param n Dimensão da matriz.
 */
double lambda(double *A, double *r, int n){
    double iaux, *aux = (double *)malloc(n*sizeof(double));
    multMat(A, r, aux, n);
    iaux = multVet(r, r, n)/multVet(r, aux, n);
    free(aux);
    return iaux;
}
示例#7
0
void Camera::computeGlobalTransformation( float x,float y,float z )
{
	float transMat4x4[16];
	float tempMat4x4[16];
	// Move to skeleton center of mass
	translate( x, y, z,transMat4x4 );

	// Apply viewing transformations
	multMat(transMat4x4,m_rotMatrix,tempMat4x4);

	// Move back to the original position
	translate( -x, -y, -z,transMat4x4 );
	multMat(tempMat4x4,transMat4x4,m_globalTransformation);

	// Apply zoom
	scale( m_zoomFactor, m_zoomFactor, m_zoomFactor, transMat4x4);
	multMat(tempMat4x4,transMat4x4,m_globalTransformation);
}
void main(){
int dim1=3,dim2=3,dim3=3;

double *a,*b,*c,*d;

char TRANSA, TRANSB;
int M, N, K;
double ALPHA, BETA;



a=malloc(sizeof(double)*dim1*dim2);

b=malloc(sizeof(double)*dim2*dim3);

c=malloc(sizeof(double)*dim1*dim3);

matrizAleatoria(dim1,dim2,a);

impMat(dim1,dim2,a);


matrizAleatoria(dim2,dim3,b);

impMat(dim2,dim3,b);

multMat(dim1,dim2,dim3,a,b,c);


impMat(dim1,dim3,c);



TRANSA = 'N';
TRANSB = 'N';
ALPHA = 1.0;
BETA = 0.0;

M=dim1;
K=dim2; 
N=dim3;

d = malloc(sizeof(double)*dim1*dim3);

dgemm_(&TRANSA, &TRANSB, &N, &M, &K, &ALPHA, b, &N, a, &K, &BETA, d, &N);




impMat(dim1,dim3,d);



}
示例#9
0
Point transformPoint(Matrix T, Point &p1)
{
	Point p;
	Matrix mp1;
	mp1.p[0][0] = p1.x;
	mp1.p[1][0] = p1.y;
	mp1.p[2][0] = p1.z;
	mp1.p[3][0] = 1.0;
	Matrix mp = multMat(T, mp1);
	p.x = mp.p[0][0];
	p.y = mp.p[1][0];
	p.z = mp.p[2][0];
	return p;
}
示例#10
0
//@param: OpenGL ModelView and Projection matrices, from glGetFloatv
void Frustum::update(float* model, float* project){
    //get product (m)
    float m[16];
    multMat(m, model, project);

    //left
    _planes[LEFT]= Vector4(
                m[3]-m[0],
                m[7]-m[4],
                m[11]-m[8],
                m[15]-m[12]);
    //bot
    _planes[BOT]= Vector4(
                m[3]-m[1],
                m[7]-m[5],
                m[11]-m[9],
                m[15]-m[13]);
    //far
    _planes[BACK]= Vector4(
                m[3]-m[2],
                m[7]-m[6],
                m[11]-m[10],
                m[15]-m[14]);
    //right
    _planes[RIGHT]= Vector4(
                m[3]+m[0],
                m[7]+m[4],
                m[11]+m[8],
                m[15]+m[12]);
    //top
    _planes[TOP]= Vector4(
                m[3]+m[1],
                m[7]+m[5],
                m[11]+m[9],
                m[15]+m[13]);
    //near
    _planes[FRONT]= Vector4(
                m[3]+m[2],
                m[7]+m[6],
                m[11]+m[10],
                m[15]+m[14]);
}
示例#11
0
 boost::shared_ptr<std::vector<ctype> > multMat (const std::vector<Math::DiagMatrix3<ctype> >& matrix, const std::vector<ctype>& vector) const {
     boost::shared_ptr<std::vector<ctype> > result = boost::make_shared<std::vector<ctype> > (vecSize ());
     multMat (matrix, vector, *result);
     return result;
 }