www.pudn.com > opengl_pick_sample.rar > matrix3d.cpp


//	matrix3d.cpp 
// 
 
#include "stdafx.h" 
#include "matrix3d.h" 
 
Matrix3D::Matrix3D(void) 
{ 
	InitMatrix(); 
} 
 
Matrix3D::Matrix3D(const Matrix3D& m3d) 
{ 
	InitMatrix(); 
	Copy(m3d); 
} 
 
Matrix3D::~Matrix3D(void) 
{ 
} 
 
void Matrix3D::Copy(const Matrix3D& m3d) 
{ 
	m3d.GetScale(m_scale[0],m_scale[1],m_scale[2]); 
	m3d.GetRotation(m_rotation[0],m_rotation[1],m_rotation[2]); 
	m3d.GetPosition(m_position[0],m_position[1],m_position[2]); 
} 
 
Matrix3D& Matrix3D::operator = (const Matrix3D& m3d) 
{ 
	Copy(m3d); 
	return *this; 
} 
 
void Matrix3D::GetRotation(double& xrot, double& yrot, double& zrot)const 
{ 
	xrot = m_rotation[0]; 
	yrot = m_rotation[1]; 
	zrot = m_rotation[2]; 
} 
 
void Matrix3D::GetPosition(double& x, double& y, double& z)const 
{ 
	x = m_position[0]; 
	y = m_position[1]; 
	z = m_position[2]; 
} 
 
void Matrix3D::GetScale(double& xscale, double& yscale, double& zscale)const 
{ 
	xscale = m_scale[0]; 
	yscale = m_scale[1]; 
	zscale = m_scale[2]; 
} 
 
void Matrix3D::SetRotation(double xrot, double yrot, double zrot) 
{ 
	m_rotation[0] = xrot; 
	m_rotation[1] = yrot; 
	m_rotation[2] = zrot; 
} 
 
void Matrix3D::SetPosition(double x, double y, double z) 
{ 
	m_position[0] = x; 
	m_position[1] = y; 
	m_position[2] = z; 
} 
 
void Matrix3D::SetScale(double xscale, double yscale, double zscale) 
{ 
	m_scale[0] = xscale; 
	m_scale[1] = yscale; 
	m_scale[2] = zscale; 
} 
 
void Matrix3D::AddRotation(double xrot, double yrot, double zrot) 
{ 
	m_rotation[0] += xrot; 
	m_rotation[1] += yrot; 
	m_rotation[2] += zrot; 
}