/***********************************************************************
 * 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".
 ***********************************************************************/


%rename("normalize!") FXVec::normalize_self();

class FXVec {
public:
  // Default constructor
  FXVec(FXfloat x=0.0f,FXfloat y=0.0f,FXfloat z=0.0f);

  // Other good stuff
  %extend {
    FXfloat __getitem__(FXint i) const {
      if(i<0||i>2) rb_raise(rb_eIndexError,"index %d out of range",i);
      return (*self)[i];
      }
    FXfloat __setitem__(FXint i,FXfloat f){
      if(i<0||i>2) rb_raise(rb_eIndexError,"index %d out of range",i);
      (*self)[i]=f;
      return f;
      }
    FXbool __eq__(const FXVec& other) const {
      return (*self == other);
      }
    FXVec __neg__() const {
      return -(*self);
      }
    FXVec __add__(const FXVec& other) const {
      return *self + other;
      }
    FXVec __sub__(const FXVec& other) const {
      return *self - other;
      }
    FXVec __mul__(FXfloat n) const {
      return (*self)*n;
      }
    FXVec __div__(FXfloat n) const {
      if(n==0.0f) rb_raise(rb_eZeroDivError,"divided by zero");
      return (*self)/n;
      }
    FXfloat dot(const FXVec& other) const {
      return (*self)*other;
      }
    FXVec cross(const FXVec& other) const {
      return (*self)^other;
      }
    FXfloat len() const {
      return len(*self);
      }
    FXVec normalize() const {
      return normalize(*self);
      }
    FXVec *normalize_self() {
      *self=normalize(*self);
      return self;
      }
    FXVec lo(const FXVec& other) const {
      return lo(*self,other);
      }
    FXVec hi(const FXVec& other) const {
      return hi(*self,other);
      }
    VALUE to_a() const {
      VALUE ary=rb_ary_new();
      rb_ary_push(ary,to_ruby((*self)[0]));
      rb_ary_push(ary,to_ruby((*self)[1]));
      rb_ary_push(ary,to_ruby((*self)[2]));
      return ary;
      }
    }
  };
