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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:47:54+00:00 2026-05-11T11:47:54+00:00

I imagine that this is a simple question, but I’m getting some strange results

  • 0

I imagine that this is a simple question, but I’m getting some strange results with my current code and I don’t have the math background to fully understand why. My goal is simple, as stated in the title: I just want to find the point at some distance and angle from a center point.

My current code:

Point centerPoint = new Point ( 0, 0 ); Point result      = new Point ( 0, 0 ); double angle      = 0.5; //between 0 and 2 * PI, angle is in radians int distance      = 1000;  result.Y = centerPoint.Y + (int)Math.Round( distance * Math.Sin( angle ) ); result.X = centerPoint.X + (int)Math.Round( distance * Math.Cos( angle ) ); 

In general, this seems to work fairly reasonably, but I get problems at various spots, most notably when the angle corresponds to points in the negative x and y axis. Clearly I’m doing something wrong — thoughts on what that is?

UPDATE: This was my mistake, this code works fine — the few outliers that were not working were actually due to a bug in how the angle for 1.5PI was being calculated. I thought I had checked that well enough, but evidently had not. Thanks to everyone for their time, hopefully the working code above will prove helpful to someone else.

  • 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. 2026-05-11T11:47:55+00:00Added an answer on May 11, 2026 at 11:47 am

    You forgot to add the center point:

    result.Y = (int)Math.Round( centerPoint.Y + distance * Math.Sin( angle ) ); result.X = (int)Math.Round( centerPoint.X + distance * Math.Cos( angle ) ); 

    The rest should be ok… (what strange results were you getting? Can you give an exact input?)

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

Sidebar

Related Questions

I think this is a simple question. Imagine you have a page that initializes
I imagine this is not a very specific programming question. But have you tried
I have rather simple, I imagine, question about CRTP , but I cannot seem
i need a timer that works like this : imagine somebody have a limit
Googling this does little good, as you can imagine. Does anyone have resources that
Imagine that i have the following code: <a:repeat value=#{bean.getList()} var=x > <li class=la> <span>
Hey this may be a somewhat simple question, but I'm new to Eclipse and
Simple (I hope), HTML question. Let's say I have a column group that spans
I have this simple piece of code in jQuery $(document).ready(function() { $('#switcher').click(function(event) { if
Apologies if this is a stupid/easy question, but still getting used to everything in

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.