-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbox2d.cpp
More file actions
33 lines (25 loc) · 687 Bytes
/
box2d.cpp
File metadata and controls
33 lines (25 loc) · 687 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
//
// Created by josselin on 06/11/2019.
//
#include "box2d.h"
box2d::box2d(const box2d::point_type &fp, const box2d::point_type &lp) : lp_{lp}, fp_{fp}, nrows{lp.row-fp.row+1}, ncols{lp.col-fp.col+1}{
}
box2d::box2d() : box2d(point2d(), point2d()){
}
box2d::~box2d() = default;
bool box2d::has(const box2d::point_type &p) const {
return (p.col >= fp_.col && p.col <= lp_.col && p.row >= fp_.row && p.row <= lp_.row);
}
int box2d::rows() const{
return nrows;
}
int box2d::cols() const{
return ncols;
}
box2d &box2d::operator=(const box2d &b) {
nrows = b.lp_.row-b.fp_.row+1;
ncols = b.lp_.col-b.fp_.col+1;
lp_ = b.lp_;
fp_ = b.fp_;
return *this;
}