Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglSphericalTransform.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglSphericalTransform.hpp
00021  *  Created: 15 January 2001 (was sgluSphericalTransform)
00022  *  Summary: spherical transform subclass of sglTransform
00023  *****************************************************************************/
00024 
00025 #ifndef __SGL_SPHERICAL_TRANSFORM_HPP
00026 #define __SGL_SPHERICAL_TRANSFORM_HPP
00027 
00028 #include <sgl.h>
00029 #include <sglTransform.hpp>
00030 
00070 template <class T>
00071 class SGL_DLL_API sglSphericalTransform : public sglTransform<T>
00072 {
00073 public:
00075    enum ModeEnum { eX_UP, eY_UP, eZ_UP };
00076 
00077 public:
00079    sglSphericalTransform();
00081    virtual ~sglSphericalTransform() {}
00082 
00087    void setMode(ModeEnum mode) { m_mode = mode; }
00088 
00092    ModeEnum getMode() const { return m_mode; }
00093 
00095    virtual void reset();
00096 
00100    void updateAzimuth(T delta_azimuth)
00101       {
00102          setAzimuth(m_azimuth + delta_azimuth);
00103       }
00104 
00109    void updateElevation(T delta_elevation)
00110       {
00111          setElevation(m_elevation + delta_elevation);
00112       }
00113 
00117    void updateRadius(T delta_radius)
00118       {
00119          setRadius(m_radius + delta_radius);
00120       }
00121 
00125    void updateCOI(const sglVec3<T> &delta_coi)
00126       {
00127          m_pos_coi += delta_coi;
00128       }
00129 
00135    void updateCOI(T delta_x, T delta_y, T delta_z)
00136       {
00137          m_pos_coi += sglVec3<T>(delta_x, delta_y, delta_z);
00138       }
00139 
00143    T getAzimuth() const { return m_azimuth; }
00144 
00149    void setAzimuth(T new_azimuth);
00150 
00154    T getElevation() const { return m_elevation; }
00155 
00160    void setElevation(T new_elevation);
00161 
00165    T getRadius() const { return m_radius; }
00166 
00171    void setRadius(T new_radius);
00172 
00176    const sglVec3<T> &getCOI() const { return m_pos_coi; }
00177 
00181    void setCOI(const sglVec3<T> &pos_coi) { m_pos_coi = pos_coi; }
00182 
00188    void setCOI(T x, T y, T z) { m_pos_coi.set(x, y, z); }
00189 
00193    void computeMatrix();
00194 
00195    // See sglNode::clone() for details.
00196    virtual sglNode *clone(unsigned int mode) const;
00197 
00198    // See sglObject::printInfo() for details.
00199    virtual void printInfo(ostream &ostrm, const char *indent_spaces) const;
00200 
00201 private:  // not implemented
00202    sglSphericalTransform(const sglSphericalTransform&);
00203    sglSphericalTransform &operator=(const sglSphericalTransform&);
00204 
00205    void copyTo(sglSphericalTransform *dst, unsigned int mode) const;
00206 
00207 protected:
00208    ModeEnum   m_mode;     // defines which is the polar axis (z by default)
00209 
00210    sglVec3<T> m_pos_coi;  // lookat position for center of interest
00211 
00212    T m_radius;      // distance from center of interest
00213    T m_elevation, m_sin_el, m_cos_el;  // elevation angle in degrees
00214    T m_azimuth,   m_sin_az, m_cos_az;  // azimuth angle in degrees
00215 
00216    sglVec2<T>   m_delta_pos;  // HACK - set by subclass
00217 };
00218 
00219 //----------------------------------------------------------------------------
00220 // convenience types:
00221 //    template class 'should' only be float or double
00222 
00224 typedef sglSphericalTransform<float>  sglSphericalTransformf;
00226 typedef sglSphericalTransform<double> sglSphericalTransformd;
00227 
00228 #endif

Generated at Mon Jul 1 18:00:05 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001