- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

# FTPoint.h

Go to the documentation of this file.

    00001 /*
    00002  * FTGL - OpenGL font library
    00003  *
    00004  * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
    00005  * Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
    00006  * Copyright (c) 2008 Sean Morrison <learner@brlcad.org>
    00007  *
    00008  * Permission is hereby granted, free of charge, to any person obtaining
    00009  * a copy of this software and associated documentation files (the
    00010  * "Software"), to deal in the Software without restriction, including
    00011  * without limitation the rights to use, copy, modify, merge, publish,
    00012  * distribute, sublicense, and/or sell copies of the Software, and to
    00013  * permit persons to whom the Software is furnished to do so, subject to
    00014  * the following conditions:
    00015  *
    00016  * The above copyright notice and this permission notice shall be
    00017  * included in all copies or substantial portions of the Software.
    00018  *
    00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    00020  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    00021  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    00022  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    00023  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    00024  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    00025  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    00026  */
    00027
    00028 #ifndef __ftgl__
    00029 #   warning This header is deprecated. Please use <FTGL/ftgl.h> from now.
    00030 #   include <FTGL/ftgl.h>
    00031 #endif
    00032
    00033 #ifndef __FTPoint__
    00034 #define __FTPoint__
    00035
    00036 #ifdef __cplusplus
    00037
    00038
    00042 class FTGL_EXPORT FTPoint
    00043 {
    00044     public:
    00048         inline FTPoint()
    00049         {
    00050             values[0] = 0;
    00051             values[1] = 0;
    00052             values[2] = 0;
    00053         }
    00054
    00062         inline FTPoint(const FTGL_DOUBLE x, const FTGL_DOUBLE y,
    00063                        const FTGL_DOUBLE z = 0)
    00064         {
    00065             values[0] = x;
    00066             values[1] = y;
    00067             values[2] = z;
    00068         }
    00069
    00075         inline FTPoint(const FT_Vector& ft_vector)
    00076         {
    00077             values[0] = ft_vector.x;
    00078             values[1] = ft_vector.y;
    00079             values[2] = 0;
    00080         }
    00081
    00088         FTPoint Normalise();
    00089
    00090
    00097         inline FTPoint& operator += (const FTPoint& point)
    00098         {
    00099             values[0] += point.values[0];
    00100             values[1] += point.values[1];
    00101             values[2] += point.values[2];
    00102
    00103             return *this;
    00104         }
    00105
    00112         inline FTPoint operator + (const FTPoint& point) const
    00113         {
    00114             FTPoint temp;
    00115             temp.values[0] = values[0] + point.values[0];
    00116             temp.values[1] = values[1] + point.values[1];
    00117             temp.values[2] = values[2] + point.values[2];
    00118
    00119             return temp;
    00120         }
    00121
    00128         inline FTPoint& operator -= (const FTPoint& point)
    00129         {
    00130             values[0] -= point.values[0];
    00131             values[1] -= point.values[1];
    00132             values[2] -= point.values[2];
    00133
    00134             return *this;
    00135         }
    00136
    00143         inline FTPoint operator - (const FTPoint& point) const
    00144         {
    00145             FTPoint temp;
    00146             temp.values[0] = values[0] - point.values[0];
    00147             temp.values[1] = values[1] - point.values[1];
    00148             temp.values[2] = values[2] - point.values[2];
    00149
    00150             return temp;
    00151         }
    00152
    00159         inline FTPoint operator * (double multiplier) const
    00160         {
    00161             FTPoint temp;
    00162             temp.values[0] = values[0] * multiplier;
    00163             temp.values[1] = values[1] * multiplier;
    00164             temp.values[2] = values[2] * multiplier;
    00165
    00166             return temp;
    00167         }
    00168
    00169
    00177         inline friend FTPoint operator * (double multiplier, FTPoint& point)
    00178         {
    00179             return point * multiplier;
    00180         }
    00181
    00182
    00190         inline friend double operator * (FTPoint &a, FTPoint& b)
    00191         {
    00192             return a.values[0] * b.values[0]
    00193                  + a.values[1] * b.values[1]
    00194                  + a.values[2] * b.values[2];
    00195         }
    00196
    00197
    00204         inline FTPoint operator ^ (const FTPoint& point)
    00205         {
    00206             FTPoint temp;
    00207             temp.values[0] = values[1] * point.values[2]
    00208                               - values[2] * point.values[1];
    00209             temp.values[1] = values[2] * point.values[0]
    00210                               - values[0] * point.values[2];
    00211             temp.values[2] = values[0] * point.values[1]
    00212                               - values[1] * point.values[0];
    00213             return temp;
    00214         }
    00215
    00216
    00224         friend bool operator == (const FTPoint &a, const FTPoint &b);
    00225
    00226
    00234         friend bool operator != (const FTPoint &a, const FTPoint &b);
    00235
    00236
    00240         inline operator const FTGL_DOUBLE*() const
    00241         {
    00242             return values;
    00243         }
    00244
    00245
    00249         inline void X(FTGL_DOUBLE x) { values[0] = x; };
    00250         inline void Y(FTGL_DOUBLE y) { values[1] = y; };
    00251         inline void Z(FTGL_DOUBLE z) { values[2] = z; };
    00252
    00253
    00257         inline FTGL_DOUBLE X() const { return values[0]; };
    00258         inline FTGL_DOUBLE Y() const { return values[1]; };
    00259         inline FTGL_DOUBLE Z() const { return values[2]; };
    00260         inline FTGL_FLOAT Xf() const { return static_cast<FTGL_FLOAT>(values[0]); };
    00261         inline FTGL_FLOAT Yf() const { return static_cast<FTGL_FLOAT>(values[1]); };
    00262         inline FTGL_FLOAT Zf() const { return static_cast<FTGL_FLOAT>(values[2]); };
    00263
    00264     private:
    00268         FTGL_DOUBLE values[3];
    00269 };
    00270
    00271 #endif //__cplusplus
    00272
    00273 #endif  //  __FTPoint__
    00274