⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vector2.h

📁 RGA: Biowaste Game Example This C++ application demonstrates how to create a 2D mobile game for S60
💻 H
字号:
/*
* ==============================================================================
*  Name        : Vector2.h
*  Part of     : RGA Game Example
*  Interface   :
*  Description : A simple 2 dimensional vector
*  Version     : 1.0
*
*  Copyright (c) 2007-2008 Nokia Corporation.
*  This material, including documentation and any related
*  computer programs, is protected by copyright controlled by
*  Nokia Corporation.
* ==============================================================================
*/

#ifndef __VECTOR2_H__
#define __VECTOR2_H__

#include <e32cmn.h>

/*
 * TVector2
 * structure defines simple 2d vector
 * including some helper functions
 */
struct TVector2
	{
	TVector2() {}
	TVector2(TReal64 aX, TReal64 aY) { iX = aX; iY = aY; }
	TVector2(TInt aX, TInt aY) { iX = aX; iY = aY; }
	TVector2(const TPoint& aPoint) { iX = aPoint.iX; iY = aPoint.iY; }
	
	/**
	 * Length
	 * @return length of the vector
	 */
	TReal64 Length() const
		{
		TReal64 sqlen = iX * iX + iY * iY;
		TReal64 length = 0;
		Math::Sqrt(length, sqlen);
		return length;
		}
	
	/**
	 * LengthSq
	 * @return squared length of the vector
	 */
	TReal64 LengthSq() const
		{
		return (iX * iX + iY * iY);
		}
	

	/**
	 * SetLength
	 * @param new vector length
	 */
	void SetLength(const TReal64 aLength)
		{
		TReal64 tmp = aLength / Length();
		iX *= tmp;
		iY *= tmp;
		}
	
	TReal64			iX;
	TReal64			iY;
	};


#endif /* __VECTOR2_H__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -