Re: NSPoint Documentation
Re: NSPoint Documentation
- Subject: Re: NSPoint Documentation
- From: "John C. Randolph" <email@hidden>
- Date: Fri, 22 Mar 2002 13:13:22 -0800
On Friday, March 22, 2002, at 12:16 PM, Jim Correia wrote:
On Friday, March 22, 2002, at 02:47 PM, Finlay Dobbie wrote:
On Friday, March 22, 2002, at 07:26 PM, Daniel Stark wrote:
afloatvalue = [NSpoint1 distanceToPoint:NSpoint2];
And it couldn't find this method. Is this implemented in
objective C? Why can't I find the docs or headers for NSpoint?
Of course if it doesn'
t exist I can do it myself, I just thought that it would be
built in as it is in Java.
NSPoint isn't implemented as an Obj-C object: it's just a
struct. Docs on the funtions to manipulate them are here:
http://developer.apple.com/techpubs/macosx/Cocoa/Reference/Foundation/ObjC_classic/
Functions/FoundationFunctions.html#BCIFGGCH
though I can't see a function comparable to distanceToPoint.
If you know a guy named Pythagoras, writing one is straight
forward though.
Come to think of it, I've had this sitting around for quite a while..
float
distance(NSPoint a, NSPoint b)
{
float
dX = a.x - b.x,
dY = a.y - b.y;
return sqrt(dX*dX + dY*dY);
}
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
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.