-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCircularBuffer.cpp
More file actions
50 lines (31 loc) · 950 Bytes
/
CircularBuffer.cpp
File metadata and controls
50 lines (31 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <vector>
#include "CircularBuffer.h"
using namespace std;
unsigned int CircularBuffer::GetRadius()
{
return radius_;
}
unsigned int CircularBuffer::GetSize()
{
return size_;
}
CircularBuffer::CircularBuffer(unsigned int radius, unsigned int scaling_factor)
{
radius_ = radius;
scaling_factor_ = scaling_factor;
unsigned int scaled_radius = scaling_factor*radius;
unsigned int kernel_size = (2*scaled_radius)+1;
int squared_radius = scaled_radius*scaled_radius;
// Create circular kernel index offsets
for (unsigned int j = 0; j < kernel_size; j++){
for (unsigned int k = 0; k < kernel_size; k++){
int xx = j-scaled_radius; // Column offset
int yy = k-scaled_radius; // Row offset
// Check if the grid point is located within the circle
if ((xx*xx + yy*yy) <= squared_radius){
coordinate_offsets_.push_back({xx,yy});
}
}
}
size_ = coordinate_offsets_.size();
}