예제 #1
0
//********************************************
// Inner
//********************************************
void CVector3d::Inner(CVector3d& vector)
{
	double x = (double)m_y*(double)vector.z()-(double)m_z*(double)vector.y();
	double y = (double)m_z*(double)vector.x()-(double)m_x*(double)vector.z();
	double z = (double)m_x*(double)vector.y()-(double)m_y*(double)vector.x();
	Set((float)x,(float)y,(float)z);
}
예제 #2
0
//********************************************
// Operator -
//********************************************
CVector3d operator-(CVector3d& u,
                    CVector3d& v)
{
	CVector3d w;
	w.Set(u.x()-v.x(),u.y()-v.y(),u.z()-v.z());
	return w;
}
예제 #3
0
//********************************************
// Cross
//********************************************
CVector3d
CVector3d::Cross(const CVector3d& v) const
{
  return CVector3d(y() * v.z() - z() * v.y(),
		   z() * v.x() - x() * v.z(),
		   x() * v.y() - y() * v.x());
}
예제 #4
0
//********************************************
// Operator ^
//********************************************
CVector3d operator^(CVector3d& u,
                    CVector3d& v)
{
	// w = u ^ v
	CVector3d w;
	w.Set(u.y()*v.z()-u.z()*v.y(),
		    u.z()*v.x()-u.x()*v.z(),
		    u.x()*v.y()-u.y()*v.x());
	return w;
}
예제 #5
0
//********************************************
// Collinear
//********************************************
int CVector3d::Collinear(CVector3d &vector)
{
	float x = vector.x() / m_x;
	float y = vector.y() / m_y;
	float z = vector.z() / m_z;
	return ((x == y) && (y == z));
}
예제 #6
0
//********************************************
// IsCollinear
//********************************************
int
CVector3d::IsCollinear(CVector3d &vector) const
{
  double x = vector.x() / vec[0];
  double y = vector.y() / vec[1];
  double z = vector.z() / vec[2];
  return ((x == y) && (y == z));
}
예제 #7
0
//********************************************
// Rotate this vector around pAround by angle
// by Haeyoung Lee
//********************************************
CVector3d CVector3d::Rotate(double angle,
														CVector3d Around)
{
	double f1, f2, f3;
	CVector3d t1, t2;


	f1 = (double)cos((double)angle);
	f2 = (double)sin((double)angle);
	t1 = Projection(&Around);
	t2 = Around.Cross(this);
	f3 = Dot(Around);

	return CVector3d((double)(f1*t1.x()+f2*t2.x()+f3*Around.x()),
		(double)(f1*t1.y()+f2*t2.y()+f3*Around.y()),
		(double)(f1*t1.z()+f2*t2.z()+f3*Around.z()));

}
예제 #8
0
//********************************************
// Set
//********************************************
void CVector3d::Set(CVector3d &vector)
{
	Set(vector.x(),vector.y(),vector.z());
}