mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-29 19:49:58 +02:00
[apps/graph/values] Create a class Interval
Change-Id: Ie05a9887c0f3d4146b9e90a139f57e6eec7981b1
This commit is contained in:
22
apps/graph/values/interval.cpp
Normal file
22
apps/graph/values/interval.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "interval.h"
|
||||
#include <assert.h>
|
||||
|
||||
Graph::Interval::Interval(float start, float end, float step) :
|
||||
m_start(start),
|
||||
m_end(end),
|
||||
m_step(step)
|
||||
{
|
||||
}
|
||||
|
||||
int Graph::Interval::numberOfElements() {
|
||||
if (m_start > m_end) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1 + (m_end - m_start)/m_step;
|
||||
}
|
||||
}
|
||||
|
||||
float Graph::Interval::element(int i) {
|
||||
assert(i >= 0 && i < numberOfElements());
|
||||
return m_start + i*m_step;
|
||||
}
|
||||
Reference in New Issue
Block a user