glc_rotationmanipulator.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024 #include "glc_rotationmanipulator.h"
00025 #include "../maths/glc_geomtools.h"
00026
00027 GLC_RotationManipulator::GLC_RotationManipulator(GLC_Viewport* pViewport, const GLC_Line3d& rotationLine)
00028 : GLC_AbstractManipulator(pViewport)
00029 , m_RotationLine(rotationLine)
00030 {
00031
00032 }
00033
00034 GLC_RotationManipulator::GLC_RotationManipulator(const GLC_RotationManipulator& rotationmanipulator)
00035 : GLC_AbstractManipulator(rotationmanipulator)
00036 , m_RotationLine(rotationmanipulator.m_RotationLine)
00037 {
00038
00039 }
00040
00041 GLC_RotationManipulator::~GLC_RotationManipulator()
00042 {
00043
00044 }
00045
00046 GLC_AbstractManipulator* GLC_RotationManipulator::clone() const
00047 {
00048 return new GLC_RotationManipulator(*this);
00049 }
00050
00051 GLC_Matrix4x4 GLC_RotationManipulator::doManipulate(const GLC_Point3d& newPoint, const GLC_Vector3d& projectionDirection)
00052 {
00053
00054 GLC_Point3d projectedPoint;
00055 GLC_Line3d projectionLine1(GLC_AbstractManipulator::m_PreviousPosition, projectionDirection);
00056 GLC_Line3d projectionLine(newPoint, projectionDirection);
00057
00058
00059 const GLC_Point3d origine(m_RotationLine.startingPoint());
00060 GLC_Plane rotationPlane(m_RotationLine.direction(), origine);
00061
00062 glc::lineIntersectPlane(projectionLine1, rotationPlane, &(GLC_AbstractManipulator::m_PreviousPosition));
00063 glc::lineIntersectPlane(projectionLine, rotationPlane, &projectedPoint);
00064
00065
00066 GLC_Vector3d vector1((GLC_AbstractManipulator::m_PreviousPosition - origine).normalize());
00067 GLC_Vector3d vector2((projectedPoint - origine).normalize());
00068
00069
00070 GLC_AbstractManipulator::m_PreviousPosition= projectedPoint;
00071
00072
00073 const GLC_Matrix4x4 trans1(-origine);
00074 const GLC_Matrix4x4 trans2(origine);
00075 const GLC_Matrix4x4 rotation(vector1, vector2);
00076
00077 return (trans2 * rotation * trans1);
00078
00079 }