Skip to content
Snippets Groups Projects
Commit af74ab96 authored by Tobias Schmidt's avatar Tobias Schmidt
Browse files

fix for mol::Transform::SetMatrix

setting the matrix now updates rotation, translation and center
components and thus fixes the GetRot, GetTrans, GetCenter functions
parent eb124182
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,7 @@ void Transform::SetMatrix(const Mat4& m)
{
tm_=m;
ttm_ = Transpose(tm_);
update_components();
}
Mat4 Transform::GetTransposedMatrix() const
......@@ -196,6 +197,15 @@ void Transform::update_tm()
ttm_ = Transpose(tm_);
}
void Transform::update_components()
{
rot_ = tm_.ExtractRotation();
cen_ = tm_.ExtractTranslation();
trans_[0] = tm_(3,0);
trans_[1] = tm_(3,1);
trans_[2] = tm_(3,2);
}
#if(OST_INFO_ENABLED)
Transform TransformFromInfo(const info::InfoGroup& group)
{
......
......@@ -82,6 +82,7 @@ private:
geom::Mat4 ttm_;
void update_tm();
void update_components();
};
#if(OST_INFO_ENABLED)
......
......@@ -10,6 +10,7 @@ set(OST_MOL_BASE_UNIT_TESTS
test_query.cc
test_surface.cc
test_residue.cc
test_transform.cc
test_view.cc
test_view_op.cc
tests.cc
......
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2011 by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3.0 of the License, or (at your option)
// any later version.
// This library 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 Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
/*
Authors: Tobias Schmidt
*/
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include <boost/test/auto_unit_test.hpp>
#include <ost/mol/mol.hh>
#include <ost/mol/transform.hh>
#include <ost/geom/geom.hh>
using namespace ost;
using namespace ost::mol;
BOOST_AUTO_TEST_SUITE( mol_base );
BOOST_AUTO_TEST_CASE(test_transform)
{
Transform tf;
BOOST_CHECK_EQUAL(tf.GetMatrix(), geom::Mat4());
BOOST_CHECK_EQUAL(tf.GetRot(), geom::Mat3());
BOOST_CHECK_EQUAL(tf.GetTrans(), geom::Vec3());
BOOST_CHECK_EQUAL(tf.GetCenter(), geom::Vec3());
geom::Mat4 mat = geom::Mat4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
tf.SetMatrix(mat);
BOOST_CHECK_EQUAL(tf.GetMatrix(), mat);
BOOST_CHECK_EQUAL(tf.GetRot(), geom::Mat3(1,2,3,5,6,7,9,10,11));
BOOST_CHECK_EQUAL(tf.GetCenter(), geom::Vec3(4,8,12));
BOOST_CHECK_EQUAL(tf.GetTrans(), geom::Vec3(13,14,15));
}
BOOST_AUTO_TEST_SUITE_END();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment