<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>HippoDraw Class Library</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="hippoApp.ico"> </head><body> <!-- Generated by Doxygen 1.6.2 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_eff62de51072964fc77c85daa9c2b3ad.html">transforms</a> </div> </div> <div class="contents"> <h1>PeriodicBinaryTransform.cxx</h1><a href="PeriodicBinaryTransform_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00011"></a>00011 <span class="comment">// for wcslib</span> <a name="l00012"></a>00012 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span> <a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#include "config.h"</span> <a name="l00014"></a>00014 <span class="preprocessor">#endif</span> <a name="l00015"></a>00015 <span class="preprocessor"></span> <a name="l00016"></a>00016 <span class="preprocessor">#include "<a class="code" href="PeriodicBinaryTransform_8h.html" title="hippodraw::PeriodicBinaryTransform class interface">transforms/PeriodicBinaryTransform.h</a>"</span> <a name="l00017"></a>00017 <a name="l00018"></a>00018 <span class="preprocessor">#include "<a class="code" href="AxisModelBase_8h.html" title="hippodraw::AxisModelBase class interface">axes/AxisModelBase.h</a>"</span> <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="Rectangle_8h.html" title="hippodrw::Rect class interface">graphics/Rectangle.h</a>"</span> <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="UnaryTransform_8h.html" title="UnaryTransform class interface.">UnaryTransform.h</a>"</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#ifdef HAVE_WCSLIB</span> <a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#ifdef _WIN32</span> <a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#include "wcslib/C/wcs.h"</span> <a name="l00025"></a>00025 <span class="preprocessor">#else</span> <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#include "wcslib/wcs.h"</span> <a name="l00027"></a>00027 <span class="preprocessor">#endif</span> <a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00029"></a>00029 <span class="preprocessor"></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <cmath></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <cstdio></span> <a name="l00032"></a>00032 <span class="preprocessor">#include <stdexcept></span> <a name="l00033"></a>00033 <span class="preprocessor">#include <sstream></span> <a name="l00034"></a>00034 <span class="preprocessor">#include <cassert></span> <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="keyword">using namespace </span>hippodraw; <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="keyword">using</span> std::max; <a name="l00039"></a>00039 <span class="keyword">using</span> std::abs; <a name="l00040"></a>00040 <span class="keyword">using</span> std::vector; <a name="l00041"></a>00041 <a name="l00047"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ac72ae21d20ecb739d9671af440e91e8c">00047</a> PeriodicBinaryTransform::PeriodicBinaryTransform() : <a name="l00048"></a>00048 <a class="code" href="classhippodraw_1_1BinaryTransform.html" title="A transform that transforms coordinates from one 2D coordinate system to another...">BinaryTransform</a>(), <a name="l00049"></a>00049 m_x_limits ( -180.0, +180.0 ), <a name="l00050"></a>00050 m_y_limits ( - 90.0, + 90.0 ), <a name="l00051"></a>00051 m_x_offset ( 0.0 ), <a name="l00052"></a>00052 m_y_offset ( 0.0 ) <a name="l00053"></a>00053 { <a name="l00054"></a>00054 } <a name="l00055"></a>00055 <a name="l00056"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a6d15ceafe58947d3b1bddfaef7e2b056">00056</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ac72ae21d20ecb739d9671af440e91e8c" title="The default constructor.">PeriodicBinaryTransform::PeriodicBinaryTransform</a> ( <a class="code" href="classhippodraw_1_1UnaryTransform.html" title="A transform that transforms coordinates in one dimension from one coordinate system...">UnaryTransform</a> * z, <a name="l00057"></a>00057 <span class="keywordtype">bool</span> is_periodic, <a name="l00058"></a>00058 <span class="keywordtype">bool</span> needs_grid, <a name="l00059"></a>00059 <span class="keywordtype">bool</span> needs_x_ticks, <a name="l00060"></a>00060 <span class="keywordtype">bool</span> needs_y_ticks, <a name="l00061"></a>00061 <span class="keywordtype">double</span> xlo, <span class="keywordtype">double</span> xhi, <a name="l00062"></a>00062 <span class="keywordtype">double</span> ylo, <span class="keywordtype">double</span> yhi) : <a name="l00063"></a>00063 <a class="code" href="classhippodraw_1_1BinaryTransform.html" title="A transform that transforms coordinates from one 2D coordinate system to another...">BinaryTransform</a> ( z, is_periodic, needs_grid, needs_x_ticks, needs_y_ticks ), <a name="l00064"></a>00064 m_x_limits ( xlo, xhi ), <a name="l00065"></a>00065 m_y_limits ( ylo, yhi ), <a name="l00066"></a>00066 m_x_offset ( 0.0 ), <a name="l00067"></a>00067 m_y_offset ( 0.0 ) <a name="l00068"></a>00068 { <a name="l00069"></a>00069 } <a name="l00070"></a>00070 <a name="l00071"></a>00071 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ac72ae21d20ecb739d9671af440e91e8c" title="The default constructor.">PeriodicBinaryTransform::</a> <a name="l00072"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ac5f299dafd71bf966c330627a0f44dff">00072</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ac72ae21d20ecb739d9671af440e91e8c" title="The default constructor.">PeriodicBinaryTransform</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html" title="A Periodic transform that transforms coordinates from one 2D coordinate system to...">PeriodicBinaryTransform</a> & t ) : <a name="l00073"></a>00073 <a class="code" href="classhippodraw_1_1BinaryTransform.html" title="A transform that transforms coordinates from one 2D coordinate system to another...">BinaryTransform</a> ( t ), <a name="l00074"></a>00074 m_x_limits( t.limitX() ), <a name="l00075"></a>00075 m_y_limits( t.limitY() ), <a name="l00076"></a>00076 m_x_offset( t.xOffset() ), <a name="l00077"></a>00077 m_y_offset( t.yOffset() ) <a name="l00078"></a>00078 { <a name="l00079"></a>00079 } <a name="l00080"></a>00080 <a name="l00081"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a42c269093e93656ad0c191b9b197037f">00081</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a42c269093e93656ad0c191b9b197037f" title="The virtual destructor.">PeriodicBinaryTransform::~PeriodicBinaryTransform</a> () <a name="l00082"></a>00082 { <a name="l00083"></a>00083 <span class="comment">// Does nothing </span> <a name="l00084"></a>00084 } <a name="l00085"></a>00085 <a name="l00086"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a946a9faad8079120e02e91cb6e997d4d">00086</a> <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a946a9faad8079120e02e91cb6e997d4d" title="Returns the Range limits of the first coordinate.">PeriodicBinaryTransform::limitX</a> ()<span class="keyword"> const</span> <a name="l00087"></a>00087 <span class="keyword"></span>{ <a name="l00088"></a>00088 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a041bec17de2a5e941c8d54d2a87b13f5" title="The limits on X axis of the transform.">m_x_limits</a>; <a name="l00089"></a>00089 } <a name="l00090"></a>00090 <a name="l00091"></a>00091 <a name="l00092"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#acbafa397b9e8ffa2805041c66e2d725c">00092</a> <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#acbafa397b9e8ffa2805041c66e2d725c" title="Returns the Range limits of the second coordinate.">PeriodicBinaryTransform::limitY</a> ()<span class="keyword"> const</span> <a name="l00093"></a>00093 <span class="keyword"></span>{ <a name="l00094"></a>00094 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a047876b9bd671f802f14602381617f5e" title="The limits on Y axis of the transform.">m_y_limits</a>; <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <a name="l00097"></a>00097 <a name="l00098"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aabb65b5472ddc53433971d903fc8b5bb">00098</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aabb65b5472ddc53433971d903fc8b5bb" title="Returns the xOffset of the (periodic) transform.">PeriodicBinaryTransform::xOffset</a>()<span class="keyword"> const</span> <a name="l00099"></a>00099 <span class="keyword"></span>{ <a name="l00100"></a>00100 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a7a08e1429d891e3cb34aeb459ed4c42c" title="The xoffset of this periodic transform.">m_x_offset</a>; <a name="l00101"></a>00101 } <a name="l00102"></a>00102 <a name="l00103"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a3a01bd4b2c11c11efdbb8ba830b38df4">00103</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a3a01bd4b2c11c11efdbb8ba830b38df4" title="Sets the xOffset of the (periodic) transform.">PeriodicBinaryTransform::setXOffset</a>( <span class="keywordtype">double</span> x_offset ) <a name="l00104"></a>00104 { <a name="l00105"></a>00105 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a7a08e1429d891e3cb34aeb459ed4c42c" title="The xoffset of this periodic transform.">m_x_offset</a> = x_offset; <a name="l00106"></a>00106 } <a name="l00107"></a>00107 <a name="l00108"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#af9108db079881494aaf7db53aca67a90">00108</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#af9108db079881494aaf7db53aca67a90" title="Returns the yOffset of the (periodic) transform.">PeriodicBinaryTransform::yOffset</a>()<span class="keyword"> const</span> <a name="l00109"></a>00109 <span class="keyword"></span>{ <a name="l00110"></a>00110 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a020710911cde7e019b7bafb9eb77be56" title="The yoffset of this periodic transform.">m_y_offset</a>; <a name="l00111"></a>00111 } <a name="l00112"></a>00112 <a name="l00113"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#afc93fd3cc59b03bc81379aeac0995887">00113</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#afc93fd3cc59b03bc81379aeac0995887" title="Sets the yOffset of the (periodic) transform.">PeriodicBinaryTransform::setYOffset</a>( <span class="keywordtype">double</span> y_offset ) <a name="l00114"></a>00114 { <a name="l00115"></a>00115 <a name="l00116"></a>00116 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a020710911cde7e019b7bafb9eb77be56" title="The yoffset of this periodic transform.">m_y_offset</a> = y_offset; <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <a name="l00119"></a>00119 <a name="l00120"></a>00120 <span class="keywordtype">double</span> <a name="l00121"></a>00121 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd447ba9ee0856b13d69bc1d9eda205b" title="Modulo Addition along either X or Y axis.">PeriodicBinaryTransform::</a> <a name="l00122"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd447ba9ee0856b13d69bc1d9eda205b">00122</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd447ba9ee0856b13d69bc1d9eda205b" title="Modulo Addition along either X or Y axis.">moduloAdd</a>( <span class="keywordtype">double</span> a1, <span class="keywordtype">double</span> a2, <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7" title="Axes constants.">hippodraw::Axes::Type</a> axis )<span class="keyword"> const</span> <a name="l00123"></a>00123 <span class="keyword"></span>{ <a name="l00124"></a>00124 <span class="keywordflow">if</span> ( axis == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> ) { <a name="l00125"></a>00125 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aaeb7139444a2e9b171ca0c9022a82efe" title="Modulo Addition along X axis.">moduloAddX</a> ( a1, a2); <a name="l00126"></a>00126 } <a name="l00127"></a>00127 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( axis == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> ) { <a name="l00128"></a>00128 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a880c3b6939204a269ad94d93cc4cc648" title="Modulo Addition along Y axis.">moduloAddY</a> ( a1, a2); <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <span class="keywordflow">else</span> <span class="keywordflow">return</span> a1 + a2; <a name="l00131"></a>00131 } <a name="l00132"></a>00132 <a name="l00133"></a>00133 <span class="keywordtype">double</span> <a name="l00134"></a>00134 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a482bfefe73b47c5312897ed0c47b7ad2" title="Modulo Subtraction along either X or Y axis.">PeriodicBinaryTransform::</a> <a name="l00135"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a482bfefe73b47c5312897ed0c47b7ad2">00135</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a482bfefe73b47c5312897ed0c47b7ad2" title="Modulo Subtraction along either X or Y axis.">moduloSub</a>( <span class="keywordtype">double</span> s1, <span class="keywordtype">double</span> s2, <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7" title="Axes constants.">hippodraw::Axes::Type</a> axis )<span class="keyword"> const</span> <a name="l00136"></a>00136 <span class="keyword"></span>{ <a name="l00137"></a>00137 <span class="keywordflow">if</span> ( axis == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> ) { <a name="l00138"></a>00138 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ae8b7123162200a14657d0f12d44099e3" title="Modulo Subtraction along X axis.">moduloSubX</a> ( s1, s2); <a name="l00139"></a>00139 } <a name="l00140"></a>00140 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( axis == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> ) { <a name="l00141"></a>00141 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a20181b0577ebc29300d67b7915e3957c" title="Modulo Subtraction along Y axis.">moduloSubY</a> ( s1, s2); <a name="l00142"></a>00142 } <a name="l00143"></a>00143 <span class="keywordflow">else</span> <span class="keywordflow">return</span> s1 - s2; <a name="l00144"></a>00144 } <a name="l00145"></a>00145 <a name="l00146"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aaeb7139444a2e9b171ca0c9022a82efe">00146</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aaeb7139444a2e9b171ca0c9022a82efe" title="Modulo Addition along X axis.">PeriodicBinaryTransform::moduloAddX</a>( <span class="keywordtype">double</span> x1, <span class="keywordtype">double</span> x2 )<span class="keyword"> const</span> <a name="l00147"></a>00147 <span class="keyword"></span>{ <a name="l00148"></a>00148 <span class="keywordflow">if</span> ( x2 < -DBL_EPSILON ) <a name="l00149"></a>00149 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ae8b7123162200a14657d0f12d44099e3" title="Modulo Subtraction along X axis.">moduloSubX</a> ( x1, -x2 ); <a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="keywordtype">double</span> overshoot = x1 + x2 - <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a041bec17de2a5e941c8d54d2a87b13f5" title="The limits on X axis of the transform.">m_x_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>(); <a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="keywordflow">if</span> ( overshoot > DBL_EPSILON ) { <a name="l00154"></a>00154 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a041bec17de2a5e941c8d54d2a87b13f5" title="The limits on X axis of the transform.">m_x_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() + overshoot; <a name="l00155"></a>00155 } <a name="l00156"></a>00156 <span class="keywordflow">else</span> { <a name="l00157"></a>00157 <span class="keywordflow">return</span> x1 + x2; <a name="l00158"></a>00158 } <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <a name="l00161"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ae8b7123162200a14657d0f12d44099e3">00161</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ae8b7123162200a14657d0f12d44099e3" title="Modulo Subtraction along X axis.">PeriodicBinaryTransform::moduloSubX</a>( <span class="keywordtype">double</span> x1, <span class="keywordtype">double</span> x2 )<span class="keyword"> const</span> <a name="l00162"></a>00162 <span class="keyword"></span>{ <a name="l00163"></a>00163 <span class="keywordflow">if</span> ( x2 < -DBL_EPSILON ) <a name="l00164"></a>00164 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aaeb7139444a2e9b171ca0c9022a82efe" title="Modulo Addition along X axis.">moduloAddX</a> ( x1, -x2 ); <a name="l00165"></a>00165 <a name="l00166"></a>00166 <span class="keywordtype">double</span> undershoot = <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a041bec17de2a5e941c8d54d2a87b13f5" title="The limits on X axis of the transform.">m_x_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() - ( x1 - x2 ); <a name="l00167"></a>00167 <a name="l00168"></a>00168 <span class="keywordflow">if</span> ( undershoot > DBL_EPSILON) <a name="l00169"></a>00169 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a041bec17de2a5e941c8d54d2a87b13f5" title="The limits on X axis of the transform.">m_x_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>() - undershoot; <a name="l00170"></a>00170 <span class="keywordflow">else</span> <a name="l00171"></a>00171 <span class="keywordflow">return</span> x1 - x2; <a name="l00172"></a>00172 } <a name="l00173"></a>00173 <a name="l00174"></a>00174 <a name="l00175"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a880c3b6939204a269ad94d93cc4cc648">00175</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a880c3b6939204a269ad94d93cc4cc648" title="Modulo Addition along Y axis.">PeriodicBinaryTransform::moduloAddY</a>( <span class="keywordtype">double</span> y1, <span class="keywordtype">double</span> y2 )<span class="keyword"> const</span> <a name="l00176"></a>00176 <span class="keyword"></span>{ <a name="l00177"></a>00177 <span class="keywordflow">if</span> ( y2 < -DBL_EPSILON ) <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a20181b0577ebc29300d67b7915e3957c" title="Modulo Subtraction along Y axis.">moduloSubY</a> ( y1, -y2 ); <a name="l00178"></a>00178 <a name="l00179"></a>00179 <span class="keywordtype">double</span> overshoot = y1 + y2 - <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a047876b9bd671f802f14602381617f5e" title="The limits on Y axis of the transform.">m_y_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>(); <a name="l00180"></a>00180 <a name="l00181"></a>00181 <span class="keywordflow">if</span> ( overshoot > DBL_EPSILON ) { <a name="l00182"></a>00182 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a047876b9bd671f802f14602381617f5e" title="The limits on Y axis of the transform.">m_y_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() + overshoot; <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <span class="keywordflow">else</span> { <a name="l00185"></a>00185 <span class="keywordflow">return</span> y1 + y2; <a name="l00186"></a>00186 } <a name="l00187"></a>00187 <a name="l00188"></a>00188 } <a name="l00189"></a>00189 <a name="l00190"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a20181b0577ebc29300d67b7915e3957c">00190</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a20181b0577ebc29300d67b7915e3957c" title="Modulo Subtraction along Y axis.">PeriodicBinaryTransform::moduloSubY</a>( <span class="keywordtype">double</span> y1, <span class="keywordtype">double</span> y2 )<span class="keyword"> const</span> <a name="l00191"></a>00191 <span class="keyword"></span>{ <a name="l00192"></a>00192 <span class="keywordflow">if</span> ( y2 < -DBL_EPSILON ) <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a880c3b6939204a269ad94d93cc4cc648" title="Modulo Addition along Y axis.">moduloAddY</a> ( y1, -y2 ); <a name="l00193"></a>00193 <a name="l00194"></a>00194 <span class="keywordtype">double</span> undershoot = <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a047876b9bd671f802f14602381617f5e" title="The limits on Y axis of the transform.">m_y_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() - ( y1 - y2 ); <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="keywordflow">if</span> ( undershoot > DBL_EPSILON ) <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a047876b9bd671f802f14602381617f5e" title="The limits on Y axis of the transform.">m_y_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>() - undershoot; <a name="l00197"></a>00197 <span class="keywordflow">else</span> <span class="keywordflow">return</span> y1 - y2; <a name="l00198"></a>00198 } <a name="l00199"></a>00199 <a name="l00200"></a>00200 <a name="l00201"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a0da1450badf30043c862df5729ba9b7b">00201</a> <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a0da1450badf30043c862df5729ba9b7b" title="Returns a rectangle enclosing the transformed data space.">PeriodicBinaryTransform::calcRectangle</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & lat, <a name="l00202"></a>00202 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & lon ) <a name="l00203"></a>00203 { <a name="l00204"></a>00204 <span class="keywordtype">double</span> x_lo = lat.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a> (); <a name="l00205"></a>00205 <span class="keywordtype">double</span> x_hi = lat.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a> (); <a name="l00206"></a>00206 <a name="l00207"></a>00207 <span class="keywordtype">double</span> y_lo = lon.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a> (); <a name="l00208"></a>00208 <span class="keywordtype">double</span> y_hi = lon.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a> (); <a name="l00209"></a>00209 <a name="l00210"></a>00210 <span class="keywordtype">double</span> x, y; <a name="l00211"></a>00211 <a name="l00212"></a>00212 <span class="keywordtype">double</span> x_min = 1000; <a name="l00213"></a>00213 <span class="keywordtype">double</span> x_max = -1000; <a name="l00214"></a>00214 <span class="keywordtype">double</span> y_min = 1000; <a name="l00215"></a>00215 <span class="keywordtype">double</span> y_max = -1000; <a name="l00216"></a>00216 <a name="l00217"></a>00217 <span class="keywordtype">int</span> n = 50; <a name="l00218"></a>00218 <span class="keywordtype">double</span> dx = ( x_hi - x_lo ) / n; <a name="l00219"></a>00219 <span class="keywordtype">double</span> dy = ( y_hi - y_lo ) / n; <a name="l00220"></a>00220 <a name="l00221"></a>00221 <a name="l00222"></a>00222 <span class="comment">// Finding out xmin, xmax, ymin, ymax along line y = y_lo</span> <a name="l00223"></a>00223 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i <= n; i++) <a name="l00224"></a>00224 { <a name="l00225"></a>00225 x = x_lo + i * dx; <a name="l00226"></a>00226 y = y_lo; <a name="l00227"></a>00227 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a31f94a56e555e0f16606663ee27f79f3" title="Transform the coordinates on the X and Y axes.">transform</a> ( x, y ); <a name="l00228"></a>00228 x_min = ( x_min < x ) ? x_min : x; <a name="l00229"></a>00229 x_max = ( x_max > x ) ? x_max : x; <a name="l00230"></a>00230 y_min = ( y_min < y ) ? y_min : y; <a name="l00231"></a>00231 y_max = ( y_max > y ) ? y_max : y; <a name="l00232"></a>00232 } <a name="l00233"></a>00233 <a name="l00234"></a>00234 <span class="comment">// Finding out xmin, xmax, ymin, ymax along line y = y_hi</span> <a name="l00235"></a>00235 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i <= n; i++) <a name="l00236"></a>00236 { <a name="l00237"></a>00237 x = x_lo + i * dx; <a name="l00238"></a>00238 y = y_hi; <a name="l00239"></a>00239 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a31f94a56e555e0f16606663ee27f79f3" title="Transform the coordinates on the X and Y axes.">transform</a> ( x, y ); <a name="l00240"></a>00240 x_min = ( x_min < x ) ? x_min : x; <a name="l00241"></a>00241 x_max = ( x_max > x ) ? x_max : x; <a name="l00242"></a>00242 y_min = ( y_min < y ) ? y_min : y; <a name="l00243"></a>00243 y_max = ( y_max > y ) ? y_max : y; <a name="l00244"></a>00244 } <a name="l00245"></a>00245 <a name="l00246"></a>00246 <span class="comment">// Finding out xmin, xmax, ymin, ymax along line x = x_lo</span> <a name="l00247"></a>00247 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i <= n; i++) <a name="l00248"></a>00248 { <a name="l00249"></a>00249 x = x_lo; <a name="l00250"></a>00250 y = y_lo + i * dy; <a name="l00251"></a>00251 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a31f94a56e555e0f16606663ee27f79f3" title="Transform the coordinates on the X and Y axes.">transform</a> ( x, y ); <a name="l00252"></a>00252 x_min = ( x_min < x ) ? x_min : x; <a name="l00253"></a>00253 x_max = ( x_max > x ) ? x_max : x; <a name="l00254"></a>00254 y_min = ( y_min < y ) ? y_min : y; <a name="l00255"></a>00255 y_max = ( y_max > y ) ? y_max : y; <a name="l00256"></a>00256 } <a name="l00257"></a>00257 <a name="l00258"></a>00258 <span class="comment">// Finding out xmin, xmax, ymin, ymax along line x = x_hi</span> <a name="l00259"></a>00259 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i <= n; i++) <a name="l00260"></a>00260 { <a name="l00261"></a>00261 x = x_hi; <a name="l00262"></a>00262 y = y_lo + i * dy; <a name="l00263"></a>00263 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a31f94a56e555e0f16606663ee27f79f3" title="Transform the coordinates on the X and Y axes.">transform</a> ( x, y ); <a name="l00264"></a>00264 x_min = ( x_min < x ) ? x_min : x; <a name="l00265"></a>00265 x_max = ( x_max > x ) ? x_max : x; <a name="l00266"></a>00266 y_min = ( y_min < y ) ? y_min : y; <a name="l00267"></a>00267 y_max = ( y_max > y ) ? y_max : y; <a name="l00268"></a>00268 } <a name="l00269"></a>00269 <a name="l00270"></a>00270 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> ( x_min, y_min, x_max - x_min, y_max - y_min ); <a name="l00271"></a>00271 } <a name="l00272"></a>00272 <a name="l00273"></a>00273 <a name="l00274"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a27698b28446e387519346d8fa02139d3">00274</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a27698b28446e387519346d8fa02139d3" title="Validates the Ranges.">PeriodicBinaryTransform::validate</a> ( <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & lat, <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & lon )<span class="keyword"> const</span> <a name="l00275"></a>00275 <span class="keyword"></span>{ <a name="l00276"></a>00276 <span class="keywordflow">if</span> ( lat.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a> () < <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a041bec17de2a5e941c8d54d2a87b13f5" title="The limits on X axis of the transform.">m_x_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() ) lat.<a class="code" href="classhippodraw_1_1Range.html#a2618a41860251089e4ab57a83429c27f" title="Sets the minimum of the range object.">setLow</a> ( <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a041bec17de2a5e941c8d54d2a87b13f5" title="The limits on X axis of the transform.">m_x_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() ); <a name="l00277"></a>00277 <span class="keywordflow">if</span> ( lat.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a> () > <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a041bec17de2a5e941c8d54d2a87b13f5" title="The limits on X axis of the transform.">m_x_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>() ) lat.<a class="code" href="classhippodraw_1_1Range.html#a57518687fc2be69b208d7424048b9baa" title="Sets the maximum of the range object.">setHigh</a> ( <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a041bec17de2a5e941c8d54d2a87b13f5" title="The limits on X axis of the transform.">m_x_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>() ); <a name="l00278"></a>00278 <a name="l00279"></a>00279 <span class="keywordflow">if</span> ( lon.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a> () < <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a047876b9bd671f802f14602381617f5e" title="The limits on Y axis of the transform.">m_y_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() ) lon.<a class="code" href="classhippodraw_1_1Range.html#a2618a41860251089e4ab57a83429c27f" title="Sets the minimum of the range object.">setLow</a> ( <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a047876b9bd671f802f14602381617f5e" title="The limits on Y axis of the transform.">m_y_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() ); <a name="l00280"></a>00280 <span class="keywordflow">if</span> ( lon.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a> () > <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a047876b9bd671f802f14602381617f5e" title="The limits on Y axis of the transform.">m_y_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>() ) lon.<a class="code" href="classhippodraw_1_1Range.html#a57518687fc2be69b208d7424048b9baa" title="Sets the maximum of the range object.">setHigh</a> ( <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a047876b9bd671f802f14602381617f5e" title="The limits on Y axis of the transform.">m_y_limits</a>.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>() ); <a name="l00281"></a>00281 } <a name="l00282"></a>00282 <a name="l00286"></a>00286 <span class="keyword">const</span> vector < AxisTick > & <a name="l00287"></a>00287 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aa77d61aa1845f1b2ceeb65b869117a67">PeriodicBinaryTransform::</a> <a name="l00288"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aa77d61aa1845f1b2ceeb65b869117a67">00288</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aa77d61aa1845f1b2ceeb65b869117a67">setTicks</a> ( <a class="code" href="classhippodraw_1_1AxisModelBase.html" title="The AxisModelBase class maintains the Range and scaling of an axis.">AxisModelBase</a> & model, <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7" title="Axes constants.">hippodraw::Axes::Type</a> axis ) <a name="l00289"></a>00289 { <a name="l00290"></a>00290 <span class="keywordflow">if</span> ( axis == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7aa70478ce277ffc322f8e1e3418e07355" title="Z axis.">Axes::Z</a> ) { <a name="l00291"></a>00291 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1BinaryTransform.html#a08e3b80cfc9b2bd537dd0998da5087c4" title="The transform on the Z axis.">m_z</a> -> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aa77d61aa1845f1b2ceeb65b869117a67">setTicks</a> ( model ); <a name="l00292"></a>00292 } <a name="l00293"></a>00293 <span class="comment">//else</span> <a name="l00294"></a>00294 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aff8da4c863f74d294ef0d690809bd6f9" title="Helps to decide the tick size for the corresponding axis.">setTickStep</a> ( model ); <a name="l00295"></a>00295 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ae88dedadd3a1069fb2da2fcb3d9bd6b5" title="Sets the first tick on the axis.">setFirstTick</a> ( model ); <a name="l00296"></a>00296 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a548d271ef67968d8487dc24b07a5e911" title="Generates the ticks in the axis.">genTicks</a> ( model, axis ); <a name="l00297"></a>00297 } <a name="l00298"></a>00298 <a name="l00300"></a>00300 <span class="keywordtype">void</span> <a name="l00301"></a>00301 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a708d3cf2546b86b8f38fa17fd396e7c1" title="Sets the range of given axis to be a new &quot;nice&quot; within the limits given...">PeriodicBinaryTransform::</a> <a name="l00302"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a708d3cf2546b86b8f38fa17fd396e7c1">00302</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a708d3cf2546b86b8f38fa17fd396e7c1" title="Sets the range of given axis to be a new &quot;nice&quot; within the limits given...">adjustValues</a> ( <a class="code" href="classhippodraw_1_1AxisModelBase.html" title="The AxisModelBase class maintains the Range and scaling of an axis.">AxisModelBase</a> &, <a name="l00303"></a>00303 <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7" title="Axes constants.">hippodraw::Axes::Type</a>, <a name="l00304"></a>00304 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & ) <a name="l00305"></a>00305 { <a name="l00306"></a>00306 <span class="comment">// Does not do anything as of now </span> <a name="l00307"></a>00307 <span class="keywordflow">return</span>; <a name="l00308"></a>00308 } <a name="l00309"></a>00309 <a name="l00310"></a><a class="code" href="PeriodicBinaryTransform_8cxx.html#a5b78abe7ec141d8c13ef2163a0518883">00310</a> <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="namespacehippodraw.html#a677bae1007193bb8a36edc63239a541a">FLT_EQUAL</a>( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y ) <a name="l00311"></a>00311 { <a name="l00312"></a>00312 <span class="keywordflow">return</span> ( (<span class="keywordtype">double</span>)abs( x - y ) <= 2.0 * ( y * FLT_EPSILON + FLT_MIN ) ); <a name="l00313"></a>00313 } <a name="l00314"></a>00314 <a name="l00315"></a>00315 <a name="l00316"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aff8da4c863f74d294ef0d690809bd6f9">00316</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aff8da4c863f74d294ef0d690809bd6f9" title="Helps to decide the tick size for the corresponding axis.">PeriodicBinaryTransform::setTickStep</a>( <a class="code" href="classhippodraw_1_1AxisModelBase.html" title="The AxisModelBase class maintains the Range and scaling of an axis.">AxisModelBase</a> & axis ) <a name="l00317"></a>00317 { <a name="l00318"></a>00318 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & range = axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#a47adba99d1bb0dd9eb9800f931feb672" title="Returns the range represented by this AxisModel.">getRange</a>(<span class="keyword">false</span>); <a name="l00319"></a>00319 <span class="keywordtype">double</span> rangeLength = range.<a class="code" href="classhippodraw_1_1Range.html#ad207cb443e371f73f07e874c504f60c1" title="Returns the length of the range object.">length</a>(); <a name="l00320"></a>00320 <a name="l00321"></a>00321 <span class="keywordtype">double</span> scale_factor = axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#afbde1a57da2ad6bd8e170d77e36e64bb" title="Returns the scale factor.">getScaleFactor</a>(); <a name="l00322"></a>00322 rangeLength *= scale_factor; <a name="l00323"></a>00323 <a name="l00324"></a>00324 <span class="comment">// The following algorithm determines the magnitude of the range...</span> <a name="l00325"></a>00325 <span class="keywordtype">double</span> rmag = floor( log10( rangeLength ) ); <a name="l00326"></a>00326 axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#af933579f4160e62b19ce2fba5f530c91" title="Sets the magnitude of the range.">setRMag</a>( rmag ); <a name="l00327"></a>00327 <a name="l00328"></a>00328 <span class="keywordtype">double</span> scalelow = range.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() * scale_factor; <a name="l00329"></a>00329 <span class="keywordtype">double</span> scalehigh = range.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>() * scale_factor; <a name="l00330"></a>00330 <a name="l00331"></a>00331 <span class="comment">// We will also need the largest magnitude for labels.</span> <a name="l00332"></a>00332 <span class="keywordtype">double</span> pmag = max( floor( log10( abs ( scalehigh ) ) ), <a name="l00333"></a>00333 floor( log10( abs ( scalelow ) ) ) ); <a name="l00334"></a>00334 axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#a447254d994d524156b490c0f78dc5c5a" title="Sets the magnitude of the power of ten for the tick labels.">setPMag</a>( pmag ); <a name="l00335"></a>00335 <a name="l00336"></a>00336 axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#ae8434910717057b1d2e5a92bba63a756" title="Sets the tick step.">setTickStep</a>( rangeLength / 4.0 ); <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <a name="l00339"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ae88dedadd3a1069fb2da2fcb3d9bd6b5">00339</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ae88dedadd3a1069fb2da2fcb3d9bd6b5" title="Sets the first tick on the axis.">PeriodicBinaryTransform::setFirstTick</a>( <a class="code" href="classhippodraw_1_1AxisModelBase.html" title="The AxisModelBase class maintains the Range and scaling of an axis.">AxisModelBase</a> & axis ) <a name="l00340"></a>00340 { <a name="l00341"></a>00341 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & range = axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#a47adba99d1bb0dd9eb9800f931feb672" title="Returns the range represented by this AxisModel.">getRange</a>(<span class="keyword">false</span>); <a name="l00342"></a>00342 <a name="l00343"></a>00343 axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#a74b0210580d8668f96dabcc2d2260928" title="Sets the value for first tick step.">setFirstTick</a> ( range.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a>() ); <a name="l00344"></a>00344 } <a name="l00345"></a>00345 <a name="l00346"></a>00346 <a name="l00351"></a>00351 <span class="keyword">const</span> vector < AxisTick > & <a name="l00352"></a>00352 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a548d271ef67968d8487dc24b07a5e911" title="Generates the ticks in the axis.">PeriodicBinaryTransform::</a> <a name="l00353"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a548d271ef67968d8487dc24b07a5e911">00353</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a548d271ef67968d8487dc24b07a5e911" title="Generates the ticks in the axis.">genTicks</a>( <a class="code" href="classhippodraw_1_1AxisModelBase.html" title="The AxisModelBase class maintains the Range and scaling of an axis.">AxisModelBase</a> & axis, <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7" title="Axes constants.">hippodraw::Axes::Type</a> axistype ) <a name="l00354"></a>00354 { <a name="l00355"></a>00355 <span class="keywordtype">double</span> y = 0.0, ylabel; <a name="l00356"></a>00356 <a name="l00357"></a>00357 <span class="keywordtype">int</span> num_ticks = 0; <a name="l00358"></a>00358 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#afb83347aa94ee29360b10d085dba3e02" title="The ticks last generated by this transform.">m_ticks</a>.clear(); <a name="l00359"></a>00359 <span class="keywordtype">double</span> pmag = axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#aa5f0390d0531f504b59bbb13de685328" title="Returns the magnitude of the power of ten for the tick labels.">getPMag</a>(); <a name="l00360"></a>00360 <span class="keywordtype">double</span> rmag = axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#a91b53d98dc36d6f69d1670d4a2c9c6ab" title="Sets the magnitude of the range.">getRMag</a>(); <a name="l00361"></a>00361 <span class="keywordtype">double</span> first_tick = axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#ad75d6349899399e6ca07cb1103d86480" title="Returns the value for the first tick step.">getFirstTick</a>(); <a name="l00362"></a>00362 <span class="keywordtype">double</span> tick_step = axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#a4421f43d8e6dbd79ef9e5f863b2da21c" title="Returns the tick step in the true coordinate system.">getTickStep</a>(); <a name="l00363"></a>00363 <span class="keywordtype">double</span> scale_factor = axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#afbde1a57da2ad6bd8e170d77e36e64bb" title="Returns the scale factor.">getScaleFactor</a>(); <a name="l00364"></a>00364 <a name="l00365"></a>00365 <span class="comment">// pmag will get set to 0 if it is less than or equal to 3. This</span> <a name="l00366"></a>00366 <span class="comment">// is used later to determine scientific notation. However, m_rmag</span> <a name="l00367"></a>00367 <span class="comment">// is still needed as the original magnitude for calculations such</span> <a name="l00368"></a>00368 <span class="comment">// as decimal place notation, and rounding to nice numbers.</span> <a name="l00369"></a>00369 <a name="l00370"></a>00370 <span class="keywordtype">bool</span> use_pmag = abs ( pmag ) > 3.0; <a name="l00371"></a>00371 <a name="l00372"></a>00372 axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#ad4bbfdc145a8049e4e52db34d968fd78" title="Use to set the value of the member variable m_use_pmag.">setUsePMag</a> ( use_pmag ); <a name="l00373"></a>00373 <a name="l00374"></a>00374 <span class="keywordtype">char</span> pstr[10]; <a name="l00375"></a>00375 <span class="keywordtype">char</span> labl[10]; <a name="l00376"></a>00376 <a name="l00377"></a>00377 <span class="keywordtype">int</span> decimals = 0; <a name="l00378"></a>00378 <a name="l00379"></a>00379 <span class="comment">// The following if-else block decides the pstr string, which holds</span> <a name="l00380"></a>00380 <span class="comment">// the number of decimal places in the label.</span> <a name="l00381"></a>00381 <a name="l00382"></a>00382 <span class="comment">// if( fabs( m_pmag ) > 3.0 ) {</span> <a name="l00383"></a>00383 <span class="keywordflow">if</span> ( use_pmag ) { <a name="l00384"></a>00384 <span class="comment">// If we are greater than mag 3, we are showing scientific</span> <a name="l00385"></a>00385 <span class="comment">// notation. How many decimals we show is determined by the</span> <a name="l00386"></a>00386 <span class="comment">// difference between the range magnitude and the power magnitude.</span> <a name="l00387"></a>00387 <a name="l00388"></a>00388 decimals = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>( pmag - rmag ); <a name="l00389"></a>00389 <span class="comment">// minumum 1 decimal in scientific notation</span> <a name="l00390"></a>00390 <a name="l00391"></a>00391 <span class="keywordflow">if</span>( !decimals ) decimals++; <a name="l00392"></a>00392 <a name="l00393"></a>00393 } <span class="keywordflow">else</span> { <a name="l00394"></a>00394 <a name="l00395"></a>00395 <span class="keywordflow">if</span>( rmag > 0.0 ){ <a name="l00396"></a>00396 <a name="l00397"></a>00397 <span class="comment">// If we are less than mag 3 and positive, then no decimal</span> <a name="l00398"></a>00398 <span class="comment">// accuracy is needed.</span> <a name="l00399"></a>00399 <a name="l00400"></a>00400 decimals = 0; <a name="l00401"></a>00401 <a name="l00402"></a>00402 } <span class="keywordflow">else</span> { <a name="l00403"></a>00403 <a name="l00404"></a>00404 <span class="comment">// If we are less than mag 3 and negative, then we are suddenly</span> <a name="l00405"></a>00405 <span class="comment">// looking at decimal numbers not in scientific notation.</span> <a name="l00406"></a>00406 <span class="comment">// Therefore we hold as many decimal places as the magnitude.</span> <a name="l00407"></a>00407 <a name="l00408"></a>00408 decimals = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>( abs( rmag ) ); <a name="l00409"></a>00409 <a name="l00410"></a>00410 } <a name="l00411"></a>00411 <a name="l00412"></a>00412 } <a name="l00413"></a>00413 <span class="comment">// @todo decimals should never be negative here, but it does end up</span> <a name="l00414"></a>00414 <span class="comment">// negative in some cases. See the "dirty fix" in Range.cxx, that</span> <a name="l00415"></a>00415 <span class="comment">// dirty-fixed this problem too. But a better fix is needed. </span> <a name="l00416"></a>00416 <span class="keywordflow">if</span> (decimals < 0) <a name="l00417"></a>00417 decimals = 0; <a name="l00418"></a>00418 <a name="l00419"></a>00419 sprintf( pstr, <span class="stringliteral">"%%1.%df"</span>, decimals ); <a name="l00420"></a>00420 <a name="l00421"></a>00421 y = first_tick; <a name="l00422"></a>00422 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> & range = axis.<a class="code" href="classhippodraw_1_1AxisModelBase.html#a47adba99d1bb0dd9eb9800f931feb672" title="Returns the range represented by this AxisModel.">getRange</a>(<span class="keyword">false</span>); <a name="l00423"></a>00423 <span class="keywordtype">double</span> range_high = range.<a class="code" href="classhippodraw_1_1Range.html#a10f7231db7f0fe0855fc344e98575714" title="Returns the maximum of the range object.">high</a>(); <a name="l00424"></a>00424 range_high *= scale_factor; <a name="l00425"></a>00425 <a name="l00426"></a>00426 <span class="keywordflow">while</span>( y <= range_high || <a class="code" href="namespacehippodraw.html#a677bae1007193bb8a36edc63239a541a">FLT_EQUAL</a>( range_high, y ) ) <a name="l00427"></a>00427 { <a name="l00428"></a>00428 <span class="keywordtype">double</span> value = 0.0; <a name="l00429"></a>00429 <a name="l00430"></a>00430 <span class="keywordflow">if</span> ( axistype == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> ) { <a name="l00431"></a>00431 value = <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aaeb7139444a2e9b171ca0c9022a82efe" title="Modulo Addition along X axis.">moduloAddX</a>( y, <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aabb65b5472ddc53433971d903fc8b5bb" title="Returns the xOffset of the (periodic) transform.">xOffset</a>() ); <a name="l00432"></a>00432 } <a name="l00433"></a>00433 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( axistype == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> ) { <a name="l00434"></a>00434 value = <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a880c3b6939204a269ad94d93cc4cc648" title="Modulo Addition along Y axis.">moduloAddY</a>( y, <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#af9108db079881494aaf7db53aca67a90" title="Returns the yOffset of the (periodic) transform.">yOffset</a>() ); <a name="l00435"></a>00435 } <a name="l00436"></a>00436 <a name="l00437"></a>00437 <span class="comment">// Now we either keep the original magnitude</span> <a name="l00438"></a>00438 <span class="comment">// or reduce it in order to express it in scientific notation.</span> <a name="l00439"></a>00439 <a name="l00440"></a>00440 <span class="keywordflow">if</span> ( use_pmag ) ylabel = value / pow( 10.0, pmag ); <a name="l00441"></a>00441 <span class="keywordflow">else</span> ylabel = value; <a name="l00442"></a>00442 <a name="l00443"></a>00443 value /= scale_factor; <a name="l00444"></a>00444 sprintf( labl, pstr, ylabel ); <a name="l00445"></a>00445 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#afb83347aa94ee29360b10d085dba3e02" title="The ticks last generated by this transform.">m_ticks</a>.push_back( <a class="code" href="classhippodraw_1_1AxisTick.html" title="A class to maintain tick coordinates and string values.">AxisTick</a> ( y, labl ) ); <a name="l00446"></a>00446 <a name="l00447"></a>00447 num_ticks++; <a name="l00448"></a>00448 <span class="keywordflow">if</span> ( tick_step == 0.0 ) <span class="keywordflow">break</span>; <a name="l00449"></a>00449 y += tick_step; <a name="l00450"></a>00450 <a name="l00451"></a>00451 } <a name="l00452"></a>00452 <a name="l00453"></a>00453 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#afb83347aa94ee29360b10d085dba3e02" title="The ticks last generated by this transform.">m_ticks</a>; <a name="l00454"></a>00454 } <a name="l00455"></a>00455 <a name="l00456"></a>00456 <a name="l00457"></a>00457 <span class="keywordtype">bool</span> <a name="l00458"></a>00458 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aa8cc334c554916aa03510fb6ba690688" title="Returns true if the transform would be one to one on both the X and Y axes.">PeriodicBinaryTransform::</a> <a name="l00459"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aa8cc334c554916aa03510fb6ba690688">00459</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#aa8cc334c554916aa03510fb6ba690688" title="Returns true if the transform would be one to one on both the X and Y axes.">isLinearInXY</a> ()<span class="keyword"> const</span> <a name="l00460"></a>00460 <span class="keyword"></span>{ <a name="l00461"></a>00461 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00462"></a>00462 } <a name="l00463"></a>00463 <a name="l00464"></a>00464 <a name="l00465"></a>00465 <a name="l00466"></a>00466 <a name="l00467"></a>00467 <a name="l00468"></a>00468 <span class="comment">/* Use WCSLIB to do transform. */</span> <a name="l00469"></a>00469 <a name="l00470"></a>00470 <span class="keywordtype">void</span> <a name="l00471"></a>00471 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a64cf6cfddf44da7cb3daac301dbc02f9" title="Initialize the WCS transform type.">PeriodicBinaryTransform::</a> <a name="l00472"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a64cf6cfddf44da7cb3daac301dbc02f9">00472</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a64cf6cfddf44da7cb3daac301dbc02f9" title="Initialize the WCS transform type.">initwcs</a>(<span class="keyword">const</span> std::string &transformName, <span class="keywordtype">double</span>* crpix, <a name="l00473"></a>00473 <span class="keywordtype">double</span>* crval, <span class="keywordtype">double</span>* cdelt, <span class="keywordtype">double</span> crota2, <span class="keywordtype">bool</span> galactic) <a name="l00474"></a>00474 { <a name="l00475"></a>00475 <span class="preprocessor">#ifdef HAVE_WCSLIB</span> <a name="l00476"></a>00476 <span class="preprocessor"></span> <span class="comment">// Assert the sizeof wcsprm struct is smaller than the size allocated. </span> <a name="l00477"></a>00477 assert(<span class="keyword">sizeof</span>(wcsprm)<=2000); <a name="l00478"></a>00478 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a> = <span class="keyword">reinterpret_cast<</span>wcsprm*<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a834ddd88e0555cb7c2f30ed0c39a1b18">m_wcs_struct</a>); <a name="l00479"></a>00479 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>->flag = -1; <a name="l00480"></a>00480 <a name="l00481"></a>00481 <span class="comment">// Call wcsini() in WCSLIB.</span> <a name="l00482"></a>00482 <span class="keywordtype">int</span> naxis = 2; <a name="l00483"></a>00483 wcsini(1, naxis, <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>); <a name="l00484"></a>00484 <a name="l00485"></a>00485 <span class="comment">// Transfer parameters from c++ class to c stuct.</span> <a name="l00486"></a>00486 std::string <a name="l00487"></a>00487 lon_type = (galactic? <span class="stringliteral">"GLON-"</span> : <span class="stringliteral">"RA---"</span>) + transformName, <a name="l00488"></a>00488 lat_type = (galactic? <span class="stringliteral">"GLAT-"</span> : <span class="stringliteral">"DEC--"</span>) + transformName; <a name="l00489"></a>00489 strcpy(<a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>->ctype[0], lon_type.c_str() ); <a name="l00490"></a>00490 strcpy(<a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>->ctype[1], lat_type.c_str() ); <a name="l00491"></a>00491 <a name="l00492"></a>00492 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<naxis; ++i){ <a name="l00493"></a>00493 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>->crval[i] = crval[i]; <span class="comment">// reference value</span> <a name="l00494"></a>00494 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>->crpix[i] = crpix[i]; <span class="comment">// pixel coordinate</span> <a name="l00495"></a>00495 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>->cdelt[i] = cdelt[i]; <span class="comment">// scale factor</span> <a name="l00496"></a>00496 } <a name="l00497"></a>00497 <span class="preprocessor">#else</span> <a name="l00498"></a>00498 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd1cb57da5768b178b233ac4e91608df" title="Throws an exception if WCSLIB support is missing.">throwWCSMissing</a> (); <a name="l00499"></a>00499 <span class="preprocessor">#endif</span> <a name="l00500"></a>00500 <span class="preprocessor"></span> <a name="l00501"></a>00501 } <a name="l00502"></a>00502 <a name="l00503"></a>00503 <span class="keywordtype">void</span> <a name="l00504"></a>00504 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd1cb57da5768b178b233ac4e91608df" title="Throws an exception if WCSLIB support is missing.">PeriodicBinaryTransform::</a> <a name="l00505"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd1cb57da5768b178b233ac4e91608df">00505</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd1cb57da5768b178b233ac4e91608df" title="Throws an exception if WCSLIB support is missing.">throwWCSMissing</a> ()<span class="keyword"> const</span> <a name="l00506"></a>00506 <span class="keyword"></span>{ <a name="l00507"></a>00507 <span class="keyword">const</span> std::string what <a name="l00508"></a>00508 ( <span class="stringliteral">"HippoDraw has not been compiled with WCSLIB support"</span> ); <a name="l00509"></a>00509 <span class="keywordflow">throw</span> std::runtime_error ( what ); <a name="l00510"></a>00510 } <a name="l00511"></a>00511 <a name="l00512"></a>00512 <a name="l00513"></a>00513 <a name="l00514"></a>00514 <span class="comment">/* virtual */</span> <a name="l00515"></a>00515 <span class="keywordtype">void</span> <a name="l00516"></a>00516 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a31f94a56e555e0f16606663ee27f79f3" title="Transform the coordinates on the X and Y axes.">PeriodicBinaryTransform::</a> <a name="l00517"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a31f94a56e555e0f16606663ee27f79f3">00517</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a31f94a56e555e0f16606663ee27f79f3" title="Transform the coordinates on the X and Y axes.">transform</a> ( <span class="keywordtype">double</span> & lon, <span class="keywordtype">double</span> & lat )<span class="keyword"> const</span> <a name="l00518"></a>00518 <span class="keyword"></span>{ <a name="l00519"></a>00519 <a name="l00520"></a>00520 <span class="preprocessor">#ifdef HAVE_WCSLIB</span> <a name="l00521"></a>00521 <span class="preprocessor"></span> <span class="keywordtype">int</span> ncoords = 1; <a name="l00522"></a>00522 <span class="keywordtype">int</span> nelem = 2; <a name="l00523"></a>00523 <span class="keywordtype">double</span> imgcrd[2], pixcrd[2]; <a name="l00524"></a>00524 <span class="keywordtype">double</span> phi[1], theta[1]; <a name="l00525"></a>00525 <span class="keywordtype">int</span> stat[1]; <a name="l00526"></a>00526 <a name="l00527"></a>00527 <span class="keywordtype">double</span> worldcrd[] ={lon,lat}; <a name="l00528"></a>00528 <a name="l00529"></a>00529 <span class="comment">// int returncode = </span> <a name="l00530"></a>00530 wcss2p(<a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>, ncoords, nelem, worldcrd, phi, theta, imgcrd, pixcrd, stat); <a name="l00531"></a>00531 <a name="l00532"></a>00532 lon = pixcrd[0]; <a name="l00533"></a>00533 lat = pixcrd[1]; <a name="l00534"></a>00534 <span class="preprocessor">#else</span> <a name="l00535"></a>00535 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd1cb57da5768b178b233ac4e91608df" title="Throws an exception if WCSLIB support is missing.">throwWCSMissing</a> (); <a name="l00536"></a>00536 <span class="preprocessor">#endif</span> <a name="l00537"></a>00537 <span class="preprocessor"></span> <a name="l00538"></a>00538 <a name="l00539"></a>00539 } <a name="l00540"></a>00540 <a name="l00541"></a>00541 <a name="l00542"></a>00542 <span class="keywordtype">bool</span> <a name="l00543"></a>00543 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ac16283647c1b08fffef97928ddb106e8" title="Transform the transformed coordinates on X and Y axis back to the original true data...">PeriodicBinaryTransform::</a> <a name="l00544"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ac16283647c1b08fffef97928ddb106e8">00544</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#ac16283647c1b08fffef97928ddb106e8" title="Transform the transformed coordinates on X and Y axis back to the original true data...">inverseTransform</a> ( <span class="keywordtype">double</span> & lon, <span class="keywordtype">double</span> & lat )<span class="keyword"> const</span> <a name="l00545"></a>00545 <span class="keyword"></span>{ <a name="l00546"></a>00546 <a name="l00547"></a>00547 <span class="preprocessor">#ifdef HAVE_WCSLIB</span> <a name="l00548"></a>00548 <span class="preprocessor"></span> <span class="keywordtype">int</span> ncoords = 1; <a name="l00549"></a>00549 <span class="keywordtype">int</span> nelem = 2; <a name="l00550"></a>00550 <span class="keywordtype">double</span> worldcrd[2], imgcrd[2]; <a name="l00551"></a>00551 <span class="keywordtype">double</span> phi[1], theta[1]; <a name="l00552"></a>00552 <span class="keywordtype">int</span> stat[1]; <a name="l00553"></a>00553 <a name="l00554"></a>00554 <span class="keywordtype">double</span> pixcrd[] = {lon,lat}; <a name="l00555"></a>00555 <a name="l00556"></a>00556 <span class="keywordtype">int</span> returncode = <a name="l00557"></a>00557 wcsp2s(<a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>, ncoords, nelem, pixcrd, imgcrd, phi, theta, worldcrd, stat); <a name="l00558"></a>00558 <a name="l00559"></a>00559 <a name="l00560"></a>00560 <span class="comment">// If there is invalid coordinate, return false.</span> <a name="l00561"></a>00561 <span class="keywordflow">if</span> ( returncode == 8 ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00562"></a>00562 <a name="l00563"></a>00563 <span class="comment">// Make sure the inverse transform result in (-180,180) or (0,360)</span> <a name="l00564"></a>00564 <span class="comment">//if (worldcrd[0]<0) worldcrd[0]=worldcrd[0]+360;</span> <a name="l00565"></a>00565 lon = worldcrd [0]; <a name="l00566"></a>00566 lat = worldcrd [1]; <a name="l00567"></a>00567 <a name="l00568"></a>00568 <a name="l00569"></a>00569 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00570"></a>00570 <span class="preprocessor">#else</span> <a name="l00571"></a>00571 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd1cb57da5768b178b233ac4e91608df" title="Throws an exception if WCSLIB support is missing.">throwWCSMissing</a> (); <a name="l00572"></a>00572 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00573"></a>00573 <span class="preprocessor">#endif</span> <a name="l00574"></a>00574 <span class="preprocessor"></span>} <a name="l00575"></a>00575 <a name="l00576"></a>00576 <span class="keywordtype">void</span> <a name="l00577"></a>00577 <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a31f94a56e555e0f16606663ee27f79f3" title="Transform the coordinates on the X and Y axes.">PeriodicBinaryTransform::</a> <a name="l00578"></a><a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a34f7f3bd11217232cdfb450ffaac65bf">00578</a> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a31f94a56e555e0f16606663ee27f79f3" title="Transform the coordinates on the X and Y axes.">transform</a> ( std::vector< double > & lon, <a name="l00579"></a>00579 std::vector< double > & lat )<span class="keyword"> const</span> <a name="l00580"></a>00580 <span class="keyword"></span>{ <a name="l00581"></a>00581 <a name="l00582"></a>00582 <span class="preprocessor">#ifdef HAVE_WCSLIB</span> <a name="l00583"></a>00583 <span class="preprocessor"></span> assert ( lat.size() == lon.size() ); <a name="l00584"></a>00584 <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = lat.size(); <a name="l00585"></a>00585 <a name="l00586"></a>00586 <span class="comment">// Form vector to array.</span> <a name="l00587"></a>00587 vector < double > worldcrd ( 2*size ); <a name="l00588"></a>00588 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < size; i++ ) { <a name="l00589"></a>00589 worldcrd[2*i]= lon[i]; <a name="l00590"></a>00590 worldcrd[2*i+1]= lat[i]; <a name="l00591"></a>00591 } <a name="l00592"></a>00592 <a name="l00593"></a>00593 <span class="keywordtype">int</span> ncoords = size; <a name="l00594"></a>00594 <span class="keywordtype">int</span> nelem = 2; <a name="l00595"></a>00595 <a name="l00596"></a>00596 vector < double > pixcrd( 2*size ); <a name="l00597"></a>00597 vector < double > imgcrd( 2*size ); <a name="l00598"></a>00598 vector < double > phi( size ); <a name="l00599"></a>00599 vector < double > theta( size ); <a name="l00600"></a>00600 vector < int > stat ( size ); <a name="l00601"></a>00601 <a name="l00602"></a>00602 <span class="comment">//int returncode =</span> <a name="l00603"></a>00603 wcss2p ( <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#a674800292f611d2f74ee584362048c39">m_wcs</a>, ncoords, nelem, &worldcrd[0], &phi[0], &theta[0], <a name="l00604"></a>00604 &imgcrd[0], &pixcrd[0], &stat[0] ); <a name="l00605"></a>00605 <a name="l00606"></a>00606 <span class="comment">// From array to vector; </span> <a name="l00607"></a>00607 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < size; i++ ) { <a name="l00608"></a>00608 lon[i]=pixcrd[2*i]; <a name="l00609"></a>00609 lat[i]=pixcrd[2*i+1]; <a name="l00610"></a>00610 } <a name="l00611"></a>00611 <a name="l00612"></a>00612 <span class="preprocessor">#else</span> <a name="l00613"></a>00613 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1PeriodicBinaryTransform.html#abd1cb57da5768b178b233ac4e91608df" title="Throws an exception if WCSLIB support is missing.">throwWCSMissing</a> (); <a name="l00614"></a>00614 <span class="preprocessor">#endif</span> <a name="l00615"></a>00615 <span class="preprocessor"></span>} </pre></div></div> <hr size="1"><address style="align: right;"><small> Generated for HippoDraw Class Library by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0> </a> </small></address> </body> </html>