/** * @file XTPArcBall.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPARCBALL_H__) # define __XTPARCBALL_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * Implements natural object rotation computation using quaternions. * An object is assumed to have bounds, and rotation begin and end points, * for which a rotation quaternion can be computed and used for actual * rotation of the view matrix. * @see * CXTPMatrix */ class _XTP_EXT_CLASS CXTPArcBall { public: /** * @brief * Constructs an empy arc-ball object. */ CXTPArcBall(); /** * @brief * Sets object bounds. * @param dWidth The width of object bounds. * @param dHeight The height of object bounds. * @see * HasBounds */ void SetBounds(double dWidth, double dHeight); /** * @brief * Determines if object bounds have been set. * @return * TRUE is object bounds have been set. * @see * SetBounds */ BOOL HasBounds() const; /** * @brief * Sets initial rotation point that is mapped from 2D space onto * a 3D sphere determined by object bounds. * @param x X coordiante of the rotation starting point. * @param y Y coordiante of the rotation starting point. * @see * SetEnd, SetBounds */ void SetBegin(double x, double y); /** * @brief * Sets final rotation point that is mapped from 2D space onto * a 3D sphere determined by object bounds. * @param x X coordiante of the rotation final point. * @param y Y coordiante of the rotation final point. * @see * SetBegin, SetBounds */ void SetEnd(double x, double y); /** * @brief * Obtains rotation quaternion parameters based on the mapped * rotation starting and ending points. * @param xQuat X component of the rotation quaternion. * @param yQuat Y component of the rotation quaternion. * @param zQuat Z component of the rotation quaternion. * @param wQuat W component of the rotation quaternion. */ void GetRotationQuaternion(double& xQuat, double& yQuat, double& zQuat, double& wQuat); private: void MapToSphere(double x, double y, CXTPPoint3d& vSphere); private: CXTPPoint3d m_vBegin; CXTPPoint3d m_vEnd; double m_dWidthAdjustmentFactor; /**< Mouse bounds width */ double m_dHeightAdjustmentFactor; /**< Mouse bounds height */ }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif //#if !defined(__XTPARCBALL_H__) /** @endcond */