/****************************************************************************** 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" namespace Libx42 { namespace Math { public value struct Affine : public IFormattable { float c00, c01, c02; float c10, c11, c12; float c20, c21, c22; float c30, c31, c32; [ComponentModel::EditorBrowsable( ComponentModel::EditorBrowsableState::Advanced )] Affine( const affine_t &a ); [ComponentModel::EditorBrowsable( ComponentModel::EditorBrowsableState::Advanced )] Affine( const ::x42::math::affine &a ); Affine( float c00, float c01, float c02, float c10, float c11, float c12, float c20, float c21, float c22, float c30, float c31, float c32 ); bool Equals( Affine a ) new; bool Equals( Affine a, float tolerance ) new; virtual bool Equals( Object ^obj ) override; static Affine operator * ( Affine a, Affine b ); static bool operator == ( Affine a, Affine b ) { return a.Equals( b ); } static bool operator != ( Affine a, Affine b ) { return !a.Equals( b ); } static bool Equals( Affine a, Affine b ) { return a.Equals( b ); } static bool Equals( Affine a, Affine b, float tolerance ); virtual String^ ToString( void ) override { return ToString( nullptr ); } virtual String^ ToString( IFormatProvider ^formatProvider ); Vector3 GetColumn( int index ) { if( index < 0 || index > 3 ) throw gcnew ::System::ArgumentOutOfRangeException( "index" ); interior_ptr< float > v = &c00; v += index * 3; return Vector3( v[0], v[1], v[2] ); } void SetColumn( int index, Vector3 value ) { if( index < 0 || index > 3 ) throw gcnew ::System::ArgumentOutOfRangeException( "index" ); interior_ptr< float > v = &c00; v += index * 3; v[0] = value.x; v[1] = value.y; v[2] = value.z; } property Vector3 Column[int] { Vector3 get( int index ) { return GetColumn( index ); } void set( int index, Vector3 value ) { SetColumn( index, value ); } } Vector3 TransformPoint( Vector3 p ); Vector3 TransformVector( Vector3 v ); Affine ComputeInverse( [::System::Runtime::InteropServices::Out] float %determinant ); Affine ComputeInverse( void ); float ComputeDeterminant( void ); static property Affine Identity { Affine get( void ); } private: virtual String^ ToString( String^ /* format */, IFormatProvider ^formatProvider ) sealed = IFormattable::ToString { return ToString( formatProvider ); } }; }; };