79 Commits

Author SHA1 Message Date
John Beard
d15b2b7305 SHAPE_ARC: Fix GetCentralAngle normalization documentation
This appears to have always been [-360 .. 360], as some tests in
test_shape_arc.cpp have had negative values for a very long time.

Add tests on the start, end and central angle accessors to enforce
the documented normalizations.
2025-06-08 09:55:54 +08:00
jean-pierre charras
2124f2b846 SHAPE_ARC::GetCentralAngle(): better algo to calculate actual arc.
The old algo worked fine only if the arc "middle point" was on the middle
of the arc. This algo just needs a "middle point" on the arc, not necessary
exactly near the middle of the arc.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21035
2025-06-01 10:12:40 +02:00
Seth Hillbrand
9bedb6eedb Fix silk board edge collision case
First, fix the error limit check in drc_test_provider_edge_clearance.
Then, we rotate the final point incorrectly in SHAPE_ARC::Collide (need
negative angle).  We were not checking this result in the QA, so add the
proper tests
2025-05-19 17:49:03 -07:00
Jeff Young
6757ba8165 Use consistent terminology and types. 2025-05-12 20:28:47 +01:00
Seth Hillbrand
de09403b10 Fix mistake in arc circle collision
Need to test nearest point from the circle center to the arc.  Add QA to
prevent regression

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20336
2025-03-14 18:06:09 -07:00
Seth Hillbrand
c24832f72b Fix IsEffectiveLine calculation
We sometimes represent circles as 360° arcs.  These are approximately
colinear but are definitely not a line
2025-03-06 12:45:10 -08:00
Seth Hillbrand
bfb3875a68 Add additional handling for arc collisions
Provides nearest point calculation for circles, segments and rects

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18203
2025-01-14 13:08:45 -08:00
Seth Hillbrand
b73481dd49 Update SHAPE_ARC::IntersectionPoints()
Force it to handle a number of edge cases from Arc-Arc collision test.
Unify and simplify the Collide Arc-Arc.  Add additional arc collision
QA test
2025-01-14 13:08:45 -08:00
Seth Hillbrand
3e8791b88d Fixup multiple issues with DP checks
Handle arcs properly even when not exactly concentric.  Properly check
for interfering elements that would prevent coupling.  Avoiding those
that are directly connected

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17967
2025-01-13 16:11:16 -08:00
Seth Hillbrand
0b2d4d4879 Revise Copyright statement to align with TLF
Recommendation is to avoid using the year nomenclature as this
information is already encoded in the git repo.  Avoids needing to
repeatly update.

Also updates AUTHORS.txt from current repo with contributor names
2025-01-01 14:12:04 -08:00
Seth Hillbrand
8724a7da09 Treat straight arcs as segments
When an arc has a very small curvature, we should not waste time with
the arc collision mode and instead just use the segment collision as it
is effectively the same result

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19422
2024-12-30 12:57:21 -08:00
John Beard
215533f31a Unify flip direction handling
There was a gentle mish-mash of booleans, some with
true being left/right and some up/down, and some functions that
can flip in both axes (which is never actually done, and doesn't
really make geometric sense).

Replace all this with the FLIP_DIRECTION enum class, which makes
the intention completely unambiguous.

This also then allows a small scattering of simplifications,
because everything takes the same type and you don't have to
fiddle booleans to fit.
2024-09-27 17:13:13 +01:00
John Beard
1fb2d7fe26 Pcbnew: Snap to graphic/track intersections
Relates-To: https://gitlab.com/kicad/code/kicad/-/issues/2329
2024-08-28 13:49:36 +01:00
Seth Hillbrand
cde153c75f Avoid some overflows in KiROUND 2024-06-18 21:37:00 -07:00
Seth Hillbrand
08f181115b Use KiROUND for consistency
Ensure that it is clear we are rounding to nearest point
2024-06-04 08:55:42 -07:00
Seth Hillbrand
590bd6237d Fix off-by-one error in distance check for arcs 2024-06-03 16:29:06 -07:00
Seth Hillbrand
a9ae86eefd Cleanup geometry functions
Added Distance(VECTOR2) function that returns a double.  Removed
superfluous EuclideanNorm, GetLineLength, integer constructor for
EDA_ANGLE (this promotes to double in the CTOR), DistanceLinePoint and
HitTestPoints

Also extended the size for arc calculations that get distances to center
points to avoid overflow
2024-05-31 12:26:37 -07:00
Seth Hillbrand
429625e311 Unify SHAPE_ARC clockwise calc.
We don't really need the extra angle calculations
2024-05-30 14:19:57 -07:00
Seth Hillbrand
819bdf4372 Fix qa failure 2024-05-21 16:26:00 -07:00
Seth Hillbrand
8147527437 Optimize SHAPE_ARC collisions
Handle arcs that are actually circles

Ensure that we get a good clearance value even inside arcs
2024-05-21 09:34:45 -07:00
Alex Shvartzkop
fcdaa4a59e Cache center point and radius along with BBox in SHAPE_ARC. 2024-04-23 19:25:23 +03:00
Seth Hillbrand
3cc1617f5a Fix slow selection time when calculating clearance
The clearance between two zones could be rather slow.  This was in part
to trying to do triangle-triangle collisions between zones when we only
need outline collision and in part to the shape_line_chain collision
routine.  The shape_line_chain collisions don't need to recreate
segments on each iteration and should instead create them once and using
this to check all collisions

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17327
2024-03-11 16:32:24 -07:00
jean-pierre charras
5ac8449e1f Minor compil and Coverity fixes 2024-03-06 13:05:21 +01:00
jean-pierre charras
8ffd4f636a SHAPE_ARC::update_bbox(): use double instead of int to calculate radius, and
if the radius is too large (> INT_MAX/2), consider arc as a segment to avoid overflows.
Nor perfect, but it avoid some issues when calculating bbox.
2024-02-29 18:01:13 +01:00
Jeff Young
11f5908761 Revert the SHAPE_ARC::Collide() part.
The arc width appears to be handled elsewhere (at least in
the test suite).

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16951
2024-02-12 17:51:14 +00:00
Jeff Young
d5ac0ff768 Fix SHAPE_ARC::BBox() and Collide() to honour m_width.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16951
2024-02-12 16:59:57 +00:00
Alex Shvartzkop
1122d80388 Better support for arcs in tuning patterns. 2024-01-31 23:38:05 +03:00
Roberto Fernandez Bautista
673e23c2e6 Fix and simplify SHAPE_LINE_CHAIN::Append( SHAPE_ARC ) + QA tests 2024-01-31 19:17:46 +03:00
Seth Hillbrand
3cf8b718f3 Don't truncate if not needed 2024-01-26 09:11:11 -08:00
Alex Shvartzkop
be1008cbd8 ADDED: Heal Shapes; Fix discontinuities in gfx import and Cleanup dialog. 2023-10-17 10:29:43 +03:00
Jon Evans
bf0592ad53 Lift some point-vs-shape APIs into SHAPE base class
Also provide a virtual method for conversion to polygon
2023-08-17 08:02:14 -04:00
jean-pierre charras
ca2dde23d0 SHAPE_ARC::Collide(): fix incorrect returned position of colliding point.
The previously returned position had nothing to do with the colliding point.
2022-12-18 15:40:15 +01:00
jean-pierre charras
1047e7143a SHAPE_ARC::GetCentralAngle(): ensure a 360 deg arc angle is always returned as 360 deg.
An arc having the same start and end points can be 0 or 360 deg arc.
In Kicad it is always 360 deg arc (i.e. a circle)
Fixes #13182
https://gitlab.com/kicad/code/kicad/issues/13182
2022-12-17 14:44:53 +01:00
Jeff Young
e5de56b6cc Fix edge case in arc collision.
SHAPE_ARC::IntersectLine() fails when one of the arcs start points
is on the center point of the other -- in this case we can't extend
the line to the arc intersection because one point does not define
a line....

Fixes https://gitlab.com/kicad/code/kicad/issues/12609
2022-10-09 23:05:15 +01:00
Seth Hillbrand
b736460e71 Move optional access from value() to *operator
`value()` throws.  Where we check for existence, we don't need to use
the throwing version and should just use the unprotected variant
2022-08-30 13:59:39 -07:00
Seth Hillbrand
f1261e71d4 Replace boost::optional with std::optional 2022-08-25 15:50:47 -07:00
Roberto Fernandez Bautista
4defc946ef Fix rounding errors in SHAPE_ARC::Collide + fix qa tests
Use CIRCLE::NearestPoint to ensure consistency
2022-04-11 13:46:36 +01:00
Jeff Young
007906cd16 Fix a degeneracy bug in arc collisions.
This also fixes a failure to use the correct effective width for
shapes (which might, for instance, inherit their widths from schematic
defaults, netclasses, etc.).

Fixes https://gitlab.com/kicad/code/kicad/issues/11358
2022-04-08 16:15:58 +01:00
Seth Hillbrand
1a7d4f30d9 Fix proper rounding when generating arcs
We should allow for KiROUND to find the proper end point of the mid/end
elements when generating an arc from center/start/angle form
2022-03-04 13:14:19 -08:00
Seth Hillbrand
3c2eb9311f Minor optimization for collision checking
Prevents extra center point calculations
2022-03-04 11:37:49 -08:00
Jeff Young
4eac8d7c66 Remove unit-less angles from geometry lib APIs. 2022-01-20 21:10:04 +00:00
Jeff Young
9298da4ebc ArcToSegmentCount calcs need to use abs value of angle. 2022-01-19 16:01:23 +00:00
Jeff Young
e61144d45a Finish with EDA_ANGLE. 2022-01-16 21:15:40 +00:00
Jeff Young
e84c574830 Some more EDA_ANGLE cleanup. 2022-01-16 19:16:18 +00:00
Jeff Young
1539fa5af2 Move SHAPE_ARC to EDA_ANGLE. 2022-01-16 01:19:45 +00:00
Jeff Young
f3fa7febeb Fix a degrees / tenths-of-a-degree mismatch. 2022-01-15 11:16:19 +00:00
Jeff Young
07013d00e1 More EDA_ANGLE. 2022-01-14 16:08:19 +00:00
Roberto Fernandez Bautista
4de4347baa SHAPE_ARC::Collide( aSeg ) must check segment end points as candidates
The edge case is when the segment is completely contained inside the arc
(This partially reverts b4835c82085a074c0ee00247504055ee063da963 and
adds the missing test cases)
2021-12-14 16:14:56 +00:00
Roberto Fernandez Bautista
b4835c8208 Add test case for SHAPE_ARC::Collide( seg ) + remove unneeded candidates
Followup to commit 01068e0d416ddc6203d6b9e7f3b9c169f62c3d98
2021-12-13 18:06:11 +00:00
Tomasz Wlostowski
01068e0d41 geometry: fix SHAPE_ARC/SEG collision
The arc2segment collision should at also include the arc endpoint projections on the segment being tested. Not sure it covers all possible cases, though.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/9023
2021-12-09 00:37:58 +01:00