mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Fixed DoubleTangentArc to create Edge
This commit is contained in:
parent
0624bff82e
commit
c4080e1231
2 changed files with 21 additions and 12 deletions
|
|
@ -207,6 +207,9 @@ class DoubleTangentArc(BaseEdgeObject):
|
|||
context: BuildLine | None = BuildLine._get_context(self)
|
||||
validate_inputs(context, self)
|
||||
|
||||
if keep not in [Keep.TOP, Keep.BOTTOM]:
|
||||
raise ValueError(f"Only the TOP or BOTTOM options are supported not {keep}")
|
||||
|
||||
arc_pt = WorkplaneList.localize(pnt)
|
||||
arc_tangent = WorkplaneList.localize(tangent).normalized()
|
||||
if WorkplaneList._get_context() is not None:
|
||||
|
|
@ -269,7 +272,7 @@ class DoubleTangentArc(BaseEdgeObject):
|
|||
_, p1, _ = other.distance_to_with_closest_points(center)
|
||||
TangentArc(arc_pt, p1, tangent=arc_tangent)
|
||||
|
||||
super().__init__(double.wire(), mode=mode)
|
||||
super().__init__(double.edge(), mode=mode)
|
||||
|
||||
|
||||
class EllipticalStartArc(BaseEdgeObject):
|
||||
|
|
@ -719,7 +722,7 @@ class PolarLine(BaseEdgeObject):
|
|||
start (VectorLike): start point
|
||||
length (float): line length
|
||||
angle (float, optional): angle from the local x-axis
|
||||
direction (VectorLike, optional): vector direction to determine angle
|
||||
direction (VectorLike, optional): vector direction to determine angle
|
||||
length_mode (LengthMode, optional): how length defines the line.
|
||||
Defaults to LengthMode.DIAGONAL
|
||||
mode (Mode, optional): combination mode. Defaults to Mode.ADD
|
||||
|
|
@ -863,7 +866,7 @@ class RadiusArc(BaseEdgeObject):
|
|||
else:
|
||||
arc = SagittaArc(start, end, -sagitta, mode=Mode.PRIVATE)
|
||||
|
||||
super().__init__(arc, mode=mode)
|
||||
super().__init__(arc.edge(), mode=mode)
|
||||
|
||||
|
||||
class SagittaArc(BaseEdgeObject):
|
||||
|
|
@ -907,7 +910,7 @@ class SagittaArc(BaseEdgeObject):
|
|||
sag_point = mid_point + sagitta_vector
|
||||
|
||||
arc = ThreePointArc(start, sag_point, end, mode=Mode.PRIVATE)
|
||||
super().__init__(arc, mode=mode)
|
||||
super().__init__(arc.edge(), mode=mode)
|
||||
|
||||
|
||||
class Spline(BaseEdgeObject):
|
||||
|
|
|
|||
|
|
@ -134,14 +134,16 @@ class BuildLineTests(unittest.TestCase):
|
|||
tuple(l5.tangent_at(p1)), tuple(l6.tangent_at(p2) * -1), 5
|
||||
)
|
||||
|
||||
l7 = Spline((15, 5), (5, 0), (15, -5), tangents=[(-1, 0), (1, 0)])
|
||||
l8 = DoubleTangentArc((0, 0, 0), (1, 0, 0), l7, keep=Keep.BOTH)
|
||||
self.assertEqual(len(l8.edges()), 2)
|
||||
# l7 = Spline((15, 5), (5, 0), (15, -5), tangents=[(-1, 0), (1, 0)])
|
||||
# l8 = DoubleTangentArc((0, 0, 0), (1, 0, 0), l7, keep=Keep.BOTH)
|
||||
# self.assertEqual(len(l8.edges()), 2)
|
||||
|
||||
l9 = EllipticalCenterArc((15, 0), 10, 5, start_angle=90, end_angle=270)
|
||||
l10 = DoubleTangentArc((0, 0, 0), (1, 0, 0), l9, keep=Keep.BOTH)
|
||||
self.assertEqual(len(l10.edges()), 2)
|
||||
self.assertTrue(isinstance(l10, Edge))
|
||||
# l10 = DoubleTangentArc((0, 0, 0), (1, 0, 0), l9, keep=Keep.BOTH)
|
||||
# self.assertEqual(len(l10.edges()), 2)
|
||||
# self.assertTrue(isinstance(l10, Edge))
|
||||
with self.assertRaises(ValueError):
|
||||
l10 = DoubleTangentArc((0, 0, 0), (1, 0, 0), l9, keep=Keep.BOTH)
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
DoubleTangentArc((0, 0, 0), (0, 0, 1), l9)
|
||||
|
|
@ -269,13 +271,17 @@ class BuildLineTests(unittest.TestCase):
|
|||
|
||||
with BuildLine():
|
||||
a4 = PolarLine((0, 0), 1, angle=30, length_mode=LengthMode.HORIZONTAL)
|
||||
d4 = PolarLine((0, 0), 1, direction=(sqrt(3), 1), length_mode=LengthMode.HORIZONTAL)
|
||||
d4 = PolarLine(
|
||||
(0, 0), 1, direction=(sqrt(3), 1), length_mode=LengthMode.HORIZONTAL
|
||||
)
|
||||
self.assertTupleAlmostEquals((a4 @ 1).to_tuple(), (1, 1 / sqrt(3), 0), 5)
|
||||
self.assertTupleAlmostEquals((a4 @ 1).to_tuple(), (d4 @ 1).to_tuple(), 5)
|
||||
|
||||
with BuildLine(Plane.XZ):
|
||||
a5 = PolarLine((0, 0), 1, angle=30, length_mode=LengthMode.VERTICAL)
|
||||
d5 = PolarLine((0, 0), 1, direction=(sqrt(3), 1), length_mode=LengthMode.VERTICAL)
|
||||
d5 = PolarLine(
|
||||
(0, 0), 1, direction=(sqrt(3), 1), length_mode=LengthMode.VERTICAL
|
||||
)
|
||||
self.assertTupleAlmostEquals((a5 @ 1).to_tuple(), (sqrt(3), 0, 1), 5)
|
||||
self.assertTupleAlmostEquals((a5 @ 1).to_tuple(), (d5 @ 1).to_tuple(), 5)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue