• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Wedgies anyone ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wedgies anyone ?


  • Subject: Wedgies anyone ?
  • From: Robert Miller <email@hidden>
  • Date: Sun, 16 Jun 2002 11:34:36 -0400

Hello,

Help please. I'm having trouble drawing a wedge (or a piece of pie if you will) using NSBezierPath, this is probably a basic trig thingy and I just haven't hit on it. I have a circle with radius 'R' so I move to the center point of the circle. I calculate the starting point on the circle like so... here's a code snippet....

// arc slice is the percentage of the total of the circle in radians
arcSlice = (num / chartTotal) * piTimes2;

startAngle = arcSum + 1 / pieRadius;
endAngle = (arcSum + arcSlice) + 1 / pieRadius;

startPt = NSMakePoint(pieCenter.x + pieRadius * sin(startAngle), pieCenter.y + pieRadius * cos(startAngle));
endPt = NSMakePoint(pieCenter.x + pieRadius * sin(endAngle), pieCenter.y + pieRadius * cos(endAngle));

arcStartPt = NSMakePoint(pieCenter.x + sin(startAngle), pieCenter.y + cos(startAngle));
arcEndPt = NSMakePoint(pieCenter.x + sin(endAngle), pieCenter.y + cos(endAngle));

path = [NSBezierPath bezierPath];
[path moveToPoint:pieCenter];
[path lineToPoint:startPt];
[path appendBezierPathWithArcFromPoint:arcStartPt toPoint:arcEndPt radius:pieRadius];
[path lineToPoint:pieCenter];

and the arc ends up concave to the points not convex ? If I use lines from center to startPt to endPt and back to center again I get a nice triangle where it should be so I know that the arc points are correct. I tired a few different calculations using separate points for the arc thinking it might be that I already supply a radius so it doesn't need to be included in the point calculation but that doesn't help. Am I doing something wrong ? Obviously huh ...

Any help is greatly appreciated
Regards,
Bob M.
_______________________________________________
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.

  • Prev by Date: Re: Protecting Software w/ Software License Keys...
  • Next by Date: Re: Drag 'n Drop 'n Delegation Dilemma
  • Previous by thread: Re: NSTextView problems
  • Next by thread: Re: Wedgies anyone ?
  • Index(es):
    • Date
    • Thread