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 6551425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:20:13+00:00 2026-05-25T12:20:13+00:00

Let me just start with the code. – (NSPoint*) pointFromPoint:(NSPoint*)point withDistance:(float)distance towardAngle:(float)angle; { float

  • 0

Let me just start with the code.

- (NSPoint*) pointFromPoint:(NSPoint*)point withDistance:(float)distance towardAngle:(float)angle; {
    float newX = distance * cos(angle);
    float newY = distance * sin(angle);

    NSPoint * anNSPoint;
    anNSPoint.x = newX;
    anNSPoint.y = newY;

    return thePoint;
}

This should, based on my knowledge, be perfect. It should return and x value of 0 and a y value of 2 if I call this code.

somePoint = [NSPoint pointFromPoint:somePoint withDistance:2 towardAngle:90];

Instead, I get and x value of 1.05 and a y of 1.70. How can I find the x and y coordinates based on an angle and a distance?

Additional note: I have looked on math.stackexchange.com, but the formulas there led me to this. I need the code, not the normal math because I know I will probably screw this up.

  • 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-05-25T12:20:14+00:00Added an answer on May 25, 2026 at 12:20 pm

    A working version of your function, which accepts values in degrees instead of radians, would look like this:

    - (NSPoint)pointFromPoint:(NSPoint)origin withDistance:(float)distance towardAngle:(float)angle
    {
        double radAngle = angle * M_PI / 180.0;
        return NSMakePoint(origin.x + distance * cos(radAngle), point.y + distance * sin(radAngle));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is best illustrated with a code sample, so let's just start off
Before I start with the real question, let me just say that I might
Let me just start out by saying I am completely new to Java web
Let me just preface by saying it's actually my crappy code that's leaking and
Let me start off by saying I had one DLL loading in just fine.
Let me start from a real life example: Customer: Alex, just noticed something strange
So I have an object graph, let's just say it's an order. You have
Let's say I want a way to display just the the center 50x50px of
Let's say: <div> pre text <div class=remove-just-this> <p>child foo</p> <p>child bar</p> nested text </div>
I'd like to just create a thread, then call CloseHandle immediately and let the

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.