Baseline Flop Count Update, New Float Baseline
This commit is contained in:
committed by
Ahmed Kallala
parent
40f4421d60
commit
43e54871df
@@ -0,0 +1,44 @@
|
||||
// # Replaced double with float
|
||||
// # Predecessor: board_reduced.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
struct Obstacle {
|
||||
float start_x;
|
||||
float start_y;
|
||||
float end_x;
|
||||
float end_y;
|
||||
float obstacle_v_x;
|
||||
float obstacle_v_y;
|
||||
float length_sq_inv;
|
||||
|
||||
Obstacle() : start_x(0), start_y(0), end_x(0), end_y(0), obstacle_v_x(0), obstacle_v_y(0), length_sq_inv(0.0) {}
|
||||
|
||||
Obstacle(float s_x, float s_y, float e_x, float e_y) : start_x(s_x), start_y(s_y), end_x(e_x), end_y(e_y) {
|
||||
obstacle_v_x = end_x - start_x;
|
||||
obstacle_v_y = end_y - start_y;
|
||||
|
||||
float length_sq = obstacle_v_x * obstacle_v_x + obstacle_v_y * obstacle_v_y;
|
||||
length_sq_inv = length_sq != 0.0 ? 1.0 / length_sq : 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
struct Board {
|
||||
float length;
|
||||
float width;
|
||||
Obstacle *obstacles;
|
||||
int n_obstacles;
|
||||
|
||||
Board(float l, float w, int n, Obstacle *o) : length(l), width(w), n_obstacles(n + 2) {
|
||||
obstacles = new Obstacle[n + 2];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
obstacles[i] = o[i];
|
||||
}
|
||||
|
||||
obstacles[n] = Obstacle(0, 0, l, 0);
|
||||
obstacles[n + 1] = Obstacle(0, w, l, w);
|
||||
}
|
||||
|
||||
~Board() { delete[] obstacles; }
|
||||
};
|
||||
Reference in New Issue
Block a user