view DemoCube/src/DemoCube.cpp @ 5:f546bb5370c7 default tip

Added a readme and a TODO in the source code.
author Atul Varma <varmaa@toolness.com>
date Tue, 12 Feb 2008 19:09:21 -0600
parents 43361e733c66
children
line wrap: on
line source

/*=====================================================================

    Copyright © 2007 Nokia Corporation. All rights reserved.

======================================================================*/

/*
============================================================================
 Name        : DemoCube.cpp
 Author      : Nokia Computer Vision Team in NRC Palo Alto
 Copyright   : Your copyright notice
 Description : Main application class
============================================================================
*/

// INCLUDE FILES
#include <eikstart.h>
#include <e32math.h>
#include "DemoCubeApplication.h"
#include "DemoCube.h"

LOCAL_C CApaApplication* NewApplication()
	{
	return new CDemoCubeApplication;
	}

GLDEF_C TInt E32Main()
	{
	return EikStart::RunApplication( NewApplication );
	}

CDemoCube* CDemoCube::NewL(const TRect& aRect)
	{
	CDemoCube* self = new(ELeave) CDemoCube(aRect);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop();
	return self;
	}

CDemoCube::CDemoCube(const TRect& aRect) :
	iRect(aRect)
	{
	}

void CDemoCube::ConstructL()
	{
	}

CDemoCube::~CDemoCube()
	{
	}

void CDemoCube::Calculate(CArrayFixFlat<TPoint>& aPoints, const TInt aX, const TInt aY, const TInt aAngle, const TInt aCubeWidth) const
	{
	const TPoint pos(iRect.iTl.iX + iRect.Width() / 2 + aX, iRect.iTl.iY + iRect.Height() / 4 + aY);
	aPoints.At(0).SetXY(pos.iX + aCubeWidth * CosL(45.0 + aAngle), pos.iY + aCubeWidth * SinL(45.0 + aAngle));
	aPoints.At(1).SetXY(pos.iX + aCubeWidth * CosL(135.0 + aAngle), pos.iY + aCubeWidth * SinL(135.0 + aAngle));
	aPoints.At(2).SetXY(pos.iX + aCubeWidth * CosL(225.0 + aAngle), pos.iY + aCubeWidth * SinL(225.0 + aAngle));
	aPoints.At(3).SetXY(pos.iX + aCubeWidth * CosL(315.0 + aAngle), pos.iY + aCubeWidth * SinL(315.0 + aAngle));
	aPoints.At(4) = aPoints.At(0);
	}

inline TReal CDemoCube::SinL(const TInt aAngle) const
	{
	TReal sine;
	TReal radian = static_cast<TReal>(aAngle % 360) / 180 * KPi;
	User::LeaveIfError(Math::Sin(sine, radian));
	return sine;
	}

inline TReal CDemoCube::CosL(const TInt aAngle) const
	{
	TReal cosine;
	TReal radian = static_cast<TReal>(aAngle % 360) / 180 * KPi;
	User::LeaveIfError(Math::Cos(cosine, radian));
	return cosine;
	}