2 Copyright (c) 2012 Advanced Micro Devices, Inc.
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose,
7 including commercial applications, and to alter it and redistribute it freely,
8 subject to the following restrictions:
10 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
14 //Originally written by Takahiro Harada
17 #ifndef _ADL_TRANSFORM_H
18 #define _ADL_TRANSFORM_H
21 #include "AdlQuaternion.h"
22 #include "AdlMatrix3x3.h"
30 Transform trSetTransform(const float4& translation, const Quaternion& quat)
33 tr.m_translation = translation;
34 tr.m_rotation = qtGetRotationMatrix( quat );
38 Transform trInvert( const Transform& tr )
41 ans.m_rotation = mtTranspose( tr.m_rotation );
42 ans.m_translation = mtMul1( ans.m_rotation, -tr.m_translation );
46 Transform trMul(const Transform& trA, const Transform& trB)
49 ans.m_rotation = mtMul( trA.m_rotation, trB.m_rotation );
50 ans.m_translation = mtMul1( trA.m_rotation, trB.m_translation ) + trA.m_translation;
54 float4 trMul1(const Transform& tr, const float4& p)
56 return mtMul1( tr.m_rotation, p ) + tr.m_translation;
60 #endif //_ADL_TRANSFORM_H