• 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
Re: Adding some polar coordinate capabilities to NSBezierPath.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding some polar coordinate capabilities to NSBezierPath.


  • Subject: Re: Adding some polar coordinate capabilities to NSBezierPath.
  • From: "John C. Randolph" <email@hidden>
  • Date: Thu, 18 Oct 2001 06:33:08 -0700

On Monday, October 15, 2001, at 06:11 AM, John C. Randolph wrote:

After attending a lecture by Dan Ingalls last week, I was somewhat intrigued by the classic turtle-graphics figures that the smalltalkers used to do for demos. The upshot is, I'm writing a category on NSBezierPath, like this:

@interface NSBezierPath (turtleGraphicsAdditions)

- (void) moveWithHeading:(float) angle distance:(float) distance;
- (void) lineWithHeading:(float) angle distance:(float) distance;

@end

..but I'm not entirely happy with these method names. I've considered making it

- (void) relativeMoveToRho:(float) rho theta:(float) theta;
- (void) relativeLineToRho:(float) rho theta:(float) theta;

where rho and theta are a polar offset from the path's current point, and adding

- (void) moveToRho:(float) rho theta:(float) theta;
- (void) lineToRho:(float) rho theta:(float) theta;

where rho and theta are a polar offset from the origin.

This code will end up in the MiscKit, so I thought I'd solicit the group's opinion. Should the naming lean more toward English, or Geometry?

BTW, after thinking about it a bit more, I realized that an NSPoint (since it consists of a pair of floats) was a perfectly good structure to store a polar coordinate.

What I finally did on this was:

NSPoint MiscConvertPolarToCartesian(NSPoint aPoint);
NSPoint MiscConvertCartesianToPolar(MiscPolar aPolar);

@interface NSBezierPath (MiscPolarAdditions)

- (void) polarMoveToPoint:(NSPoint) point;
- (void) polarRelativeMoveToPoint: (NSPoint) point;
- (void) polarLineToPoint:(NSPoint) point;
- (void) polarRelativeLineToPoint:(NSPoint) point;
- (void) polarAppendBezierPathWithPoints:(NSPointArray)points count:(int)count;

+ (void) polarStrokeLineFromPoint:(NSPoint)point1 toPoint:(NSPoint)point2;

@end

I didn't want to try the arc methods..

-jcr


  • Follow-Ups:
    • Re: Adding some polar coordinate capabilities to NSBezierPath.
      • From: Ondra Cada <email@hidden>
References: 
 >Adding some polar coordinate capabilities to NSBezierPath. (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: NSTextView and setFont - bug or feature?
  • Next by Date: Re: launchApplication (NSWorkSpace) : the icon is always displayed
  • Previous by thread: Re: Adding some polar coordinate capabilities to NSBezierPath.
  • Next by thread: Re: Adding some polar coordinate capabilities to NSBezierPath.
  • Index(es):
    • Date
    • Thread