コード例 #1
0
ファイル: Matrix.cpp プロジェクト: francoisludewig/MecaSolid
			Vector Matrix::operator*(const Vector &b)const{
				Vector a;
				a.ComponantX(element[0][0]*b.ComponantX() + element[0][1]*b.ComponantY() + element[0][2]*b.ComponantZ());
				a.ComponantY(element[1][0]*b.ComponantX() + element[1][1]*b.ComponantY() + element[1][2]*b.ComponantZ());
				a.ComponantZ(element[2][0]*b.ComponantX() + element[2][1]*b.ComponantY() + element[2][2]*b.ComponantZ());
				return a;
			}
コード例 #2
0
TEST(BasisChangerFromBasisToBasis,ChangeVector){
	Point o(1,-3,2);
	Quaternion q(Vector(M_PI/4,M_PI/4,M_PI/4));
	Basis from(o,q),to;
	BasisChangerFromBasisToBasis basisToBasis;
	basisToBasis.ToBasis(&to);
	basisToBasis.FromBasis(&from);

	Vector u(M_PI,M_PI/5,2*M_PI,from.ID());
	Vector v = u;

	basisToBasis.ChangeVector(u);

	double x = v.ComponantX()*from.AxisX().ComponantX()
			 + v.ComponantY()*from.AxisY().ComponantX()
			 + v.ComponantZ()*from.AxisZ().ComponantX();

	double y = v.ComponantX()*from.AxisX().ComponantY()
			 + v.ComponantY()*from.AxisY().ComponantY()
			 + v.ComponantZ()*from.AxisZ().ComponantY();

	double z = v.ComponantX()*from.AxisX().ComponantZ()
			+ v.ComponantY()*from.AxisY().ComponantZ()
			+ v.ComponantZ()*from.AxisZ().ComponantZ();

	ASSERT_TRUE(isEquals (x,u.ComponantX()));
	ASSERT_TRUE(isEquals (y,u.ComponantY()));
	ASSERT_TRUE(isEquals (z,u.ComponantZ()));
}
コード例 #3
0
TEST(Vector,DivEqual){
	Vector a(M_PI,2*M_PI,M_PI/2);
	double b = sqrt(2.);
	Vector c = a/b;
	a /=b;
	EXPECT_DOUBLE_EQ (a.ComponantX(),c.ComponantX());
	EXPECT_DOUBLE_EQ (a.ComponantY(),c.ComponantY());
	EXPECT_DOUBLE_EQ (a.ComponantZ(),c.ComponantZ());
}
コード例 #4
0
TEST(Vector,Diff){
	Vector a(M_PI,2*M_PI,M_PI/2);
	Vector b(7*M_PI,2*M_PI,-4*M_PI/2);
	Vector c = a-b;

	EXPECT_DOUBLE_EQ (a.ComponantX()-b.ComponantX(),c.ComponantX());
	EXPECT_DOUBLE_EQ (a.ComponantY()-b.ComponantY(),c.ComponantY());
	EXPECT_DOUBLE_EQ (a.ComponantZ()-b.ComponantZ(),c.ComponantZ());
}
コード例 #5
0
TEST(Vector,Sum){
	Vector a(M_PI,2*M_PI,M_PI/2);
	Vector b(7*M_PI,-2*M_PI,-4*M_PI/2);
	Vector c = a+b;

	EXPECT_DOUBLE_EQ (a.ComponantX()+b.ComponantX(),c.ComponantX());
	EXPECT_DOUBLE_EQ (a.ComponantY()+b.ComponantY(),c.ComponantY());
	EXPECT_DOUBLE_EQ (a.ComponantZ()+b.ComponantZ(),c.ComponantZ());
}
コード例 #6
0
TEST(Vector,VectorialRandom){
	Vector a(M_PI,2*M_PI,M_PI/2);
	Vector b(M_PI/6,M_PI/3,M_PI/4);

	Vector pvExpected = a^b;

	EXPECT_DOUBLE_EQ (a.ComponantY()*b.ComponantZ()-a.ComponantZ()*b.ComponantY(),pvExpected.ComponantX());
	EXPECT_DOUBLE_EQ (a.ComponantZ()*b.ComponantX()-a.ComponantX()*b.ComponantZ(),pvExpected.ComponantY());
	EXPECT_DOUBLE_EQ (a.ComponantX()*b.ComponantY()-a.ComponantY()*b.ComponantX(),pvExpected.ComponantZ());
}
コード例 #7
0
TEST(Vector,LinearCombination){
	Vector a(1,0,0);
	Vector b(0,1,0);
	Vector c(0,0,1);

	Vector d = sqrt(3)*a+sqrt(5)*b-sqrt(7)*c;
	EXPECT_DOUBLE_EQ (sqrt(3.0),d.ComponantX());
	EXPECT_DOUBLE_EQ (sqrt(5.0),d.ComponantY());
	EXPECT_DOUBLE_EQ (-sqrt(7.0),d.ComponantZ());
}
コード例 #8
0
TEST(Vector,MultiplicationEqual){
	Vector a(5,17,-57);
	double b = -13;
	Vector c = a*b;
	a *=b;

	ASSERT_TRUE(isEquals(a.ComponantX(),c.ComponantX()));
	ASSERT_TRUE(isEquals(a.ComponantY(),c.ComponantY()));
	ASSERT_TRUE(isEquals(a.ComponantZ(),c.ComponantZ()));
}
コード例 #9
0
TEST(Vector,IO_Operator){
	Vector a(M_PI,2*M_PI,M_PI/2);
	Vector b;

	ofstream fichierOut("testVector3D.txt", ios::out | ios::trunc);
	if(fichierOut){
		fichierOut << a;
		fichierOut.close();
	}

	ifstream fichierIn("testVector3D.txt", ios::in);
	if(fichierIn){
		fichierIn >> b;
		fichierIn.close();
	}


	EXPECT_DOUBLE_EQ (a.ComponantX(),b.ComponantX());
	EXPECT_DOUBLE_EQ (a.ComponantY(),b.ComponantY());
	EXPECT_DOUBLE_EQ (a.ComponantZ(),b.ComponantZ());

	remove("testVector3D.txt");
}
コード例 #10
0
ファイル: Vector.cpp プロジェクト: francoisludewig/MecaSolid
			double Vector::ScalarProduct(const Vector & b) const {
				if(this->Id() != b.Id())
					throw(Error(0,"Scalar product of vectors from different basis !",0));
				double ps = (this->componantX*b.ComponantX()+this->componantY*b.ComponantY()+this->componantZ*b.ComponantZ());
				return ps;
			}
コード例 #11
0
TEST(Vector,Constructor){
	Vector a;
	ASSERT_EQ (0,a.ComponantX());
	ASSERT_EQ (0,a.ComponantY());
	ASSERT_EQ (0,a.ComponantZ());
}