0
|
1 /*=====================================================================
|
|
2
|
|
3 Copyright © 2007 Nokia Corporation. All rights reserved.
|
|
4
|
|
5 ======================================================================*/
|
|
6
|
|
7 /*
|
|
8 ============================================================================
|
|
9 Name : DemoCube.cpp
|
|
10 Author : Nokia Computer Vision Team in NRC Palo Alto
|
|
11 Copyright : Your copyright notice
|
|
12 Description : Main application class
|
|
13 ============================================================================
|
|
14 */
|
|
15
|
|
16 // INCLUDE FILES
|
|
17 #include <eikstart.h>
|
|
18 #include <e32math.h>
|
|
19 #include "DemoCubeApplication.h"
|
|
20 #include "DemoCube.h"
|
|
21
|
|
22 LOCAL_C CApaApplication* NewApplication()
|
|
23 {
|
|
24 return new CDemoCubeApplication;
|
|
25 }
|
|
26
|
|
27 GLDEF_C TInt E32Main()
|
|
28 {
|
|
29 return EikStart::RunApplication( NewApplication );
|
|
30 }
|
|
31
|
|
32 CDemoCube* CDemoCube::NewL(const TRect& aRect)
|
|
33 {
|
|
34 CDemoCube* self = new(ELeave) CDemoCube(aRect);
|
|
35 CleanupStack::PushL(self);
|
|
36 self->ConstructL();
|
|
37 CleanupStack::Pop();
|
|
38 return self;
|
|
39 }
|
|
40
|
|
41 CDemoCube::CDemoCube(const TRect& aRect) :
|
|
42 iRect(aRect)
|
|
43 {
|
|
44 }
|
|
45
|
|
46 void CDemoCube::ConstructL()
|
|
47 {
|
|
48 }
|
|
49
|
|
50 CDemoCube::~CDemoCube()
|
|
51 {
|
|
52 }
|
|
53
|
|
54 void CDemoCube::Calculate(CArrayFixFlat<TPoint>& aPoints, const TInt aX, const TInt aY, const TInt aAngle, const TInt aCubeWidth) const
|
|
55 {
|
|
56 const TPoint pos(iRect.iTl.iX + iRect.Width() / 2 + aX, iRect.iTl.iY + iRect.Height() / 4 + aY);
|
|
57 aPoints.At(0).SetXY(pos.iX + aCubeWidth * CosL(45.0 + aAngle), pos.iY + aCubeWidth * SinL(45.0 + aAngle));
|
|
58 aPoints.At(1).SetXY(pos.iX + aCubeWidth * CosL(135.0 + aAngle), pos.iY + aCubeWidth * SinL(135.0 + aAngle));
|
|
59 aPoints.At(2).SetXY(pos.iX + aCubeWidth * CosL(225.0 + aAngle), pos.iY + aCubeWidth * SinL(225.0 + aAngle));
|
|
60 aPoints.At(3).SetXY(pos.iX + aCubeWidth * CosL(315.0 + aAngle), pos.iY + aCubeWidth * SinL(315.0 + aAngle));
|
|
61 aPoints.At(4) = aPoints.At(0);
|
|
62 }
|
|
63
|
|
64 inline TReal CDemoCube::SinL(const TInt aAngle) const
|
|
65 {
|
|
66 TReal sine;
|
|
67 TReal radian = static_cast<TReal>(aAngle % 360) / 180 * KPi;
|
|
68 User::LeaveIfError(Math::Sin(sine, radian));
|
|
69 return sine;
|
|
70 }
|
|
71
|
|
72 inline TReal CDemoCube::CosL(const TInt aAngle) const
|
|
73 {
|
|
74 TReal cosine;
|
|
75 TReal radian = static_cast<TReal>(aAngle % 360) / 180 * KPi;
|
|
76 User::LeaveIfError(Math::Cos(cosine, radian));
|
|
77 return cosine;
|
|
78 } |