本文整理汇总了C++中Points类的典型用法代码示例。如果您正苦于以下问题:C++ Points类的具体用法?C++ Points怎么用?C++ Points使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Points类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: normalCase
void normalCase(Point start, Point end, double slope, Points &points) const {
double inverseSlope = 1/slope;
double b = start.y - slope*start.x;
bool isLeftRight = start.x < end.x;
if (!isLeftRight) {
Point tmp = start;
start = end;
end = tmp;
}
double xStart = ceil(start.x);
double xEnd = end.x;
for (double x = xStart; x < xEnd; x += step_)
points.push_back(Point(x, slope*x + b));
bool isBottomTop = start.y < end.y;
if (!isBottomTop) {
Point tmp = start;
start = end;
end = tmp;
}
double yStart = ceil(start.y);
double yEnd = end.y;
for (double y = yStart; y < yEnd; y += step_)
points.push_back(Point((y - b)*inverseSlope, y));
if (isLeftRight)
std::sort(points.begin(), points.end(), sort_x());
else
std::sort(points.begin(), points.end(), sort_reverse_x());
}
示例2: offset
void BriefingScreen::draw_system_map() const {
Point off = offset();
{
Points points;
for (int i = 0; i < _system_stars.size(); ++i) {
const Star& star = _system_stars[i];
RgbColor star_color = GetRGBTranslateColorShade(Hue::GRAY, star.shade + DARKEST);
Point location = star.location;
location.offset(off.h, off.v);
points.draw(location, star_color);
}
}
coordPointType corner;
int32_t scale;
Rect pix_bounds = _bounds.size().as_rect();
GetLevelFullScaleAndCorner(0, &corner, &scale, &pix_bounds);
Rect bounds = _bounds;
bounds.offset(off.h, off.v);
draw_arbitrary_sector_lines(corner, scale, 16, bounds);
draw_briefing_objects(bounds.origin(), 32, pix_bounds, corner, scale);
}
示例3: make_ball_basis
sp_mat make_ball_basis(const Points & points,
const Points & centers,
uint R){
/*
Make a set of balls.
Each ball has unique points via set subtraction
(think "moon shape" if two balls overlap)
Each ball should have exactly R points, but there may be
Fewer if we run out of points.
*/
uint N = points.n_rows;
uint K = centers.n_rows;
sp_mat basis = sp_mat(N,K);
bvec mask = zeros<bvec>(N);
vec dist;
uvec idx;
double r;
uint k;
for(k = 0; k < K; k++){
dist = lp_norm(points.each_row() - centers.row(k),2,1);
r = find_radius(dist,mask,R);
idx = find(dist < r);
for(uint i = 0; i < idx.n_elem; i++){
// Paint all elements of idx that aren't
// already in another basis
if(0 == mask(idx(i)))
basis(idx(i),k) = 1.0 / (double) idx.n_elem;
}
mask(idx).fill(1); // Add to mask
if(N == sum(mask)){
break;
}
}
basis.resize(N,k); // Avoid all zero
basis = sp_normalise(basis,2,0); // Should be almost ortho
return basis;
}
示例4: getControlPoints
SCurvedHistogram::Points SCurvedHistogram::getControlPoints(const ::fwData::Histogram::csptr& _histogram) const
{
::fwData::Histogram::fwHistogramValues histogramValues = _histogram->getValues();
const float binsWidth = _histogram->getBinsWidth();
const float histogramMin = _histogram->getMinValue();
Point p;
Points controlPoints;
const size_t nbValues = histogramValues.size();
// WARNING: we shouldn't add all the points of the histogram into the vector of controlPoints
// (testing...)
for(size_t i = 0; i < nbValues; ++i)
{
p.first = static_cast<double>(histogramMin + i * binsWidth);
p.second = histogramValues[i];
controlPoints.push_back( p );
}
return controlPoints;
}
示例5: chebpoints
const Points& chebpoints(size_t n) {
if (pointsCache.count(n)) {
return pointsCache.at(n);
}
if (n==0) {
pointsCache[0] = Points{};
return pointsCache.at(0);
}
Points out;
out.reserve(n);
// for(size_t i=0; i <= n; i++) {
// CPLX arg(0,PI * i / (1.0 * n));
// CPLX z = std::exp(arg);
// out.push_back(z.real());
// }
for(size_t i=0; i < n; i++) {
out.push_back(std::cos((2*i+1.0) / (2.0 * n)*cheb::PI));
}
pointsCache[n] = out;
return pointsCache.at(n);
}
示例6: getControlPoints
CurvedHistogram::Points CurvedHistogram::getControlPoints( ::fwData::Histogram::sptr _histogram)
{
::fwData::Histogram::fwHistogramValues histogramValues = _histogram->getValues();
const float binsWidth = _histogram->getBinsWidth();
const float histogramMin = _histogram->getMinValue();
Point p;
Points controlPoints;
const unsigned int nbValues = (int) histogramValues.size();
// WARNING: we shouldn't add all the points of the histogram into the vector of controlPoints
// (testing...)
for(unsigned int i = 0; i < nbValues; ++i)
{
p.first = (double)(histogramMin + i * binsWidth);
p.second = histogramValues[i];
controlPoints.push_back( p );
}
return controlPoints;
}
示例7: ReadPoints
Points ReadPoints(std::ifstream& input) {
Points data;
for (std::string id_str;
std::getline(input, id_str, '\t');) {
Point point;
char last_delimiter;
for (last_delimiter = '\t';
last_delimiter != '\r' && last_delimiter != '\n'; last_delimiter =
input.get()) {
std::string component_str;
input >> component_str;
point.push_back(std::atof(component_str.c_str()));
}
if (last_delimiter == '\r') {
const char slash_n = input.get();
}
data.emplace_back(std::move(point));
}
return data;
}
示例8: FindWithinflattenDescendLists
void FindWithinflattenDescendLists(int totalfound,int* indices,REAL* distances,int N,int* pi,Points& points,Cover::DescendList* descendlists) {
//total found it the sum of the descendlists counts
//found must point to totalfound ints
//upon return found will have the indices of the points on the descendlists
//N is the number of descendlists, one for each query point
//pi must point to 2*N ints
vector<DescendNodePtr> vect(totalfound);
int* numfound=pi;
int* offsets=pi+N;
numfound[0]=descendlists[0].getCount();
offsets[0]=0;
int j=0;
for(DescendNode* node=descendlists[0].first();node;node=descendlists[0].next(node),j++){
new(&vect[j]) DescendNodePtr(node);
}
sort(&vect[0],&vect[0]+j);
for(int k=0;k<j;k++) {
DescendNode* dnode=vect[k].getPtr();
indices[k]=points.getIndex(dnode->getCoverNode()->getPoint());
distances[k]=dnode->getDist();
}
for(int i=1;i<N;i++) {
numfound[i]=descendlists[i].getCount();
offsets[i]=offsets[i-1]+numfound[i-1];
int j=0;
for(DescendNode* node=descendlists[i].first();node;node=descendlists[i].next(node),j++){
new(&vect[j]) DescendNodePtr(node);
}
sort(&vect[0],&vect[0]+j);
for(int k=0;k<j;k++) {
DescendNode* dnode=vect[k].getPtr();
indices[offsets[i]+k]=points.getIndex(dnode->getCoverNode()->getPoint());
distances[offsets[i]+k]=dnode->getDist();
}
}
}
示例9: circle_filled
Points generate::circle_filled(int x, int y, int r)
{
using namespace math;
Points points;
points.points.reserve((r+1)*4);
float xdif;
int rsqr = sqr(r), x1,x2;
for (int i = 0; i <= r; i++)
{
xdif = sqrt((float) (rsqr - sqr(i)));
x1 = x +((int) round(-xdif)); x2 = x +((int) round(xdif)) -1;
// Top half of circle
points.add(x1, y-i);
points.add(x2, y-i);
// Bottom half of circle
points.add(x1, y+i-1);
points.add(x2, y+i-1);
}
return points;
}
示例10: zeroSlope
void zeroSlope(Point start, Point end, Points &points) const {
if ((start.x - end.x)==0) {
bool isBottomTop = start.y < end.y;
if (!isBottomTop) {
Point tmp = start;
start = end;
end = tmp;
}
double yStart = ceil(start.y);
double yEnd = end.y;
for (double y = yStart; y < yEnd; y += step_)
points.push_back(Point(start.x, y));
if (isBottomTop)
std::sort(points.begin(), points.end(), sort_y());
else
std::sort(points.begin(), points.end(), sort_reverse_y());
} else {
bool isLeftRight = start.x < end.x;
if (!isLeftRight) {
Point tmp = start;
start = end;
end = tmp;
}
double xStart = ceil(start.x);
double xEnd = end.x;
for (double x = xStart; x < xEnd; x += step_)
points.push_back(Point(x, start.y));
if (isLeftRight)
std::sort(points.begin(), points.end(), sort_x());
else
std::sort(points.begin(), points.end(), sort_reverse_x());
}
}
示例11: assert
Points DubinsCarSimulator::next(const Points & points,
const vec & actions) const{
assert(DUBINS_DIM == points.n_cols);
assert(points.is_finite());
assert(DUBINS_ACTION_DIM == actions.n_elem);
Points new_points = Points(points);
double u1 = actions(0); // linear velocity
double u2 = actions(1); // angular velocity
new_points.col(0) += m_step * u1 * cos(points.col(2)); // x
new_points.col(1) += m_step * u1 * sin(points.col(2)); // y
new_points.col(2) += m_step * u1*u2; // theta
// Angle wrap
uvec wrap_idx = uvec{2};
mat bbox = {{datum::nan,datum::nan},
{datum::nan,datum::nan},
{-datum::pi,datum::pi}};
wrap(new_points,wrap_idx,bbox);
// May be out of bounds
return new_points;
}
示例12: pow
/* This method finds the point that is closest to both this point and the supplied one */
size_t
Point::nearest_waypoint_index(const Points &points, const Point &dest) const
{
size_t idx = -1;
double distance = -1; // double because long is limited to 2147483647 on some platforms and it's not enough
for (Points::const_iterator p = points.begin(); p != points.end(); ++p) {
// distance from this to candidate
double d = pow(this->x - p->x, 2) + pow(this->y - p->y, 2);
// distance from candidate to dest
d += pow(p->x - dest.x, 2) + pow(p->y - dest.y, 2);
// if the total distance is greater than current min distance, ignore it
if (distance != -1 && d > distance) continue;
idx = p - points.begin();
distance = d;
if (distance < EPSILON) break;
}
return idx;
}
示例13: file
void MainWindow::on_actionOpen_File_triggered()
{
QString fileName = QFileDialog::getOpenFileName(this);
if (fileName.isEmpty())
return ;
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly))
QMessageBox::warning(this, tr("No File Opened!"), tr("Please check your input."), QMessageBox::Abort);
else {
QTextStream fin(&file);
Points points;
int num;
fin >> num;
for (int i = 0; i < num; i++) {
Point tmp;
fin >> tmp.first >> tmp.second;
points.push_back(tmp);
}
file.close();
graph->setPoints(points);
drawWidget->transform->setFocusPolicy();
statusBar()->showMessage(QString("Open File: %1").arg(fileName));
}
}
示例14: Format1
/**
* txt to binary
*/
int Format1(int argc, char** argv)
{
assert(argv[1][0] == '1' && argv[1][1] == 0);
if (argc != 4 && argc != 6) {
cout
<< "-- For type 1, read binary file and output txt file [start_line] and [end_line] is optional"
<< endl;
cout << " " << argv[0]
<< " 1 binary_file_in txt_file_out [start_line] [end_line]" << endl;
return -1;
}
Points<DefaultDataTypes> points;
points.LoadPoints(argv[2]);
int start_line = 0;
int end_line = points.size_;
if (argc == 6) {
start_line = atoi(argv[4]);
end_line = atoi(argv[5]);
}
points.WriteTextFile(argv[3], start_line, end_line);
return -1;
}
示例15: buf_points
void TableCloth::Find_place(Point& start, int x_dir, int y_dir, char cookie, Points& list)
{
Points buf_points(8);
for (int i = start.x + x_dir, j = start.y + y_dir; ; i += x_dir, j += y_dir)
{
if (! CheckIndex(i, j) ) return;
if ( m_table_cloth[i][j] == '.') return;
if ( m_table_cloth[i][j] == cookie)
{
list.Add_last(buf_points);
return;
}
buf_points.Add_last(i, j);
}
}