/// This file is part of the X3DToolKit library /// Copyright (C) 2002-2004 Yannick Le Goc (legoc@imag.fr) /// http://artis.imag.fr/Members/Yannick.Legoc/X3D/ /// 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 #ifndef X3DTK_SFPOINT3F_H #define X3DTK_SFPOINT3F_H #include "SFVec3f.h" #include #include namespace X3DTK { class SFString; /*! \brief Class declared in providing a 3D point. * * SFPoint3f is a point in an affin space, which is different from a vector represented * by the SFVec3f class. When it is multiplied by a SFMatrix34f, the translation is applied. * * \ingroup base */ class SFPoint3f { public: /// x coordinates. float x; /// y coordinates. float y; /// z coordinates. float z; /// Constructor. SFPoint3f(); /// Constructor with x, y and z coordinates in parameters. SFPoint3f(float x, float y, float z); /// Copy constructor. SFPoint3f(const SFPoint3f &p); /// Overloaded assignment operator. SFPoint3f &operator= (const SFPoint3f &v); /// Overloaded operator. SFPoint3f &operator+= (const SFVec3f &v); /// Overloaded operator. SFPoint3f &operator+= (const SFPoint3f &v); /// Overloaded operator. SFPoint3f &operator-= (const SFVec3f &v); /// Explicit constructor from a string of which format is "x y z". explicit SFPoint3f(const SFString &s); // Conversion from vector to point. explicit SFPoint3f(const SFVec3f &V); /// Bracket operator. inline float &operator[](int i) {return (&x)[i];}; /// Bracket operator. inline const float &operator[](int i) const {return (&x)[i];}; /// Overloaded operator+. friend SFPoint3f operator+ (const SFPoint3f &v1, const SFVec3f &v2); /// Overloaded operator+. friend SFPoint3f operator+ (const SFPoint3f &v1, const SFPoint3f &v2); /// Overloaded operator-. friend SFPoint3f operator- (const SFPoint3f &v1, const SFVec3f &v2); /// Overloaded operator-. friend SFVec3f operator- (const SFPoint3f &v1, const SFPoint3f &v2); /// Overloaded operator*. friend SFPoint3f operator* (const float a, const SFPoint3f &v); /// Returns the distance between the points A and B. friend float distance(const SFPoint3f &A, const SFPoint3f &B); /// Returns the pointed array. inline float *f_data() {return &x;}; /// Returns the pointed array. inline const float *f_data() const {return &x;}; /// Returns the pointed array. inline operator float *() {return &x;}; /// Returns the pointed array. inline operator const float *() const {return &x;}; /// Origin point. static const SFPoint3f null; }; } #endif