本文整理汇总了C++中ring_type::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ ring_type::push_back方法的具体用法?C++ ring_type::push_back怎么用?C++ ring_type::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ring_type
的用法示例。
在下文中一共展示了ring_type::push_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: linear_draw_circular_aperture
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);
}
示例2: linear_draw_rectangular_aperture
void GerberImporter::linear_draw_rectangular_aperture(point_type startpoint, point_type endpoint, coordinate_type width,
coordinate_type height, ring_type& ring)
{
if (startpoint.y() > endpoint.y())
swap(startpoint, endpoint);
if (startpoint.x() > endpoint.x())
{
ring.push_back(point_type(startpoint.x() + width / 2, startpoint.y() + height / 2));
ring.push_back(point_type(startpoint.x() + width / 2, startpoint.y() - height / 2));
ring.push_back(point_type(startpoint.x() - width / 2, startpoint.y() - height / 2));
ring.push_back(point_type(endpoint.x() - width / 2, endpoint.y() - height / 2));
ring.push_back(point_type(endpoint.x() - width / 2, endpoint.y() + height / 2));
ring.push_back(point_type(endpoint.x() + width / 2, endpoint.y() + height / 2));
}
else
{
ring.push_back(point_type(startpoint.x() + width / 2, startpoint.y() - height / 2));
ring.push_back(point_type(startpoint.x() - width / 2, startpoint.y() - height / 2));
ring.push_back(point_type(startpoint.x() - width / 2, startpoint.y() + height / 2));
ring.push_back(point_type(endpoint.x() - width / 2, endpoint.y() + height / 2));
ring.push_back(point_type(endpoint.x() + width / 2, endpoint.y() + height / 2));
ring.push_back(point_type(endpoint.x() + width / 2, endpoint.y() - height / 2));
}
bg::correct(ring);
}
示例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());
}