📄 vector2.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 + -