[whatwg] Canvas arcTo

Which straight line do you mean?

In the first case, the constraints are:

* There is a circle with the given radius.
* The infinite line P0-P1 is tangential to that circle.
* The infinite line P1-P2 is tangential to that circle.
* The Arc is the shortest arc of that circle, between the points where
the circle touches the two lines.

When P0-P1-P2 is a straight line, there is a circle (among many
others) which satisfies the first three constraints, and there is a
zero-length arc of that circle which satisfies the fourth constraint.
(You can't then re-calculate the circle's radius from the arc, because
the arc is just a single point, but I don't think that means the arc
doesn't exist as part of a finite circle). That's not very useful when
you want to draw stuff since there are infinitely many distinct things
you could draw, but it's not the case that there's nothing you could
draw.


In the second case, there is one distinct circle (with zero radius)
which touches both the lines, and there is one distinct point which
the start and end tangent points must be equal to, and the shortest
arc which joins those two points has zero length. There's still
infinitely many such arcs and it gets a bit confusing if you want to
work out its direction (in order to draw line joins and caps), but
you'd always be drawing at least a line from P0 to P1.

(To handle that confusion about the zero-sized arc, I think my earlier
suggestion should be modified to say "... Otherwise, if x1=x2 and
y1=y2, or if the line defined by the points (x0, y0) and (x1, y1) is
parallel and in the same direction as the line defined by the points
(x1, y1) and (x2, y2), ** or if radius is zero, ** then the method
must connect the point (x0, y0) to the point (x1, y1) by a straight
line and add the point (x1, y1) to the subpath. ...")


Actually, I just realised there's still a problem in the normal
non-parallel non-zero-size case, because there are four different
circles which have the two infinite lines as tangents. (And you have
to use infinite lines rather than finite lines, to handle the second
case in http://canvex.lazyilluminati.com/misc/arcto.html like Safari).
So I think it would have to say something like:

"""
Otherwise, let L01 be the line through the points (x0, y0) and (x1,
y1), and let L12 be the line through the points (x1, y1) and (x2, y2).
Consider the circle that has L01 and L12 as tangents, and has its
origin and the point (x2, y2) on the same side of L01, and has its
origin and the point (x0, y0) on the same side of L12, and has radius
radius. The points at which this circle touches these two lines are
called the start and end tangent points respectively. Let The Arc be
the shortest arc given by the circumference of this circle, joining
the start and end tangent points.
"""

unless I got anything else wrong.

On 03/07/07, Kristof Zelechovski <giecrilj at stegny.2a.pl> wrote:
> The questioned wording is correct: a straight line has infinite radius and
> thus does not match the requirement if the radius is finite.
> Chris
>
> -----Original Message-----
> From: whatwg-bounces at lists.whatwg.org
> [mailto:whatwg-bounces at lists.whatwg.org] On Behalf Of Philip Taylor
> Sent: Monday, July 02, 2007 1:42 PM
> To: WHATWG
> Subject: [whatwg] Canvas arcTo
>
> "If the point (x2, y2) is on the line defined by the points (x0, y0)
> and (x1, y1) then the method must do nothing, as no arc would satisfy
> the above constraints." - why would no arc satisfy the constraints? If
> P0, P1, P2 are collinear and non-coincident, then (I think) any of the
> (infinitely many) circles which have the given radius and touch
> tangential to the line P0->P2 will satisfy the constraints (i.e. being
> tangential to P0->P1 at some point and to P1->P2 at some point).
>
> [snip]
>
> "Negative or zero values for radius must cause the implementation to
> raise an INDEX_SIZE_ERR exception." - why not allow zero? You just get
> an arc at P1 with zero length, with the start and end tangent points
> both at P1, so the effect would be a straight line from P0 to P1,
> without needing to handle it as a special case. Safari works like
> that.
>

-- 
Philip Taylor
excors at gmail.com

Received on Tuesday, 3 July 2007 06:03:58 UTC