Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make the interp classes use purely floats

  • Loading branch information...
commit 1eea1963e17cb201579e365a097ffd950a9b6430 1 parent 8d3c889
Alistair Riddoch alriddoch authored

Showing 1 changed file with 10 additions and 9 deletions. Show diff stats Hide diff stats

  1. +10 9 Mercator/Segment.cpp
19 Mercator/Segment.cpp
@@ -32,23 +32,24 @@ namespace Mercator {
32 32 class LinInterp {
33 33 private:
34 34 /// The length of the line.
35   - int m_size;
  35 + float m_size;
36 36 /// Flag indicating that both points have the same value.
37 37 bool noCalc;
38 38 public:
39 39 /// Values at the two ends.
40 40 float ep1, ep2;
41 41 /// \brief Determine the interpolated value along the line.
42   - inline float calc(int loc)
  42 + inline float calc(float loc)
43 43 {
44   - return ((noCalc) ? ep1 : ((m_size-loc) * ep1 + loc * ep2));
  44 + return ((noCalc) ? ep1 :
  45 + ((m_size-loc) * ep1 + loc * ep2));
45 46 }
46 47 /// \brief Constructor
47 48 ///
48 49 /// @param size length of the line.
49 50 /// @param l value at one end of the line.
50 51 /// @param h value at one end of the line.
51   - LinInterp(int size,float l, float h) : m_size(size), noCalc(false),
  52 + LinInterp(float size,float l, float h) : m_size(size), noCalc(false),
52 53 ep1(l/size), ep2(h/size)
53 54 {
54 55 if (l==h) {
@@ -67,18 +68,18 @@ class LinInterp {
67 68 class QuadInterp {
68 69 private:
69 70 /// The length of one side of the square quad.
70   - int m_size;
  71 + float m_size;
71 72 /// Flag indicating that all points have the same value.
72 73 bool noCalc;
73 74 public:
74 75 /// Values at the four corners.
75 76 float ep1, ep2, ep3, ep4;
76 77 /// \brief Determine the interpolated value within the quad.
77   - inline float calc(int locX, int locY)
  78 + inline float calc(float locX, float locY)
78 79 {
79 80 return ((noCalc) ? ep1 :
80   - (( ep1*(m_size-locX) + ep2 * locX) * (m_size-locY) +
81   - ( ep4*(m_size-locX) + ep3 * locX) * (locY) ) / m_size );
  81 + (( ep1*(m_size-locX) + ep2 * locX) * (m_size-locY) +
  82 + ( ep4*(m_size-locX) + ep3 * locX) * (locY) ) / m_size );
82 83 }
83 84 /// \brief Constructor
84 85 ///
@@ -87,7 +88,7 @@ class QuadInterp {
87 88 /// @param e2 value at one corner of the square quad.
88 89 /// @param e3 value at one corner of the square quad.
89 90 /// @param e4 value at one corner of the square quad.
90   - QuadInterp(int size,float e1, float e2, float e3, float e4)
  91 + QuadInterp(float size,float e1, float e2, float e3, float e4)
91 92 : m_size(size), noCalc(false),
92 93 ep1(e1/size), ep2(e2/size), ep3(e3/size), ep4(e4/size)
93 94 {

0 comments on commit 1eea196

Please sign in to comment.
Something went wrong with that request. Please try again.