FROM : Serge Meynard
DATE : Mon Apr 11 18:41:44 2005
On Apr 11, 2005, at 11:48, Nicko van Someren wrote:
>> But there's a simple error in your code. Here currPoint and nextPoint
>> are the second and third points forming the current corner; drawing
>> an arc between them won't produce what you want. The radius
>> calculation you're making is probably fine, but the two points you
>> provide to the arc method must lie on the circle, and you want them
>> to be at 90 degrees from each other. What you need for your arc
>> points is a set of points at distance "radius" from currPoint; the
>> first interpolated between currPoint and [path currentPoint], and the
>> second interpolated between currPoint and nextPoint.
>
> Not so. The documentation for
> appendBezierPathWithArcFromPoint:toPoint:radius: says:
>
> "The arc lies on the perimeter of a circle with radius radius
> inscribed in an angle defined by the current point, fromPoint, and
> toPoint. The arc is drawn between the tangent points of the circle
> with the two legs of the angle. The arc usually does not contain the
> points fromPoint and toPoint..."
>
> So what is happening is that you draw a pair of straight lines first
> from the current end of the path to the "from" point and then from
> there to the "to" point and then you tuck into the bend a circle of
> the given radius. Your arc is the section of the circle between the
> two tangent points. This means that if you are drawing curves around
> right-angle bends then you want the "from" point to be the corner that
> you would have gone to if you were drawing a proper 90 corner and the
> "to" point to be somewhere along the straight line around the corner.
> As was noted elsewhere, a straight line segment is drawn from the
> current end of the path to the tangent point where the arc starts but
> there is not extension line to join the other end of the arc to the
> "to" point.
>
> Nicko
You're right, I guess I misunderstood the doc about how that method
works... Reading it again it makes more sense now, and is actually
easier to use (fewer calculations needed). Maybe you can try to spot
the error in his code? I've put my foot in my mouth twice in this
thread, maybe I should quit while I'm ahead :)
DATE : Mon Apr 11 18:41:44 2005
On Apr 11, 2005, at 11:48, Nicko van Someren wrote:
>> But there's a simple error in your code. Here currPoint and nextPoint
>> are the second and third points forming the current corner; drawing
>> an arc between them won't produce what you want. The radius
>> calculation you're making is probably fine, but the two points you
>> provide to the arc method must lie on the circle, and you want them
>> to be at 90 degrees from each other. What you need for your arc
>> points is a set of points at distance "radius" from currPoint; the
>> first interpolated between currPoint and [path currentPoint], and the
>> second interpolated between currPoint and nextPoint.
>
> Not so. The documentation for
> appendBezierPathWithArcFromPoint:toPoint:radius: says:
>
> "The arc lies on the perimeter of a circle with radius radius
> inscribed in an angle defined by the current point, fromPoint, and
> toPoint. The arc is drawn between the tangent points of the circle
> with the two legs of the angle. The arc usually does not contain the
> points fromPoint and toPoint..."
>
> So what is happening is that you draw a pair of straight lines first
> from the current end of the path to the "from" point and then from
> there to the "to" point and then you tuck into the bend a circle of
> the given radius. Your arc is the section of the circle between the
> two tangent points. This means that if you are drawing curves around
> right-angle bends then you want the "from" point to be the corner that
> you would have gone to if you were drawing a proper 90 corner and the
> "to" point to be somewhere along the straight line around the corner.
> As was noted elsewhere, a straight line segment is drawn from the
> current end of the path to the tangent point where the arc starts but
> there is not extension line to join the other end of the arc to the
> "to" point.
>
> Nicko
You're right, I guess I misunderstood the doc about how that method
works... Reading it again it makes more sense now, and is actually
easier to use (fewer calculations needed). Maybe you can try to spot
the error in his code? I've put my foot in my mouth twice in this
thread, maybe I should quit while I'm ahead :)






Cocoa mail archive

