GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_pullmanipulator.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  *****************************************************************************/
23 
24 #include "glc_pullmanipulator.h"
25 #include "../maths/glc_line3d.h"
26 #include "../maths/glc_geomtools.h"
27 #include "../viewport/glc_viewport.h"
28 
29 #include <QtGlobal>
30 
32 : GLC_AbstractManipulator(pViewport)
33 , m_PullDirection(pullDirection)
34 {
35 
36 }
37 
39 : GLC_AbstractManipulator(pullManipulator)
40 , m_PullDirection(pullManipulator.m_PullDirection)
41 {
42 
43 }
44 
46 {
47 
48 }
49 
51 {
52  return new GLC_PullManipulator(*this);
53 }
54 
56 {
59 }
60 
61 GLC_Matrix4x4 GLC_PullManipulator::doManipulate(const GLC_Point3d& newPoint, const GLC_Vector3d& projectionDirection)
62 {
63  // Project the given point on the sliding plane with the given direction
64  GLC_Point3d projectedPoint;
65  GLC_Line3d projectionLine(newPoint, projectionDirection);
66  glc::lineIntersectPlane(projectionLine, GLC_AbstractManipulator::m_SliddingPlane, &projectedPoint);
67 
68  // Project the point on the pulling direction
70 
71  // Compute the translation matrix
72  GLC_Matrix4x4 translationMatrix(projectedPoint - GLC_AbstractManipulator::m_PreviousPosition);
73 
74  // Update previous position to this position
76  return translationMatrix;
77 }

©2005-2013 Laurent Ribon