Hi Graham,

On 09/07/2008, at 4:37 PM, Graham Cox wrote:

On 9 Jul 2008, at 4:02 pm, Chris Suter wrote:

so you can get a worst case bounds by ignoring the mitre limit.

No you can't. If the stroke width is 'w' then you can outset the bounds by w/2 to enclose the path for straight edges and angles >= 90 degrees. When there is a more acute angle though the resulting spike quickly extends beyond this bounds up to the miter limit, at which point it becomes a bevel join and falls within the bounds again. Thus to calculate the bounds that will include all such spikes, you do need to factor in the miter limit.

You could ignore the mitre limit and assume it was always mitre joint and it would give you a worst case bounds. However, it wouldn't be sensible to do that since the bounds would stretch out excessively for very acute angles. It's for this reason that I was wrong to suggest it.

Thanks to this page I now understand what the miter limit is:

http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Attributes-Stroke.html

I suggest you have a look at the PDF specification since that's the definitive reference for this stuff.

It's the distance 'm' along the widest part of the corner. This is the hypotenuse of a right-triangle whose other sides are the edge of the path and the normal to the path, which has the known width 'w'. Thus the angle 'a' of the corner is equal to 2*sin(w/m), or m = 2w/ sin(a).

I think you mean a = 2 * arcsin(w / m) and m = w / sin(a / 2).

But it's not necessary to worry about the angle itself for a worst case calculation, since only the value of m matters - it can never exceed the programmed miter limit. Thus the path bounds is simply outset by (miter limit * w/2) to ensure it is just beyond the tip of any possible spike.

You will need to also take into account of the line width (as I'm sure you do) so I think the combined offset would be best expressed as:

        max(w / 2, ml * w / 2)

where ml is the mitre limit.

-- Chris

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to