35OVAL::OVAL(
const SEG& aSeg,
int aWidth ) : m_seg( aSeg ), m_width( aWidth )
38 wxASSERT( aWidth > 0 );
46 if( aOverallSize.
x > aOverallSize.
y )
47 segVec.
x = ( aOverallSize.
x - aOverallSize.
y );
49 segVec.y = ( aOverallSize.
y - aOverallSize.
x );
53 m_seg =
SEG( aCenter - segVec / 2, aCenter + segVec / 2 );
54 m_width = std::min( aOverallSize.
x, aOverallSize.
y );
60 const int rad =
m_width / 2 + aClearance;
87 const int half_width = aOval.
GetWidth() / 2;
88 const int half_len = aOval.
GetLength() / 2;
93 std::vector<TYPED_POINT2I> pts;
114 pts.emplace_back(
VECTOR2I{ 0, half_len }, pt_type );
115 pts.emplace_back(
VECTOR2I{ 0, -half_len }, pt_type );
119 const int d_centre_to_cap_centre = half_len - half_width;
130 const auto add_end = [&](
const VECTOR2I& aPt )
136 add_end( { half_width, d_centre_to_cap_centre } );
137 add_end( { half_width, -d_centre_to_cap_centre } );
138 add_end( { -half_width, d_centre_to_cap_centre } );
139 add_end( { -half_width, -d_centre_to_cap_centre } );
155 const VECTOR2I cap_radial = { 0, half_width };
159 EDA_ANGLE radial_line_rotation = rotation;
163 VECTOR2I cap_radial_to_x_axis = cap_radial;
164 RotatePoint( cap_radial_to_x_axis, radial_line_rotation );
171 VECTOR2I cap_radial_to_y_axis = cap_radial;
172 RotatePoint( cap_radial_to_y_axis, radial_line_rotation );
174 const auto add_quadrant = [&](
const VECTOR2I& aPt )
180 add_quadrant(
VECTOR2I{ 0, d_centre_to_cap_centre } + cap_radial_to_y_axis );
181 add_quadrant(
VECTOR2I{ 0, d_centre_to_cap_centre } + cap_radial_to_x_axis );
183 add_quadrant(
VECTOR2I{ 0, -d_centre_to_cap_centre } - cap_radial_to_y_axis );
184 add_quadrant(
VECTOR2I{ 0, -d_centre_to_cap_centre } - cap_radial_to_x_axis );
static constexpr BOX2< VECTOR2I > ByCorners(const VECTOR2I &aCorner1, const VECTOR2I &aCorner2)
Class that represents an oval shape (rectangle with semicircular end caps)
int GetLength() const
Get the overall length of the oval from endcap tip to endcap tip.
EDA_ANGLE GetAngle() const
Get the angle of the oval's central segment.
BOX2I BBox(int aClearance) const
Get the bounding box of the oval.
OVAL(const SEG &aSeg, int aWidth)
Create an oval from the segment joining the centers of the semicircles and the diameter of the semici...
VECTOR2I GetCenter() const
Get the center point of the oval.
const SEG & GetSegment() const
Get the central segment of the oval.
int GetWidth() const
Get the width of the oval (diameter of the semicircles)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
std::vector< TYPED_POINT2I > GetOvalKeyPoints(const OVAL &aOval, OVAL_KEY_POINT_FLAGS aFlags)
Get a list of interesting points on an oval (rectangle with semicircular end caps)
unsigned int OVAL_KEY_POINT_FLAGS
SHAPE_LINE_CHAIN ConvertToChain(const OVAL &aOval)
POINT_TYPE
Meanings that can be assigned to a point in pure geometric terms.
@ PT_CENTER
The point is the center of something.
@ PT_QUADRANT
The point is on a quadrant of a circle (N, E, S, W points).
@ PT_END
The point is at the end of a segment, arc, etc.
@ PT_MID
The point is at the middle of a segment, arc, etc.
VECTOR2I GetRotated(const VECTOR2I &aVector, const EDA_ANGLE &aAngle)
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I
constexpr const VECTOR2< T > & LexicographicalMax(const VECTOR2< T > &aA, const VECTOR2< T > &aB)
constexpr const VECTOR2< T > & LexicographicalMin(const VECTOR2< T > &aA, const VECTOR2< T > &aB)