Example #1
0
// Returns the cross product of two vectors
vector4 vector4::Cross(const vector4 &v2) const
{
	vector4 r;
	r.x() = (y() * v2.z()) - (z() * v2.y());
	r.y() = (z() * v2.x()) - (x() * v2.z());
	r.z() = (x() * v2.y()) - (y() * v2.x());
	r.w() = w();	
	return r;
}
Example #2
0
vector4 vector4::Transform(const vector4& v, const matrix& m)
{
	vector4 result = vector4( 
						(v.x() * m(0,0)) + (v.y() * m(1,0)) + (v.z() * m(2,0)) + (v.w() * m(3,0)),
						(v.x() * m(0,1)) + (v.y() * m(1,1)) + (v.z() * m(2,1)) + (v.w() * m(3,1)),
						(v.x() * m(0,2)) + (v.y() * m(1,2)) + (v.z() * m(2,2)) + (v.w() * m(3,2)),
						(v.x() * m(0,3)) + (v.y() * m(1,3)) + (v.z() * m(2,3)) + (v.w() * m(3,3)) );
	return result;
	
}
Example #3
0
const vector4 vector4::operator / (const vector4 &v2) const
{
	vector4 r;
	r.x() = x() / v2.x();
	r.y() = y() / v2.y();
	r.z() = z() / v2.z();
	r.w() = w() / v2.w();
	return r;
}
Example #4
0
// Returns the dot product of two vectors
float vector4::Dot(const vector4 &v2) const
{
	return ((x() * v2.x()) + (y() * v2.y()) + (z() * v2.z()) + (w() * v2.w()));
}
Example #5
0
// Equality operations
bool vector4::operator == (const vector4 &v) const
{
	return ((x() == v.x()) && (y() == v.y()) && (z() == v.z()) && (w() == v.w()));
}