Merge pull request #947 from jwagenet/tangent-objects

Add Tangent objects for Point and Arc
This commit is contained in:
Roger Maitland 2025-04-16 09:36:12 -04:00 committed by GitHub
commit b03fa9a7fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 959 additions and 15 deletions

View file

@ -1,13 +1,13 @@
<?xml version='1.0' encoding='utf-8'?>
<svg width="40.09mm" height="101.09mm" viewBox="-0.01125 -25.01125 10.0225 25.2725" version="1.1" xmlns="http://www.w3.org/2000/svg">
<svg width="100.089998mm" height="102.589998mm" viewBox="-0.0045 -10.0045 10.009 10.259" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g transform="scale(1,-1)" stroke-linecap="round">
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.0225">
<path d="M 6.0,0.0 A 47.000000000000085,47.000000000000085 180.0 0,0 9.615385,18.076923" />
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.00900000018">
<path d="M 6.0,0.0 A 11.022002852739636,11.022002852739636 0.0 0,1 1.242,9.069003" />
<circle cx="6.0" cy="0.0" r="0.25" />
</g>
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.0225" id="dashed" stroke-dasharray="0.27 0.405">
<path d="M 0.0,20.0 A 5.0,5.0 180.0 1,0 2.5,15.669873" />
<line x1="6.0" y1="0.0" x2="6.0" y2="5.0" />
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.00900000018" id="dashed" stroke-dasharray="0.108 0.162">
<path d="M 0.0,10.0 C 2.605146,7.884615 8.294029,4.391384 10.0,10.0" />
<line x1="6.0" y1="0.0" x2="6.0" y2="1.0" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 708 B

Before After
Before After

View file

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<svg width="100.09mm" height="100.09mm" viewBox="-0.0045 -10.0045 10.009 10.009" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g transform="scale(1,-1)" stroke-linecap="round">
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.008999999999999998">
<path d="M 0.098274,9.997584 A 12.0,12.0 87.18351331597553 0,0 9.497124,4.66264" />
</g>
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.008999999999999998" id="dashed" stroke-dasharray="0.108 0.162">
<circle cx="7.0" cy="3.0" r="3.0" />
<path d="M -0.0,6.0 A 2.0,2.0 0.0 0,1 0.0,10.0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 639 B

View file

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<svg width="100.09mm" height="100.09mm" viewBox="-0.0045 -10.0045 10.009 10.009" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g transform="scale(1,-1)" stroke-linecap="round">
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.009">
<line x1="8.448109" y1="5.627352" x2="0.965406" y2="9.751568" />
</g>
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.009" id="dashed" stroke-dasharray="0.108 0.162">
<circle cx="7.0" cy="3.0" r="3.0" />
<path d="M -0.0,6.0 A 2.0,2.0 0.0 0,1 0.0,10.0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 590 B

View file

@ -0,0 +1,13 @@
<?xml version='1.0' encoding='utf-8'?>
<svg width="102.59mm" height="100.09mm" viewBox="-0.0045 -10.0045 10.259 10.009" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g transform="scale(1,-1)" stroke-linecap="round">
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.009000000000000001">
<path d="M 10.0,3.0 A 10.575383789062535,10.575383789062535 -108.43494882292202 0,0 4.283756,7.578649" />
<circle cx="10.0" cy="3.0" r="0.25" />
</g>
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.009000000000000001" id="dashed" stroke-dasharray="0.108 0.162">
<path d="M -0.0,0.0 A 5.0,5.0 0.0 0,1 0.0,10.0" />
<line x1="10.0" y1="3.0" x2="9.051317" y2="3.316228" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 725 B

View file

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<svg width="102.59mm" height="100.09mm" viewBox="-0.0045 -10.0045 10.259 10.009" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g transform="scale(1,-1)" stroke-linecap="round">
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.009000000000000001">
<line x1="10.0" y1="3.0" x2="3.25848" y2="8.792401" />
<circle cx="10.0" cy="3.0" r="0.25" />
</g>
<g fill="none" stroke="rgb(0,0,0)" stroke-width="0.009000000000000001" id="dashed" stroke-dasharray="0.108 0.162">
<path d="M -0.0,0.0 A 5.0,5.0 0.0 0,1 0.0,10.0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 612 B

View file

@ -188,6 +188,33 @@ The following objects all can be used in BuildLine contexts. Note that
+++
Curve define by three points
.. grid-item-card:: :class:`~objects_curve.ArcArcTangentLine`
.. image:: assets/example_arc_arc_tangent_line.svg
+++
Line tangent defined by two arcs
.. grid-item-card:: :class:`~objects_curve.ArcArcTangentArc`
.. image:: assets/example_arc_arc_tangent_arc.svg
+++
Arc tangent defined by two arcs
.. grid-item-card:: :class:`~objects_curve.PointArcTangentLine`
.. image:: assets/example_point_arc_tangent_line.svg
+++
Line tangent defined by a point and arc
.. grid-item-card:: :class:`~objects_curve.PointArcTangentArc`
.. image:: assets/example_point_arc_tangent_arc.svg
+++
Arc tangent defined by a point, direction, and arc
Reference
^^^^^^^^^
@ -210,6 +237,10 @@ Reference
.. autoclass:: Spline
.. autoclass:: TangentArc
.. autoclass:: ThreePointArc
.. autoclass:: ArcArcTangentLine
.. autoclass:: ArcArcTangentArc
.. autoclass:: PointArcTangentLine
.. autoclass:: PointArcTangentArc
2D Objects
----------

View file

@ -176,7 +176,6 @@ svg.write("assets/polyline_example.svg")
with BuildLine(Plane.YZ) as filletpolyline:
FilletPolyline((0, 0, 0), (0, 10, 2), (0, 10, 10), (5, 20, 10), radius=2)
show(filletpolyline)
scene = Compound(filletpolyline.line) + Compound.make_triad(2)
visible, _hidden = scene.project_to_viewport((0, 0, 1), (0, 1, 0))
s = 100 / max(*Compound(children=visible).bounding_box().size)
@ -248,17 +247,71 @@ svg.add_shape(dot.moved(Location(Vector((1, 0)))))
svg.write("assets/intersecting_line_example.svg")
with BuildLine() as double_tangent:
l2 = JernArc(start=(0, 20), tangent=(0, 1), radius=5, arc_size=-300)
l3 = DoubleTangentArc((6, 0), tangent=(0, 1), other=l2)
p1 = (6, 0)
d1 = (0, 1)
l2 = Spline((0, 10), (3, 8), (7, 7), (10, 10))
show_object([p1, l2])
l3 = DoubleTangentArc(p1, tangent=d1, other=l2)
s = 100 / max(*double_tangent.line.bounding_box().size)
svg = ExportSVG(scale=s)
svg.add_layer("dashed", line_type=LineType.ISO_DASH_SPACE)
svg.add_shape(l2, "dashed")
svg.add_shape(l3)
svg.add_shape(dot.scale(5).moved(Pos(6, 0)))
svg.add_shape(Edge.make_line((6, 0), (6, 5)), "dashed")
svg.add_shape(dot.scale(5).moved(Pos(p1)))
svg.add_shape(PolarLine(p1, 1, direction=d1), "dashed")
svg.write("assets/double_tangent_line_example.svg")
with BuildLine() as point_arc_tangent_line:
p1 = (10, 3)
l1 = CenterArc((0, 5), 5, -90, 180)
l2 = PointArcTangentLine(p1, l1, Side.RIGHT)
s = 100 / max(*point_arc_tangent_line.line.bounding_box().size)
svg = ExportSVG(scale=s)
svg.add_layer("dashed", line_type=LineType.ISO_DASH_SPACE)
svg.add_shape(l1, "dashed")
svg.add_shape(l2)
svg.add_shape(dot.scale(5).moved(Pos(p1)))
svg.write("assets/example_point_arc_tangent_line.svg")
with BuildLine() as point_arc_tangent_arc:
p1 = (10, 3)
d1 = (-3, 1)
l1 = CenterArc((0, 5), 5, -90, 180)
l2 = PointArcTangentArc(p1, d1, l1, Side.RIGHT)
s = 100 / max(*point_arc_tangent_arc.line.bounding_box().size)
svg = ExportSVG(scale=s)
svg.add_layer("dashed", line_type=LineType.ISO_DASH_SPACE)
svg.add_shape(l1, "dashed")
svg.add_shape(l2)
svg.add_shape(dot.scale(5).moved(Pos(p1)))
svg.add_shape(PolarLine(p1, 1, direction=d1), "dashed")
svg.write("assets/example_point_arc_tangent_arc.svg")
with BuildLine() as arc_arc_tangent_line:
l1 = CenterArc((7, 3), 3, 0, 360)
l2 = CenterArc((0, 8), 2, -90, 180)
l3 = ArcArcTangentLine(l1, l2, Side.RIGHT, Keep.OUTSIDE)
s = 100 / max(*arc_arc_tangent_line.line.bounding_box().size)
svg = ExportSVG(scale=s)
svg.add_layer("dashed", line_type=LineType.ISO_DASH_SPACE)
svg.add_shape(l1, "dashed")
svg.add_shape(l2, "dashed")
svg.add_shape(l3)
svg.write("assets/example_arc_arc_tangent_line.svg")
with BuildLine() as arc_arc_tangent_arc:
l1 = CenterArc((7, 3), 3, 0, 360)
l2 = CenterArc((0, 8), 2, -90, 180)
radius = 12
l3 = ArcArcTangentArc(l1, l2, radius, Side.LEFT, Keep.OUTSIDE)
s = 100 / max(*arc_arc_tangent_arc.line.bounding_box().size)
svg = ExportSVG(scale=s)
svg.add_layer("dashed", line_type=LineType.ISO_DASH_SPACE)
svg.add_shape(l1, "dashed")
svg.add_shape(l2, "dashed")
svg.add_shape(l3)
svg.write("assets/example_arc_arc_tangent_arc.svg")
# show_object(example_1.line, name="Ex. 1")
# show_object(example_2.line, name="Ex. 2")
# show_object(example_3.line, name="Ex. 3")