📄 geometry3d.h
字号:
////////////////////////////////////////////////////////////////////////
//
// Geometry3D.h
//
// Copyright (c) 2003 Nokia Phones Ltd All rights reserved.
//
////////////////////////////////////////////////////////////////////////
#ifndef _GEOMETRY3D_H
#define _GEOMETRY3D_H
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
#include <e32math.h>
////////////////////////////////////////////////////////////////////////
class TScreenVertex;
class TCamera;
class TScanConverter;
class TMathLookup;
////////////////////////////////////////////////////////////////////////
class Geometry3D
{
public:
static TInt Reduce(TInt &aSubject, TInt aLimit);
public:
enum
{
leftBound = 0,
topBound ,
rightBound ,
bottomBound ,
numBounds ,
//
leftOutcode = ( 1 << leftBound ),
topOutcode = ( 1 << topBound ),
rightOutcode = ( 1 << rightBound ),
bottomOutcode = ( 1 << bottomBound ),
//
screenCoordUnityLog = 4,
screenCoordUnity = ( 1 << screenCoordUnityLog ),
screenCoordBias = ( 1 << ( screenCoordUnityLog - 1 ) ),
screenCoordFractionMask = ( screenCoordUnity - 1 ),
//
};
};
////////////////////////////////////////////////////////////////////////
class TVector3
{
public:
TVector3();
TVector3(TInt aX, TInt aY, TInt aZ);
void MakeSum(const TVector3 &aVectorA, const TVector3 &aVectorB);
void MakeDifference(const TVector3 &aVectorA, const TVector3 &aVectorB);
void MakeInverse(const TVector3 &aVector);
void MakeCrossProduct(const TVector3 &aVectorA, const TVector3 &aVectorB);
void ScaleFrom(const TVector3 &aVector, TInt aScale);
void ScaleFrom(const TVector3 &aVector, TInt aScale, TInt aDownshift);
// Warning - slow! Use only for initialisation!
void NormaliseFrom(const TVector3 &aVector, TInt aUnity);
// Like normalisation, but doesn't guarantee any particular magnitude
// for the result: instead it cuts large vectors down to a reasonable size
// (always less than or equal to aUnity) and discards trailing zeroes.
// Much faster than NormaliseFrom()!
void ReduceFrom(const TVector3 &aVector, TInt aUnity);
static TInt DotProduct(const TVector3 &aVectorA, const TVector3 &aVectorB);
public:
TInt iX;
TInt iY;
TInt iZ;
};
////////////////////////////////////////////////////////////////////////
class TPlane
{
public:
TPlane(){}
TPlane(const TVector3 &aVectorA, const TVector3 &aVectorB, const TVector3 &aVectorC);
TBool PointIsOutside(const TVector3 &aPoint);
void IntersectLineSegment
(
TVector3 &aStart,
TVector3 &aEnd,
TVector3 &aOutput,
TMathLookup &aMath
);
private:
enum
{
planeNormalUnity = ( 1 << 12 ),
//
maxExcessAltitude = 0x7fff,
maxExcessRatio = 0x7fff,
};
TVector3 iNormalVector;
TInt iAltitude;
};
////////////////////////////////////////////////////////////////////////
class TMatrix3x3
{
public:
TMatrix3x3();
void MakeIdentity();
void MakeRx(TInt aAngle, TMathLookup &aMath);
void MakeRy(TInt aAngle, TMathLookup &aMath);
void MakeRz(TInt aAngle, TMathLookup &aMath);
void MakeCompound(const TMatrix3x3 &aMatrixA, const TMatrix3x3 &aMatrixB);
void MakeInverse(const TMatrix3x3 &aSourceMatrix);
void Transform(const TVector3 &aSourceVector, TVector3 &aDestVector) const;
void InverseTransform(const TVector3 &aSourceVector, TVector3 &aDestVector) const;
private:
enum
{
matrixUnityLog = 12,
matrixUnity = ( 1 << matrixUnityLog ),
};
TInt iElement[ 3 ][ 3 ];
};
////////////////////////////////////////////////////////////////////////
class TAffineTransform
{
public:
TAffineTransform(){}
TAffineTransform(const TVector3 &aVector);
TAffineTransform(const TMatrix3x3 &aMatrix);
void SetVector(const TVector3 &aVector);
void SetMatrix(const TMatrix3x3 &aMatrix);
void MakeCompound(const TAffineTransform &aAffineA, const TAffineTransform &aAffineB);
void Transform(const TVector3 &aSourceVector, TVector3 &aDestVector) const;
void GetInverseVector(TVector3 &aDestVector) const;
protected:
TMatrix3x3 iMatrix;
TVector3 iVector;
};
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
#endif
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -