/****************************************************************************** libx42.net - skinned vertex animation library (.NET API) Copyright (C) 2007 HermitWorks Entertainment Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA. ******************************************************************************/ #pragma once #include "Vector.h" #include "Angle.h" #include "Affine.h" namespace Libx42 { namespace Math { public value struct Quaternion : IFormattable { float i, j, k, w; Quaternion( float i, float j, float k, float w ) : i( i ), j( j ), k( k ), w( w ) { } Quaternion( Vector3 ijk, float w ) : i( ijk.x ), j( ijk.y ), k( ijk.z ), w( w ) { } [ComponentModel::EditorBrowsable( ComponentModel::EditorBrowsableState::Advanced )] Quaternion( const ::x42::math::quat &q ) : i( q.i ), j( q.j ), k( q.k ), w( q.w ) { } static Quaternion Slerp( Quaternion a, Quaternion b, float t ); static Quaternion Conjugate( Quaternion q ); Quaternion Conjugate( void ) { return Conjugate( *this ); } static Quaternion operator * ( Quaternion a, Quaternion b ); void ToAxisAngle( [::System::Runtime::InteropServices::Out] Vector3 %axis, [::System::Runtime::InteropServices::Out] Angle %angle ); static Quaternion FromAxisAngle( Vector3 axis, Angle angle ); Affine ToAffine( void ); String^ ToString( IFormatProvider ^formatProvider ) { return String::Format( formatProvider, "<{0} {1} {2} {3}>", i, j, k, w ); } virtual String^ ToString( void ) override { return ToString( nullptr ); } bool Equals( Quaternion q ) new; virtual bool Equals( Object ^obj ) override; static bool operator == ( Quaternion a, Quaternion b ) { return a.Equals( b ); } static bool operator != ( Quaternion a, Quaternion b ) { return !a.Equals( b ); } static property Quaternion Identity { Quaternion get( void ) { return Quaternion( 0, 0, 0, 1 ); } } private: virtual String^ ToString( String^ /* format */, IFormatProvider ^formatProvider ) sealed = IFormattable::ToString { return ToString( formatProvider ); } }; }; };