Example #1
0
 //! Implements <a href="http://qsar.sourceforge.net/dicts/blue-obelisk/index.xhtml#calculateOrthogonalisationMatrix">blue-obelisk:calculateOrthogonalisationMatrix</a>
 void OBUnitCell::SetData(const vector3 v1, const vector3 v2, const vector3 v3)
 {
   matrix3x3 m (v1, v2, v3);
   _mOrtho.FillOrth(vectorAngle(v2,v3), // alpha
                    vectorAngle(v1,v3), // beta
                    vectorAngle(v1,v2), // gamma
                    v1.length(),        // a
                    v2.length(),        // b
                    v3.length());       // c
   _mOrient = m.transpose() * _mOrtho.inverse();
   _spaceGroup = NULL;
   _spaceGroupName = "";
   _lattice = OBUnitCell::Undefined;
 }
	quaternion<Real> quaternion<Real>::buildRotation(const vector3<Real> &axis, Real angle)
	{
		HASSERT(isAbout(1, axis.length()));
		Real sina2 = (Real)sin(0.5 * angle);
		return quaternion<Real>((Real)cos(0.5 * angle), axis.x * sina2, axis.y * sina2, axis.z * sina2);
	}
Example #3
0
//                MathGP Library
//  Copyright (c) 2012-2016 Borislav Stanimirov
//   
//  See the LICENSE.txt file, included in this
//  distribution for details about the copyright
#include "mathgp_test.h"

using namespace mathgp;

TESTCASE("vector_geometry")
{
    vector3 a = vector3::coord(0, 1, 0);

    CHECK(close(a.length(), 1.f, mathgp::constants<float>::EPSILON()));
    CHECK(a.length_sq() == 1.f);
    CHECK(a.manhattan_length() == 1.f);

    vector3 b = vector3::coord(1, 2, 3);

    CHECK(close(b.length(), 3.741657387f, mathgp::constants<float>::EPSILON()));
    CHECK(b.length_sq() == 14.f);
    CHECK(b.manhattan_length() == 6.f);

    CHECK(close(distance(a, b), 3.31662479f, mathgp::constants<float>::EPSILON()));
    CHECK(distance_sq(a, b) == 11.f);
    CHECK(manhattan_distance(a, b) == 5.f);

	a = vector3::coord(0, 1, 0);
	b = vector3::coord(1, 0, 0);

	CHECK(orthogonal(a, b));