/* The original version of this file came from OpenTissue * * Copyright (C) 2003 Department of Computer Science, University of Copenhagen * Modifications copyright 2004, 2005 Nicholas Bishop * * This file is part of SharpConstruct. * * SharpConstruct is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * SharpConstruct is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SharpConstruct; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef ARCBALL_H #define ARCBALL_H class ArcBall { public: typedef double Vector[ 3 ]; typedef double Transform[ 4 ][ 4 ]; ArcBall( const double radius ); ~ArcBall(); static void NormalizeCoordinates( double&, double&, int, int ); void Reset(); void BeginDrag( const double, const double ); void Drag( const double, const double ); const Transform& Transformation(); const Transform& SnapRotation( const Transform& t, float angle ); void BakeSnapRotation(); protected: double radius; Vector Panchor; Vector Pcurrent; double CurrentAngle; Vector CurrentAxis; Transform AnchorTransformation; Transform IncrementalTransformation; Transform CurrentTransformation; Transform SnapTransform; // Operations on type Transform void Identity( Transform& ) const; void Copy( const Transform&, Transform& ) const; void Multiply( const Transform&, const Transform&, Transform& ) const; // Operations on type Vector double Length( const Vector& ) const; void Copy( const Vector&, Vector& ) const; double Dot( const Vector&, const Vector& ) const; void Cross( const Vector&, const Vector&, Vector& ) const; private: void ProjectOntoSurface( Vector& ); void ComputeIncrementalTransformation( const Vector&, const Vector&, Transform& ); }; #endif // ARCBALL_H