#pragma once
#include "Mdesk.h"
#include "McGeContext.h"

class McGeMatrix3d;
// -------------------------------------------------------------------------
// Summary:
// 		McGeScale3d 被称为"3D比例矢量"，此类用于表示3D空间中比例变换
// -------------------------------------------------------------------------
class MXGEDLL McGeScale3d
{
public:
	// -------------------------------------------------------------------------
	// Summary:
	// 		构造函数
	// -------------------------------------------------------------------------
	McGeScale3d();

	// -------------------------------------------------------------------------
	// Summary:
	// 		用比例系数factor建构一致的比例变换
	// Parameters:
	// 		factor	-	输入一致的比例系数
	// -------------------------------------------------------------------------
	McGeScale3d(mxreal factor);

	// -------------------------------------------------------------------------
	// Summary:
	// 		用比例系数xFact和yFact,zFact建构比例变换
	// Parameters:
	//		xFact	-	输入X方向的比例系数
	//		yFact	-	输入Y方向的比例系数
	//		zFact	-	输入Z方向的比例系数
	// -------------------------------------------------------------------------
	McGeScale3d(mxreal xFact, mxreal yFact, mxreal zFact);

	//:Ignore
	
	static const   McGeScale3d kIdentity;

	McGeScale3d    operator *  (const McGeScale3d& sclVec) const;
	McGeScale3d&   operator *= (const McGeScale3d& scl);
	McGeScale3d&   preMultBy   (const McGeScale3d& leftSide);
	McGeScale3d&   postMultBy  (const McGeScale3d& rightSide);
	McGeScale3d&   setToProduct(const McGeScale3d& sclVec1, const McGeScale3d& sclVec2);
	McGeScale3d    operator *  (mxreal s) const;
	McGeScale3d&   operator *= (mxreal s);
	McGeScale3d&   setToProduct(const McGeScale3d& sclVec, mxreal s);
	friend 
		MXGEDLL McGeScale3d    operator *  (mxreal, const McGeScale3d& scl);

	McGeScale3d    inverse        () const;
	McGeScale3d&   invert         ();

	Mdesk::Boolean isProportional(const McGeTol& tol = McGeContext::gTol) const;


	Mdesk::Boolean operator == (const McGeScale3d& sclVec) const;
	Mdesk::Boolean operator != (const McGeScale3d& sclVec) const;
	Mdesk::Boolean isEqualTo   (const McGeScale3d& scaleVec,
		const McGeTol& tol = McGeContext::gTol) const;

	mxreal         operator [] (unsigned int i) const;
	mxreal&        operator [] (unsigned int i);
	McGeScale3d&   set         (mxreal sc0, mxreal sc1, mxreal sc2);

	operator       McGeMatrix3d   () const;
	void getMatrix(McGeMatrix3d& mat) const;
	McGeScale3d&   extractScale   ( const McGeMatrix3d& mat );
	McGeScale3d&   removeScale    ( McGeMatrix3d& mat );

	mxreal         sx, sy, sz;
	//:End Ignore
};


MXGEDLL McGeScale3d   operator *  (mxreal s, const McGeScale3d& scl);

inline mxreal
McGeScale3d::operator [] (unsigned int i) const
{
	return *(&sx+i);
}

inline mxreal&
McGeScale3d::operator [] (unsigned int i)
{
	return *(&sx+i);
}
