Re: NSPoint Documentation
Re: NSPoint Documentation
- Subject: Re: NSPoint Documentation
- From: David Remahl <email@hidden>
- Date: Fri, 22 Mar 2002 21:22:01 +0100
>
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_cla
>
ssic/
>
Functions/FoundationFunctions.html#BCIFGGCH
>
>
though I can't see a function comparable to distanceToPoint.
>
>
-- Finlay
We could help out people looking through this thread in the future, by
giving a simple function to calculate the distance between the points...Just
in case the person in need doesn't like geometry :)
float DRDistanceBetweenPoints(NSPoint pt1, NSPoint pt2)
{
float ptxd = pt1.x - pt2.x;
float ptyd = pt1.y - pt2.y;
return sqrtf( ptxd*ptxd + ptyd*ptyd );
}
Not tested...
/ david
_______________________________________________
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.