#include <Bresenham.h>
Definition at line 40 of file Bresenham.h.
Static Public Member Functions | |
| static void | compute (BresenhamCallBack *callBack, SUMOReal val1, SUMOReal val2) |
Data Structures | |
| class | BresenhamCallBack |
| void Bresenham::compute | ( | BresenhamCallBack * | callBack, | |
| SUMOReal | val1, | |||
| SUMOReal | val2 | |||
| ) | [static] |
compute the bresenham - interpolation between both values the higher number is increased by one for each step while the smaller is increased by smaller/higher. In each step, the callback is executed.
Definition at line 42 of file Bresenham.cpp.
References Bresenham::BresenhamCallBack::execute(), and SUMOReal.
Referenced by NBNode::computeLanes2Lanes(), and NBEdge::divideOnEdges().
00042 { 00043 // case1: both numbers are equal 00044 if (val1==val2) { 00045 for (SUMOReal step=0; step<val1; step++) { 00046 callBack->execute(step, step); 00047 } 00048 return; 00049 } 00050 // case2: the first value is higher 00051 if (val1>val2) { 00052 SUMOReal pos = 0; 00053 SUMOReal prop = val2 / val1; 00054 SUMOReal cnt = prop / 2; 00055 for (SUMOReal i=0; i<val1; i++) { 00056 callBack->execute(i, pos); 00057 cnt += prop; 00058 if (cnt>=1.0) { 00059 pos++; 00060 cnt -= 1.0; 00061 } 00062 } 00063 return; 00064 } 00065 // case3: the first value is smaller than the second 00066 if (val1<val2) { 00067 SUMOReal pos = 0; 00068 SUMOReal prop = val1 / val2; 00069 SUMOReal cnt = prop / 2; 00070 for (SUMOReal i=0; i<val2; i++) { 00071 callBack->execute(pos, i); 00072 cnt += prop; 00073 if (cnt>=1.0) { 00074 pos++; 00075 cnt -= 1.0; 00076 } 00077 } 00078 return; 00079 } 00080 }
1.5.6