Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8240285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:26:16+00:00 2026-06-07T20:26:16+00:00

NSPoint is a C-struct used in Cocoa to represent a point in the plane.

  • 0

NSPoint is a C-struct used in Cocoa to represent a point in the plane.

How do you translate, rotate, and do other geometric operations on NSPoint in an Objective-C style ?

So far, I’m using C functions to make these calculations, but in my opinion it doesn’t look good with the rest of the code.

-(NSPoint) rotateAroundNSPoint: (NSPoint)origin  pointToRotate:(NSPoint)point andDegreesAngle:(float)angleD;
NSPoint rotateAround(NSPoint origin, NSPoint initialPos, float angleDegrees)


/* C-style function */
NSPoint pointD = rotateAround(point000, point001, 72*9);
/* Objective-C method */
NSPoint pointE = [self rotateAroundNSPoint:point000 pointToRotate:point001 andDegreesAngle:72*12];

Are there other alternatives ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:26:19+00:00Added an answer on June 7, 2026 at 8:26 pm

    Cocoa defines macros pointing to functions like this so you could do that to keep a consistent style

    e.g.

    #define NSPointRotateAround(origin, initialPos, angleDegrees) rotateAround(origin, initialPos, angleDegrees)
    

    it would still be calling the same code, just looks a bit neater. You could also move the geometric functions into a common file as well, there is no need for them to be associated with a class

    note: I just looked and cocoa actually uses inline functions so you could do that as well (the calling code looks the same either way)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning Objective-C and Cocoa (in fits and starts when time allows) so be
So I have this struct composed of three NSPoint structures. typedef struct AOTriangle_ {
Let me just start with the code. - (NSPoint*) pointFromPoint:(NSPoint*)point withDistance:(float)distance towardAngle:(float)angle; { float
I'm trying to learn Objective C & Cocoa, but I just can't manage to
I'm trying to create a Cocoa Window within an otherwise Carbon Application (it's an
Is there an appropriate structure provided in the Apple foundation kits to represent discrete
I'm looking for an explanation of NSWindow's dragImage method. - (void)dragImage:(NSImage *)image at:(NSPoint)imageLocation offset:(NSSize)pointerOffset
I have this managedObject subclass, position rappresent a NSPoint. In a XIB I want
In a Cocoa-based App i'm having a canvas for drawing, inherited from NSView, as
I'm relatively new to Cocoa/ObjC. Could someone please help me change my code to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.