Re: Wedgies anyone ?
Re: Wedgies anyone ?
- Subject: Re: Wedgies anyone ?
- From: "Ken Thomases" <email@hidden>
- Date: Mon, 17 Jun 2002 17:18:17 -0500
- Priority: normal
On 17 Jun 2002, at 9:59, Robert Miller wrote:
>
Hi,
>
>
Thanks for taking the time to look at this but, what you were
>
looking at was my last iteration
>
of trying to figure out what's going on. As you suggested I started with
>
cos(x) sin(y) but that only
>
produces one single line from the center to the perimeter (startPt) as
>
well. It's as if the arc is not being drawn or begin drawn
>
in an unexpected location. The odd thing is the if I do:
>
>
[path moveToPoint:pieCenter];
>
[path lineToPoint:startPt];
>
>
//[path appendBezierPathWithArcFromPoint:startPt
>
toPoint:endPt radius:pieRadius];
>
[path moveToPoint:pieCenter];
>
[path lineToPoint:endPt];
>
>
I get two lines from the center to the perimeter at the correct end
>
points .! That's the mystery, I'm guessing that
>
there is something I don't understand about how
>
'appendBezierPathWithArcFromPoint' works. ???
>
>
Regards,
>
Bob M.
>
>
On Sunday, June 16, 2002, at 11:51 AM, Thomas Deniau wrote:
>
>
> Le 16/06/02 17:34, Robert Miller disait :
>
>
>
>> startPt = NSMakePoint(pieCenter.x + pieRadius * sin(startAngle),
>
>> pieCenter.y + pieRadius * cos(startAngle));
>
>> endPt = NSMakePoint(pieCenter.x + pieRadius * sin(endAngle),
>
>> pieCenter.y + pieRadius * cos(endAngle));
>
>
>
> Erm, maybe I'm totally wrong, but I think that sin gives the 'y'
>
> coordinate.
>
> So IMHO you should do
>
>
>
> startPt = NSMakePoint(pieCenter.x + pieRadius * cos(startAngle),
>
> pieCenter.y + pieRadius * sin(startAngle));
>
> endPt = NSMakePoint(pieCenter.x + pieRadius * cos(endAngle),
>
> pieCenter.y + pieRadius * sin(endAngle));
>
>
>
> Then I would delete the following lines and directly do
>
>
>
> path = [NSBezierPath bezierPath];
>
> [path moveToPoint:pieCenter];
>
> [path lineToPoint:startPt];
>
> [path appendBezierPathWithArcFromPoint:startPt toPoint:endPt
>
> radius:pieRadius];
>
> [path lineToPoint:pieCenter];
>
>
>
>
>
> But maybe that's not you want to do.
>
>
>
>
>
> --
>
> Thomas Deniau
I'm _really_ out of my depth in terms of Cocoa, so I'm just guessing
here:
If you look at the parameters for
appendBezierPathWithArcFromPoint:toPoint:radius: they don't provide
enough information to disambiguate the two possible arcs. (If you
include the long-way-around arcs, there are four possible arc.) So,
it probably uses certain conventions to disambiguate. For example,
"assume we're going short-way around, counterclockwise from fromPoint
to toPoint". Or, in other words, "as we walk an imaginary line from
fromPoint to toPoint, the arc will be on our right". (I guessed
counterclockwise/on-the-right because that's what you get from
appendBezierPathWithArcWithCenter:radius:startAngle:endAngle:; if you
want clockwise they make you specify that explicitly.) Your tests
may indicate that the actual conventions are different than my
examples.
So, if you reverse your startPoint and endPoint, do you get the arc
you wanted?
By the way, my reading of the docs for
appendBezierPathWithArcFromPoint:toPoint:radius: indicates that it
will draw the line from center to the fromPoint for you. Also, much
of the math in your original message looked like duplication of the
functionality of
appendBezierPathWithArcWithCenter:radius:startAngle:endAngle:, which
also doesn't suffer from the ambiguity that's plaguing you. Is there
a reason you aren't using that?
Ken
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.