# SbVec2f.h

    00001 #ifndef COIN_SBVEC2F_H
    00002 #define COIN_SBVEC2F_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <stdio.h>
    00028
    00029 #include <Inventor/SbBasic.h>
    00030
    00031 class COIN_DLL_API SbVec2f {
    00032 public:
    00033   SbVec2f(void);
    00034   SbVec2f(const float v[2]);
    00035   SbVec2f(const float x, const float y);
    00036   float dot(const SbVec2f & v) const;
    00037   SbBool equals(const SbVec2f & v, const float tolerance) const;
    00038   const float * getValue(void) const;
    00039   void getValue(float & x, float & y) const;
    00040   float length(void) const;
    00041   void negate(void);
    00042   float normalize(void);
    00043   SbVec2f & setValue(const float v[2]);
    00044   SbVec2f & setValue(const float x, const float y);
    00045   float & operator [] (const int i);
    00046   const float & operator [] (const int i) const;
    00047   SbVec2f & operator *= (const float d);
    00048   SbVec2f & operator /= (const float d);
    00049   SbVec2f & operator += (const SbVec2f & u);
    00050   SbVec2f & operator -= (const SbVec2f & u);
    00051   SbVec2f operator-(void) const;
    00052
    00053   friend COIN_DLL_API SbVec2f operator * (const SbVec2f & v, const float d);
    00054   friend COIN_DLL_API SbVec2f operator * (const float d, const SbVec2f & v);
    00055   friend COIN_DLL_API SbVec2f operator / (const SbVec2f & v, const float d);
    00056   friend COIN_DLL_API SbVec2f operator + (const SbVec2f & v1, const SbVec2f & v2);
    00057   friend COIN_DLL_API SbVec2f operator - (const SbVec2f & v1, const SbVec2f & v2);
    00058   friend COIN_DLL_API int operator == (const SbVec2f & v1, const SbVec2f & v2);
    00059   friend COIN_DLL_API int operator != (const SbVec2f & v1, const SbVec2f & v2);
    00060
    00061   void print(FILE * fp) const;
    00062
    00063 private:
    00064   float vec[2];
    00065 };
    00066
    00067 COIN_DLL_API SbVec2f operator * (const SbVec2f & v, const float d);
    00068 COIN_DLL_API SbVec2f operator * (const float d, const SbVec2f & v);
    00069 COIN_DLL_API SbVec2f operator / (const SbVec2f & v, const float d);
    00070 COIN_DLL_API SbVec2f operator + (const SbVec2f & v1, const SbVec2f & v2);
    00071 COIN_DLL_API SbVec2f operator - (const SbVec2f & v1, const SbVec2f & v2);
    00072 COIN_DLL_API int operator == (const SbVec2f & v1, const SbVec2f & v2);
    00073 COIN_DLL_API int operator != (const SbVec2f & v1, const SbVec2f & v2);
    00074
    00075 // *************************************************************************
    00076
    00077 #endif // !COIN_SBVEC2F_H