Skip to content

Commit

Permalink
fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Jan 29, 2024
1 parent cf1955a commit 5bc96ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/ellipseEnclose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using namespace cpp11::literals;

#include <vector>
#include <limits>

struct Ellipse {
double x;
Expand Down Expand Up @@ -38,7 +39,7 @@ bool points_on_line(const cpp11::doubles_matrix<>& points, Ellipse &enc) {
double y0 = ymin = ymax = points(0, 1);
double xdiff = points(1, 0) - x0;
bool vert = xdiff == 0;
double slope;
double slope = std::numeric_limits<double>::infinity();
if (!vert) {
slope = (points(1, 1) - y0) / xdiff;
}
Expand Down Expand Up @@ -289,10 +290,10 @@ cpp11::writable::data_frame enclose_ellip_points(cpp11::doubles x, cpp11::double
cpp11::writable::doubles a;
cpp11::writable::doubles b;
cpp11::writable::doubles rad;
for (R_xlen_t i = 0; i < splits.size() - 1; ++i) {
for (size_t i = 0; i < splits.size() - 1; ++i) {
int size = splits[i+1] - splits[i];
cpp11::writable::doubles_matrix<> points(size, 2);
for (size_t j = 0; j < points.nrow(); ++j) {
for (R_xlen_t j = 0; j < points.nrow(); ++j) {
points(j, 0) = x[splits[i] + j];
points(j, 1) = y[splits[i] + j];
}
Expand Down
5 changes: 2 additions & 3 deletions src/enclose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ cpp11::writable::data_frame enclose_points(cpp11::doubles x, cpp11::doubles y, c
std::vector<Point> points;
all_points.push_back(points);
int currentId = id[0];
int i;
for (i = 0; i < id.size(); ++i) {
for (R_xlen_t i = 0; i < id.size(); ++i) {
Point p_tmp = {x[i], y[i]};
if (id[i] != currentId) {
currentId = id[i];
Expand All @@ -200,7 +199,7 @@ cpp11::writable::data_frame enclose_points(cpp11::doubles x, cpp11::doubles y, c
}
all_points.back().push_back(p_tmp);
}
for (i = 0; i < all_points.size(); ++i) {
for (size_t i = 0; i < all_points.size(); ++i) {
Circle center = enclosePoints(all_points[i]);
x0.push_back(center.x);
y0.push_back(center.y);
Expand Down
1 change: 1 addition & 0 deletions src/pointPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using namespace cpp11::literals;

#include <math.h>
#include <vector>

double distSquared(std::pair<double, double> p, std::pair<double, double> p1) {
double x = p1.first - p.first;
Expand Down

0 comments on commit 5bc96ab

Please sign in to comment.