OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Arachne::LinearAlg2D Namespace Reference

Functions

static int64_t pointIsLeftOfLine (const Point &p, const Point &a, const Point &b)
static float getAngleLeft (const Point &a, const Point &b, const Point &c)

Function Documentation

◆ getAngleLeft()

float Slic3r::Arachne::LinearAlg2D::getAngleLeft ( const Point & a,
const Point & b,
const Point & c )
inlinestatic

Compute the angle between two consecutive line segments.

The angle is computed from the left side of b when looking from a.

c \ . \ b angle| | a

Parameters
astart of first line segment
bend of first segment and start of second line segment
cend of second line segment
Returns
the angle in radians between 0 and 2 * pi of the corner in b
49{
50 const Vec2i64 ba = (a - b).cast<int64_t>();
51 const Vec2i64 bc = (c - b).cast<int64_t>();
52 const int64_t dott = ba.dot(bc); // dot product
53 const int64_t det = cross2(ba, bc); // determinant
54 if (det == 0) {
55 if ((ba.x() != 0 && (ba.x() > 0) == (bc.x() > 0)) || (ba.x() == 0 && (ba.y() > 0) == (bc.y() > 0)))
56 return 0; // pointy bit
57 else
58 return float(M_PI); // straight bit
59 }
60 const float angle = -atan2(double(det), double(dott)); // from -pi to pi
61 if (angle >= 0)
62 return angle;
63 else
64 return M_PI * 2 + angle;
65}
#define M_PI
Definition ExtrusionSimulator.cpp:31
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
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138
Eigen::Matrix< int64_t, 2, 1, Eigen::DontAlign > Vec2i64
Definition Point.hpp:58
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

References Slic3r::angle(), Slic3r::cast(), Slic3r::cross2(), and M_PI.

Referenced by Slic3r::Arachne::removeColinearEdges().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pointIsLeftOfLine()

int64_t Slic3r::Arachne::LinearAlg2D::pointIsLeftOfLine ( const Point & p,
const Point & a,
const Point & b )
inlinestatic

Returns the determinant of the 2D matrix defined by the vectors ab and ap as rows.

The returned value is zero for p lying (approximately) on the line going through a and b The value is positive for values lying to the left and negative for values lying to the right when looking from a to b.

Parameters
pthe point to check
athe from point of the line
bthe to point of the line
Returns
a positive value when p lies to the left of the line from a to b
27{
28 return int64_t(b.x() - a.x()) * int64_t(p.y() - a.y()) - int64_t(b.y() - a.y()) * int64_t(p.x() - a.x());
29}

Referenced by Slic3r::Arachne::fixSelfIntersections().

Here is the caller graph for this function: