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 Vector2d with double
|
||||
// # Predecessor: board.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
struct Obstacle {
|
||||
double start_x;
|
||||
double start_y;
|
||||
double end_x;
|
||||
double end_y;
|
||||
double obstacle_v_x;
|
||||
double obstacle_v_y;
|
||||
double 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(double s_x, double s_y, double e_x, double 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;
|
||||
|
||||
double 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 {
|
||||
double length;
|
||||
double width;
|
||||
Obstacle *obstacles;
|
||||
int n_obstacles;
|
||||
|
||||
Board(double l, double 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