/***********************************************************************
 * FXRuby -- the Ruby language bindings for the FOX GUI toolkit.
 * Copyright (c) 2001-2003 by J. Lyle Johnson. All Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * For further information please contact the author by e-mail
 * at "lyle@users.sourceforge.net".
 ***********************************************************************/


/// Quaternion (single-precision version)
class FXQuat : public FXHVec {
public:

  /// Constructors
  FXQuat();

  /// Construct from axis and angle
  FXQuat(const FXVec& axis,FXfloat phi=0.0);

  /// Construct from euler angles yaw (z), pitch (y), and roll (x)
  FXQuat(FXfloat roll,FXfloat pitch,FXfloat yaw);

  /// Construct from components
  FXQuat(FXfloat x,FXfloat y,FXfloat z,FXfloat w);

  /// Adjust quaternion length
  FXQuat& adjust();

  /// Set quaternion from yaw (z), pitch (y), and roll (x)
  void setRollPitchYaw(FXfloat roll,FXfloat pitch,FXfloat yaw);
  
  %extend {
#ifdef SWIGRUBY
    // Obtain yaw, pitch, and roll 
    VALUE getRollPitchYaw() {
      FXfloat roll,pitch,yaw;
      self->getRollPitchYaw(roll,pitch,yaw);
      VALUE result=rb_ary_new();
      rb_ary_push(result,rb_float_new(roll));
      rb_ary_push(result,rb_float_new(pitch));
      rb_ary_push(result,rb_float_new(yaw));
      return result;
      }
#endif

    // Exponentiate quaternion
    FXQuat exp() const {
      return exp(*self);
      }
  
    // Take logarithm of quaternion
    FXQuat log() const {
      return log(*self);
      }
  
    // Invert quaternion
    FXQuat invert() const {
      return invert(*self);
      }

    // Conjugate quaternion
    FXQuat conj() const {
      return conj(*self);
      }

    // Mutiply quaternions
    FXQuat __mul__(const FXQuat& other) const {
      return (*self)*other;
      }

    // Construct quaternion from arc a->b on unit sphere
    static FXQuat arc(const FXVec& a,const FXVec& b){
      return arc(a,b);
      }

    // Spherical lerp
    static FXQuat lerp(const FXQuat& u,const FXQuat& v,FXfloat f){
      return lerp(u,v,f);
      }
    }
  };

