From 4f00c4c74d213a37a4b1a3313e50ce2b4dd51271 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Mar 2013 21:48:15 +0100 Subject: finish rename --- facetracknoir/rotation.cpp | 48 ---------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 facetracknoir/rotation.cpp (limited to 'facetracknoir/rotation.cpp') diff --git a/facetracknoir/rotation.cpp b/facetracknoir/rotation.cpp deleted file mode 100644 index 1c89d775..00000000 --- a/facetracknoir/rotation.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "rotation.h" - -#include - -// ---------------------------------------------------------------------------- -Rotation Rotation::inv() -{ - return Rotation(a,-b,-c,-d); -} - -// conversions -// see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles -void Rotation::fromEuler(double yaw, double pitch, double roll) -{ - double sin_phi = sin(roll/2.0); - double cos_phi = cos(roll/2.0); - double sin_the = sin(pitch/2.0); - double cos_the = cos(pitch/2.0); - double sin_psi = sin(yaw/2.0); - double cos_psi = cos(yaw/2.0); - - a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; - b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; - c = cos_phi*sin_the*cos_psi + sin_phi*cos_the*sin_psi; - d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; -} - -void Rotation::toEuler(double& yaw, double& pitch, double& roll) -{ - roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); - pitch = asin(2.0*(a*c - b*d)); - yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); -} - -Rotation operator*(const Rotation& A, const Rotation& B) -{ - return Rotation(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication - A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, - A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, - A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); -} \ No newline at end of file -- cgit v1.2.3