include/matrix.h
branchpyrit
changeset 91 9d66d323c354
parent 46 6493fb65f0b1
child 94 4c8abb8977dc
equal deleted inserted replaced
90:f6a72eb99631 91:9d66d323c354
     1 /*
     1 /*
     2  * matrix.h: Matrix class, currently not used
     2  * matrix.h: Matrix class, currently not used
     3  *
     3  *
     4  * This file is part of Pyrit Ray Tracer.
     4  * This file is part of Pyrit Ray Tracer.
     5  *
     5  *
     6  * Copyright 2006, 2007  Radek Brich
     6  * Copyright 2006, 2007, 2008  Radek Brich
     7  *
     7  *
     8  * Permission is hereby granted, free of charge, to any person obtaining a copy
     8  * Permission is hereby granted, free of charge, to any person obtaining a copy
     9  * of this software and associated documentation files (the "Software"), to deal
     9  * of this software and associated documentation files (the "Software"), to deal
    10  * in the Software without restriction, including without limitation the rights
    10  * in the Software without restriction, including without limitation the rights
    11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    96 	}
    96 	}
    97 
    97 
    98 	friend Matrix operator*(const Float &f, Matrix &m) { return m * f; };
    98 	friend Matrix operator*(const Float &f, Matrix &m) { return m * f; };
    99 
    99 
   100 	// product of matrix and vector
   100 	// product of matrix and vector
   101 	Vector3 operator*(const Vector3 &v)
   101 	Vector operator*(const Vector &v)
   102 	{
   102 	{
   103 		Vector3 u = Vector3();
   103 		Vector u = Vector();
   104 		u.x = data[0][0] * v.x + data[0][1] * v.y + data[0][2] * v.z + data[0][3] * v.w;
   104 		u.x = data[0][0] * v.x + data[0][1] * v.y + data[0][2] * v.z + data[0][3] * v.w;
   105 		u.y = data[1][0] * v.x + data[1][1] * v.y + data[1][2] * v.z + data[1][3] * v.w;
   105 		u.y = data[1][0] * v.x + data[1][1] * v.y + data[1][2] * v.z + data[1][3] * v.w;
   106 		u.z = data[2][0] * v.x + data[2][1] * v.y + data[2][2] * v.z + data[2][3] * v.w;
   106 		u.z = data[2][0] * v.x + data[2][1] * v.y + data[2][2] * v.z + data[2][3] * v.w;
   107 		u.w = data[3][0] * v.x + data[3][1] * v.y + data[3][2] * v.z + data[3][3] * v.w;
   107 		u.w = data[3][0] * v.x + data[3][1] * v.y + data[3][2] * v.z + data[3][3] * v.w;
   108 		return u;
   108 		return u;
   109 	}
   109 	}
   110 
   110 
   111 	friend Matrix operator*(const Vector3 &v, Matrix &m) { return m * v; };
   111 	friend Matrix operator*(const Vector &v, Matrix &m) { return m * v; };
   112 };
   112 };
   113 
   113 
   114 #endif
   114 #endif