OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::AreaMoments Struct Reference

Public Member Functions

void add (const Polygon &polygon)

Public Attributes

double area { 0. }
Vec2d first { Vec2d::Zero() }
Vec3d second { Vec3d::Zero() }

Detailed Description

Member Function Documentation

◆ add()

void Slic3r::AreaMoments::add ( const Polygon & polygon)
inline
141 {
142 if (polygon.points.size() < 3)
143 return;
144 Vec2d p1 = unscaled(polygon.points.back());
145 for (const Point &point : polygon.points) {
146 const Vec2d p2 = unscaled(point);
147 const double a = cross2(p1, p2);
148 area += a / 2.;
149 first += a / 6. * (p1 + p2);
150 second += a / 12. *
151 Vec3d(p1.x() * p1.x() + p1.x() * p2.x() + p2.x() * p2.x(), p1.y() * p1.y() + p1.y() * p2.y() + p2.y() * p2.y(),
152 p1.x() * p1.y() + p2.x() * p2.y() + 0.5 * (p1.x() * p2.y() + p2.x() * p1.y()));
153 p1 = p2;
154 }
155 }
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
int32_t cross2(const Eigen::MatrixBase< Eigen::Matrix< int32_t, 2, 1, Options > > &v1, const Eigen::MatrixBase< Eigen::Matrix< int32_t, 2, 1, Options > > &v2)=delete
constexpr Eigen::Matrix< Tout, 2, EigenArgs... > unscaled(const Slic3r::Point &v) noexcept
Definition Arrange.cpp:81
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
Vec2d first
Definition ConnectedBodies.cpp:136
Vec3d second
Definition ConnectedBodies.cpp:138
double area
Definition ConnectedBodies.cpp:135

References area, Slic3r::cross2(), first, Slic3r::MultiPoint::points, second, and Slic3r::unscaled().

Here is the call graph for this function:

Member Data Documentation

◆ area

double Slic3r::AreaMoments::area { 0. }
135{ 0. };

Referenced by add().

◆ first

Vec2d Slic3r::AreaMoments::first { Vec2d::Zero() }
136{ Vec2d::Zero() };

Referenced by add().

◆ second

Vec3d Slic3r::AreaMoments::second { Vec3d::Zero() }
138{ Vec3d::Zero() };

Referenced by add().


The documentation for this struct was generated from the following file: