本文整理汇总了C++中point_type类的典型用法代码示例。如果您正苦于以下问题:C++ point_type类的具体用法?C++ point_type怎么用?C++ point_type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了point_type类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: swap
void GerberImporter::linear_draw_circular_aperture(point_type startpoint, point_type endpoint,
coordinate_type radius, unsigned int circle_points, ring_type& ring)
{
const coordinate_type dx = endpoint.x() - startpoint.x();
const coordinate_type dy = endpoint.y() - startpoint.y();
double angle_step;
double offset;
if (circle_points % 2 == 0)
++circle_points;
if (startpoint.x() > endpoint.x())
swap(startpoint, endpoint);
angle_step = 2 * bg::math::pi<double>() / circle_points;
if (dx == 0)
offset = bg::math::pi<double>();
else
offset = atan(dy / dx) + bg::math::pi<double>() / 2;
for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
ring.push_back(point_type(cos(angle_step * i + offset) * radius + startpoint.x(),
sin(angle_step * i + offset) * radius + startpoint.y()));
offset += bg::math::pi<double>();
for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
ring.push_back(point_type(cos(angle_step * i + offset) * radius + endpoint.x(),
sin(angle_step * i + offset) * radius + endpoint.y()));
bg::correct(ring);
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:33,代码来源:gerberimporter.cpp
示例2: sin
void GerberImporter::draw_oval(point_type center, coordinate_type width, coordinate_type height,
coordinate_type hole_diameter, unsigned int circle_points, polygon_type& polygon)
{
double angle_step;
double offset;
coordinate_type x;
coordinate_type y;
coordinate_type radius;
if (circle_points % 2 == 0)
++circle_points;
angle_step = -2 * bg::math::pi<double>() / circle_points;
if (width < height)
{
radius = width / 2;
offset = 0;
x = 0;
y = height / 2 - radius;
}
else
{
radius = height / 2;
offset = -bg::math::pi<double>() / 2;
x = width / 2 - radius;
y = 0;
}
for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
polygon.outer().push_back(point_type(cos(angle_step * i + offset) * radius + center.x() - x,
sin(angle_step * i + offset) * radius + center.y() - y));
offset += bg::math::pi<double>();
for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
polygon.outer().push_back(point_type(cos(angle_step * i + offset) * radius + center.x() + x,
sin(angle_step * i + offset) * radius + center.y() + y));
polygon.outer().push_back(polygon.outer().front());
if (hole_diameter != 0)
{
polygon.inners().resize(1);
draw_regular_polygon(center, hole_diameter, circle_points, 0, false, polygon.inners().front());
}
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:47,代码来源:gerberimporter.cpp
示例3: draw_regular_polygon
void GerberImporter::draw_regular_polygon(point_type center, coordinate_type diameter, unsigned int vertices,
coordinate_type offset, bool clockwise, ring_type& ring)
{
double angle_step;
if (clockwise)
angle_step = -2 * bg::math::pi<double>() / vertices;
else
angle_step = 2 * bg::math::pi<double>() / vertices;
offset *= bg::math::pi<double>() / 180.0;
for (unsigned int i = 0; i < vertices; i++)
ring.push_back(point_type(cos(angle_step * i + offset) * diameter / 2 + center.x(),
sin(angle_step * i + offset) * diameter / 2 + center.y()));
ring.push_back(ring.front());
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:18,代码来源:gerberimporter.cpp
示例4: ceil
void GerberImporter::circular_arc(point_type center, coordinate_type radius,
double angle1, double angle2, unsigned int circle_points,
linestring_type& linestring)
{
const unsigned int steps = ceil((angle2 - angle1) / (2 * bg::math::pi<double>()) * circle_points);
const double angle_step = (angle2 - angle1) / steps;
for (unsigned int i = 0; i < steps; i++)
{
const double angle = angle1 + i * angle_step;
linestring.push_back(point_type(cos(angle) * radius + center.x(),
sin(angle) * radius + center.y()));
}
linestring.push_back(point_type(cos(angle2) * radius + center.x(),
sin(angle2) * radius + center.y()));
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:18,代码来源:gerberimporter.cpp
示例5: draw_rectangle
void GerberImporter::draw_rectangle(point_type center, coordinate_type width, coordinate_type height,
coordinate_type hole_diameter, unsigned int circle_points, polygon_type& polygon)
{
const coordinate_type x = center.x();
const coordinate_type y = center.y();
polygon.outer().push_back(point_type(x - width / 2, y - height / 2));
polygon.outer().push_back(point_type(x - width / 2, y + height / 2));
polygon.outer().push_back(point_type(x + width / 2, y + height / 2));
polygon.outer().push_back(point_type(x + width / 2, y - height / 2));
polygon.outer().push_back(polygon.outer().front());
if (hole_diameter != 0)
{
polygon.inners().resize(1);
draw_regular_polygon(center, hole_diameter, circle_points, 0, false, polygon.inners().front());
}
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:18,代码来源:gerberimporter.cpp
示例6: sliceTriangle
void sliceTriangle(const point_type& A,
const point_type& B,
const point_type& C,
const vec_type& N,
SegmentStack& _segmentStack) const
{
using geometry::prim::Segment;
typedef geometry::comp::Compound<Segment> SegmentPlane;
SegmentStack::iterator _Ait = _segmentStack.get(A.z()),
_Bit = _segmentStack.get(B.z()),
_Cit = _segmentStack.get(C.z()),
it;
Point2f _Aproj = A.project(geometry::base::Z);
vec_type b = B - A;
scalar_type _invBz = 1.0 / b.z();
vec_type c = C - A;
scalar_type _invCz = 1.0 / c.z();
vec_type d = C - B;
scalar_type _invDz = 1.0 / d.z();
scalar_type _ratioR, _ratioS, _pos;
Vec2f r,s;
bool _passedB = false;
for (it = _Ait ; it != _Cit && it != _segmentStack.end(); ++it)
{
SegmentPlane* _segmentPlane = &(it->second);
if (it == _Bit) _passedB = true;
if (!_passedB)
{
_pos = it->first - A.z();
_ratioR = _pos * _invCz;
_ratioS = _pos * _invBz;
s(b.x()*_ratioS,b.y()*_ratioS);
} else
{
_pos = it->first;
_ratioR = (_pos - A.z()) * _invCz;
_ratioS = (_pos - B.z()) * _invDz;
s(b.x() + d.x()*_ratioS,b.y() + d.y()*_ratioS);
}
r(c.x()*_ratioR,c.y()*_ratioR);
Point2f _p0 = _Aproj+r, _p1 = _Aproj+s;
Vec2f _normal = _p1 - _p0; // Normal of segment points
if (_normal.sqrLength() == 0.0) continue;
_normal(-_normal[1],_normal[0]);
/// Swap point to assure that points are in proper order to be able to make lineSegments
if (dot(Vec2f(N.x(),N.y()),_normal) > 0.0) std::swap(_p0,_p1);
_segmentPlane->add(Segment(_p0,_p1));
}
}
开发者ID:aeickho,项目名称:Tomo,代码行数:56,代码来源:TriangleSlicer.hpp
示例7: atan2
void GerberImporter::draw_rectangle(point_type point1, point_type point2, coordinate_type height, polygon_type& polygon)
{
const double angle = atan2(point2.y() - point1.y(), point2.x() - point1.x());
const coordinate_type dx = height / 2 * sin(angle);
const coordinate_type dy = height / 2 * cos(angle);
polygon.outer().push_back(point_type(point1.x() + dx, point1.y() - dy));
polygon.outer().push_back(point_type(point1.x() - dx, point1.y() + dy));
polygon.outer().push_back(point_type(point2.x() - dx, point2.y() + dy));
polygon.outer().push_back(point_type(point2.x() + dx, point2.y() - dy));
polygon.outer().push_back(polygon.outer().front());
bg::correct(polygon);
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:14,代码来源:gerberimporter.cpp
示例8: update_object
void RemoteServerProxy::update_object(uint32_t object_id, double x, double y, char type, point_type points,
bool alive) {
if (alive) {
if (renderers_.find(object_id) != renderers_.end()) {
renderers_[object_id]->update_position(Vector(x, y));
} else if (type == 'b') {
renderers_[object_id] = new BulletRenderer(Vector(x, y), points.front().x());
} else if (type == 'l') {
renderers_[object_id] = new NewLifeRenderer(Vector(x, y), points.front().x());
}
} else if (object_id != object_id_) {
if (renderers_.find(object_id) != renderers_.end()) {
Renderer *render = renderers_[object_id];
renderers_.erase(object_id);
delete render;
}
} else {
if (notify_dead_) {
Logger::info("Perdio todas las vidas");
notifier_("PERDISTE TODAS LAS VIDAS");
notify_dead_ = false;
}
}
}
开发者ID:tinchou,项目名称:bluesjackrabbit,代码行数:24,代码来源:RemoteServerProxy.cpp
示例9: set
static inline void set(point_type& p, CoordinateType const& value)
{
p.y(value);
}
开发者ID:Niko-r,项目名称:geofeatures,代码行数:4,代码来源:point.hpp
示例10: get
static inline CoordinateType get(point_type const& p)
{
return p.y();
}
开发者ID:Niko-r,项目名称:geofeatures,代码行数:4,代码来源:point.hpp
示例11: operator
bool operator()(const point_type& a, const point_type& b) const {
return std::tie(a.x(), a.y()) < std::tie(b.x(), b.y());
}
开发者ID:kmjonsson,项目名称:pcb2gcode,代码行数:3,代码来源:segmentize_tests.cpp
示例12: point_difference_type
point_difference_type(const point_type& aSrc,
const point_type& aDst) :
M(aSrc.get_matrix() - aDst.get_matrix()) { };
开发者ID:ahmadyan,项目名称:ReaK,代码行数:3,代码来源:covar_topology.hpp
示例13: move_position_toward
/**
* Computes the covariance matrix which is the linear interpolation between two matrices, by a fraction.
* \param a The first covariance matrix.
* \param fraction The scalar fraction at which the evaluate the linear interpolation.
* \param b The second covariance matrix.
* \return The interpolated covariance matrix.
*/
point_type move_position_toward(const point_type& a, double fraction, const point_type& b) const {
return point_type(matrix_type(value_type(1.0 - fraction) * a.get_matrix() + value_type(fraction) * b.get_matrix()));
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:10,代码来源:covar_topology.hpp
示例14: adjust
/**
* Adds a given covariance matrix difference to a given covariance matrix.
* \param a A covariance matrix.
* \param delta A covariance matrix difference to add to a.
* \return The adjusted covariance matrix.
*/
point_type adjust(const point_type& a, const point_difference_type& delta) const {
return point_type(matrix_type( a.get_matrix() + delta.M ));
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:9,代码来源:covar_topology.hpp
示例15: copy_ring
shared_ptr<multi_polygon_type> Voronoi::build_voronoi(const multi_polygon_type& input,
coordinate_type bounding_box_offset, coordinate_type max_dist)
{
auto output = make_shared<multi_polygon_type>();
voronoi_diagram_type voronoi_diagram;
voronoi_builder_type voronoi_builder;
vector<segment_type_p> segments;
list<const cell_type *> visited_cells;
size_t segments_num = 0;
ring_type bounding_box_ring;
bg::assign(bounding_box_ring, bg::return_buffer<box_type>(
bg::return_envelope<box_type>(input), bounding_box_offset));
for (const polygon_type& polygon : input)
{
segments_num += polygon.outer().size() - 1;
for (const ring_type& ring : polygon.inners())
{
segments_num += ring.size() - 1;
}
}
segments_num += bounding_box_ring.size() - 1;
segments.reserve(segments_num);
for (const polygon_type& polygon : input)
{
copy_ring(polygon.outer(), segments);
for (const ring_type& ring : polygon.inners())
{
copy_ring(ring, segments);
}
}
copy_ring(bounding_box_ring, segments);
output->resize(input.size());
for (size_t i = 0; i < input.size(); i++)
(*output)[i].inners().resize(input.at(i).inners().size());
boost::polygon::insert(segments.begin(), segments.end(), &voronoi_builder);
voronoi_builder.construct(&voronoi_diagram);
for (const cell_type& cell : voronoi_diagram.cells())
{
if (!cell.is_degenerate())
{
const edge_type *edge = cell.incident_edge();
const cell_type *last_cell = NULL;
const auto found_cell = std::find(visited_cells.begin(), visited_cells.end(), &cell);
bool backwards = false;
if (found_cell == visited_cells.end())
{
pair<const polygon_type *, ring_type *> related_geometries = find_ring(input, cell, *output);
if (related_geometries.first && related_geometries.second)
{
const polygon_type& polygon = *(related_geometries.first);
ring_type& ring = *(related_geometries.second);
do {
if (edge->is_primary())
{
if (edge->is_finite())
{
const point_type startpoint (edge->vertex0()->x(), edge->vertex0()->y());
const point_type endpoint (edge->vertex1()->x(), edge->vertex1()->y());
auto append_remove_extra = [&] (const point_type& point)
{
/*
* This works, but it seems more a workaround than a proper solution.
* Why are these segments here in the first place? FIXME
*/
if (ring.size() >= 2 && bg::equals(point, *(ring.end() - 2)))
ring.pop_back();
else
ring.push_back(point);
};
if (bg::covered_by(startpoint, polygon) && bg::covered_by(endpoint, polygon))
{
ring.clear();
break;
}
if (ring.empty() || startpoint.x() != ring.back().x() || startpoint.y() != ring.back().y())
append_remove_extra(startpoint);
if (edge->is_linear())
append_remove_extra(endpoint);
else
{
vector<point_type_fp_p> sampled_edge;
//.........这里部分代码省略.........
开发者ID:chrysn-pull-requests,项目名称:pcb2gcode,代码行数:101,代码来源:voronoi.cpp
示例16: temp_mpoly
unique_ptr<multi_polygon_type> GerberImporter::render(bool fill_closed_lines, unsigned int points_per_circle)
{
map<int, multi_polygon_type> apertures_map;
ring_type region;
coordinate_type cfactor;
unique_ptr<multi_polygon_type> temp_mpoly (new multi_polygon_type());
bool contour = false;
vector<pair<const gerbv_layer_t *, gerberimporter_layer> >layers (1);
auto layers_equivalent = [](const gerbv_layer_t * const layer1, const gerbv_layer_t * const layer2)
{
const gerbv_step_and_repeat_t& sr1 = layer1->stepAndRepeat;
const gerbv_step_and_repeat_t& sr2 = layer2->stepAndRepeat;
if (layer1->polarity == layer2->polarity &&
sr1.X == sr2.X &&
sr1.Y == sr2.Y &&
sr1.dist_X == sr2.dist_X &&
sr1.dist_Y == sr2.dist_Y)
return true;
else
return false;
};
gerbv_image_t *gerber = project->file[0]->image;
if (gerber->info->polarity != GERBV_POLARITY_POSITIVE)
unsupported_polarity_throw_exception();
if (gerber->netlist->state->unit == GERBV_UNIT_MM)
cfactor = scale / 25.4;
else
cfactor = scale;
layers.front().first = gerber->netlist->layer;
generate_apertures_map(gerber->aperture, apertures_map, points_per_circle, cfactor);
for (gerbv_net_t *currentNet = gerber->netlist; currentNet; currentNet = currentNet->next){
const point_type start (currentNet->start_x * cfactor, currentNet->start_y * cfactor);
const point_type stop (currentNet->stop_x * cfactor, currentNet->stop_y * cfactor);
const double * const parameters = gerber->aperture[currentNet->aperture]->parameter;
multi_polygon_type mpoly;
if (!layers_equivalent(currentNet->layer, layers.back().first))
{
layers.resize(layers.size() + 1);
layers.back().first = currentNet->layer;
}
map<coordinate_type, multi_linestring_type>& paths = layers.back().second.paths;
unique_ptr<multi_polygon_type>& draws = layers.back().second.draws;
auto merge_ring = [&](ring_type& ring)
{
if (ring.size() > 1)
{
polygon_type polygon;
bg::correct(ring);
if (simplify_cutins(ring, polygon))
bg::union_(*draws, polygon, *temp_mpoly);
else
bg::union_(*draws, ring, *temp_mpoly);
ring.clear();
draws.swap(temp_mpoly);
temp_mpoly->clear();
}
};
auto merge_mpoly = [&](multi_polygon_type& mpoly)
{
bg::correct(mpoly);
bg::union_(*draws, mpoly, *temp_mpoly);
mpoly.clear();
draws.swap(temp_mpoly);
temp_mpoly->clear();
};
if (currentNet->interpolation == GERBV_INTERPOLATION_LINEARx1) {
if (currentNet->aperture_state == GERBV_APERTURE_STATE_ON) {
if (contour)
{
if (region.empty())
bg::append(region, start);
bg::append(region, stop);
}
else
{
if (gerber->aperture[currentNet->aperture]->type == GERBV_APTYPE_CIRCLE)
{
linestring_type new_segment;
new_segment.push_back(start);
//.........这里部分代码省略.........
开发者ID:corna,项目名称:pcb2gcode,代码行数:101,代码来源:gerberimporter.cpp
示例17: minpoint
BoundBox(const Point<THEIR_PRECISION>& minpoint, THEIR_PRECISION2 width, THEIR_PRECISION3 height)
: minpoint(minpoint)
, maxpoint(minpoint)
{
maxpoint.offset(width, height);
}
开发者ID:golvok,项目名称:IEEEXtreme-9.0,代码行数:6,代码来源:geometry.hpp
注:本文中的point_type类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论