本文整理汇总了C++中Point类的典型用法代码示例。如果您正苦于以下问题:C++ Point类的具体用法?C++ Point怎么用?C++ Point使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Point类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: grad
// Calculates and return the gradient between two points
double grad(Point a, Point b) {
return 1.0 * (a.y() - b.y()) / (a.x() - b.x());
}
示例2: u
bool ConvexHull::isLeftTurn(Point c, Point a, Point b){
Point u(b.x() - a.x(), b.y() - a.y(), 0),
v(c.x() - a.x(), c.y() - a.y(), 0);
return u.x()*v.y() - u.y()*v.x() >= 0;
}
示例3: Point
Point :: Point(const Point &rhs){
x = rhs.getX();
y = rhs.getY();
}
示例4: translate
//===========================================================================
void TorusVolume::translate(const Point& vec)
//===========================================================================
{
ALWAYS_ERROR_IF(dimension() != vec.dimension(), "Volume and translation vector of different dimension");
location_ += vec;
}
示例5: drawLine
void Canhamo::drawLine(const Point &begin, const Point &end, int r, int g, int b){
CanvasLine line = { { begin.x(), begin.y(), end.x(), end.y() }, { r, g, b } };
canvasLines.push_back(line);
}
示例6: log
//-----------------------------------------------------------------------------
void MeshSmoothing::smooth(Mesh& mesh, std::size_t num_iterations)
{
log(PROGRESS, "Smoothing mesh: %s", mesh.str(false).c_str());
if (mesh.geometry().degree() != 1)
{
dolfin_error("MeshSmoothing.cpp",
"smooth mesh",
"This function does not support higher-order mesh geometry");
}
// Make sure we have cell-facet connectivity
mesh.init(mesh.topology().dim(), mesh.topology().dim() - 1);
// Make sure we have vertex-edge connectivity
mesh.init(0, 1);
// Make sure the mesh is ordered
mesh.order();
// Mark vertices on the boundary so we may skip them
BoundaryMesh boundary(mesh, "exterior");
const MeshFunction<std::size_t> vertex_map = boundary.entity_map(0);
MeshFunction<bool> on_boundary(reference_to_no_delete_pointer(mesh), 0);
on_boundary = false;
if (boundary.num_vertices() > 0)
{
for (VertexIterator v(boundary); !v.end(); ++v)
on_boundary[vertex_map[*v]] = true;
}
// Iterate over all vertices
const std::size_t d = mesh.geometry().dim();
std::vector<double> xx(d);
for (std::size_t iteration = 0; iteration < num_iterations; iteration++)
{
for (VertexIterator v(mesh); !v.end(); ++v)
{
// Skip vertices on the boundary
if (on_boundary[*v])
continue;
// Get coordinates of vertex
const Point p = v->point();
// Compute center of mass of neighboring vertices
for (std::size_t i = 0; i < d; i++) xx[i] = 0.0;
std::size_t num_neighbors = 0;
for (EdgeIterator e(*v); !e.end(); ++e)
{
// Get the other vertex
dolfin_assert(e->num_entities(0) == 2);
std::size_t other_index = e->entities(0)[0];
if (other_index == v->index())
other_index = e->entities(0)[1];
// Create the vertex
Vertex vn(mesh, other_index);
// Skip the vertex itself
if (v->index() == vn.index())
continue;
num_neighbors += 1;
// Compute center of mass
const double* xn = vn.x();
for (std::size_t i = 0; i < d; i++)
xx[i] += xn[i];
}
for (std::size_t i = 0; i < d; i++)
xx[i] /= static_cast<double>(num_neighbors);
// Compute closest distance to boundary of star
double rmin = 0.0;
for (CellIterator c(*v); !c.end(); ++c)
{
// Get local number of vertex relative to facet
const std::size_t local_vertex = c->index(*v);
// Get normal of corresponding facet
Point n = c->normal(local_vertex);
// Get first vertex in facet
Facet f(mesh, c->entities(mesh.topology().dim() - 1)[local_vertex]);
VertexIterator fv(f);
// Compute length of projection of v - fv onto normal
const double r = std::abs(n.dot(p - fv->point()));
if (rmin == 0.0)
rmin = r;
else
rmin = std::min(rmin, r);
}
// Move vertex at most a distance rmin / 2
double r = 0.0;
for (std::size_t i = 0; i < d; i++)
{
const double dx = xx[i] - p[i];
//.........这里部分代码省略.........
示例7: dFunc_linear
float dFunc_linear(const Point& pt)
{ return pt.x()+0.5; }
示例8: dFunc_zoneplate
float dFunc_zoneplate(const Point& pt)
{ return std::sin( 100*M_PI * (std::pow(pt.x()+0.5, 2) + std::pow(pt.y()+0.5, 2)) )/2. + 0.5; }
示例9: dFunc_contrast
float dFunc_contrast(const Point& pt)
{ return (pt.y()+0.5) * std::sin( 100*M_PI * std::pow(pt.x()+0.5, 2) )/2. + 0.5; }
示例10: dFunc_radial
float dFunc_radial(const Point& pt)
{ return pt.norm()*2.; }
示例11: dFunc_quadra
float dFunc_quadra(const Point& pt)
{ return std::pow(pt.x()+0.5, 2); }
示例12: Point
Point Landmark::get_point(map<string,double> values)
{
Point result = Point(m_x_term->evaluate(values), m_y_term->evaluate(values));
result.set_landmark_name(m_name);
return result;
}
示例13: pointInRobotSpace
Geometry2d::Point OurRobot::pointInRobotSpace(Geometry2d::Point pt) const {
Point p = pt;
p.rotate(pos, -angle);
return p;
}
示例14: candidates
void GoalDetection::performSanityChecks(const Fovea &fovea,
const VisionFrame &frame,
std::vector<BBox> ®ions) {
std::vector<BBox> candidates (regions);
regions.clear();
std::vector<BBox>::iterator it;
for (it = candidates.begin(); it != candidates.end(); ++it) {
// Check that the middle and the bottom 75% for edges
// Only need 1 strong edge in each to be good
int middle = (it->a.y() + it->b.y()) / 2;
int bottom = it->a.y() + (it->b.y() - it->a.y()) * 0.75;
bool keepM = false;
bool keepB = false;
for (int col = it->a.x(); col <= it->b.x(); ++col) {
// Check middle
Point edge = fovea.edge(col, middle);
float magnitude = (edge.x() * edge.x()) + (edge.y() * edge.y());
if (magnitude > MIN_EDGE_THRESHOLD) keepM = true;
// Check bottom
edge = fovea.edge(col, bottom);
magnitude = (edge.x() * edge.x()) + (edge.y() * edge.y());
if (magnitude > MIN_EDGE_THRESHOLD) keepB = true;
}
if (!keepM) {
//std::cout << "throwing away since no keepM" << std::endl;
continue ;
}
if (!keepB) {
//std::cout << "throwing away since no keepB" << std::endl;
continue;
}
// Check % of colour in goal post - ie compare length and colour
float length = it->b.y() - it->a.y();
int centre = (it->a.x() + it->b.x()) / 2;
float numColourPixels = 0;
for (int row = it->a.y(); row < it->b.y(); ++row) {
if (fovea.colour(centre, row) == cGOAL_YELLOW) {
++numColourPixels;
}
}
if ((numColourPixels / length) < COLOUR_RATIO_THRESHOLD) {
//std::cout << "throwing away since not enough colour" << std::endl;
continue;
}
// Check bottom of goal post is below field edge
Point fieldEdge = fovea.mapFoveaToImage(Point(centre, 0));
int fieldEdgeY = 0;
if (fovea.top) {
fieldEdgeY = frame.topStartScanCoords[fieldEdge.x()];
} else {
fieldEdgeY = frame.botStartScanCoords[fieldEdge.x()];
}
fieldEdge.y() = std::max(fieldEdge.y(), fieldEdgeY);
fieldEdge = fovea.mapImageToFovea(fieldEdge);
if (fieldEdge.y() > it->b.y()) {
//std::cout << "throwing away since above field edge" << std::endl;
continue;
}
regions.push_back(*it);
}
// If more than 2 goals, things have gone wrong, so panic
if (regions.size() > 2) regions.clear();
}
示例15: stack
void Shape::stack(Shape *p, const Shape *q)
{
Point n = q->north();
Point s = p->south();
p->move(n.x() - s.x(), n.y() -s.y() +1);
}