Tangents

A line or an arc can be given what it touches instead of where it ends. tangent= names the circle, arc or spline, and planex2d computes the touch point, so no point of a tangent has to be worked out by hand. With two targets, as in tangent=("a", "b"), a line touches both.

[1]:
import math
import planex as px

From a point, along a circle, to a spline

A tangent can start at a point, leave a circle, or touch a spline (Figure 2).

  • From a point, tangent="circle" draws one of the two tangents to the circle, and reverse=True the other (a).

  • From a point on a circle, Line(3, tangent="c") leaves the circle along its tangent there, 3 long (b).

  • From a point outside a spline, tangent="curve" touches the spline (c).

Where a line could touch a target at several points, a point given with the target, as in tangent=("curve", p), selects the touch point nearest to p.

[6]:
point = px.QuickSketch().Circle(5, 0, 1.5, id="circle", construction=True)
point.Move((0, 0)).Line(tangent="circle")
point.Move((0, 0)).Line(tangent="circle", reverse=True)

leaving = px.QuickSketch().Circle(0, 0, 1, id="c")
leaving.Move((0, 1)).Line(3, tangent="c")

spline = px.QuickSketch((0, 2)).Spline([(1, 1), (2, 0.8), (3, 1.2), (4, 2)], id="curve")
spline.Move((2, -1)).Line(tangent="curve");
From a point
(a) From a point
Leaving a circle
(b) Leaving a circle
Touching a spline
(c) Touching a spline
Figure 2: Tangents from a point, along a circle and to a spline

An arc can be tangent too. See Arcs from references for arcs that touch two edges, and Choosing between solutions for picking one of several tangents.