예제 #1
0
파일: mat33.cpp 프로젝트: patyork/project2
simphys::vec3 simphys::operator*( mat33& left, simphys::vec3& right)
{
    using namespace std;
    simphys::vec3 output;
    
    for( int i=0; i<3; i++ )
    {
        for( int j=0; j<3; j++ )
        {
            switch(i)
            {
                case 0:
                    output.setX( output.getX() + left(i,j)*right.getX() );
                    break;
                case 1:
                    output.setY( output.getY() + left(i,j)*right.getY() );
                    break;
                case 2:
                    output.setZ( output.getZ() + left(i,j)*right.getZ() );
                    break;
                default:
                    break;
            }
        }
    }
    
    return output;
}
예제 #2
0
simphys::vec3 simphys::operator+(const simphys::vec3& v1, const simphys::vec3& v2) {
  return vec3(v1.getX() + v2.getX(), 
	      v1.getY() + v2.getY(), 
	      v1.getZ() + v2.getZ());
}
예제 #3
0
simphys::vec3 simphys::vec3::crossProduct(const simphys::vec3& other) const {
  return vec3(y * other.getZ() - z * other.getY(), 
	      z * other.getX() - x * other.getZ(), 
	      x * other.getY() - y * other.getX());
}
예제 #4
0
simphys::vec3 simphys::operator*(const simphys::vec3& v1, float c) {
  return vec3(v1.getX() * c, 
	      v1.getY() * c, 
	      v1.getZ() * c);
}
예제 #5
0
simphys::vec3 simphys::operator*(float c, const simphys::vec3& v1) {
  return vec3(c * v1.getX(), 
	      c * v1.getY(), 
	      c * v1.getZ());
}
예제 #6
0
simphys::vec3 simphys::operator-(const simphys::vec3& v1, const simphys::vec3& v2) {
  // TODO - fill in implementation for quiz 1.
  return vec3(v1.getX()-v2.getX(), v1.getY()-v2.getY(), v1.getZ()-v2.getZ());
}
예제 #7
0
simphys::vec3 simphys::vec3::crossProduct(const simphys::vec3& other) const {
  // TODO - fill in implementation for quiz 1.
  return vec3(y*other.getZ()-z*other.getY(), z*other.getX() - x*other.getZ(), x*other.getY() - y * other.getX());
}
예제 #8
0
float simphys::vec3::dotProduct(const simphys::vec3& other) const {
  // TODO - fill in implementation for quiz 1.
  return x*other.getX() + y*other.getY() + z*other.getZ();
}
예제 #9
0
simphys::vec3 simphys::operator*(const simphys::vec3& v1, float c) {
  // TODO - fill in implementation for quiz 1.
  return vec3(v1.getX() * c, v1.getY() * c, v1.getZ() * c);
}