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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:27:51+00:00 2026-05-17T06:27:51+00:00

I am attempting to orbit an object around a center point, much like the

  • 0

I am attempting to orbit an object around a center point, much like the sun and our planets. However I am having no luck at all. Any help would be really great. Thanks. I’m writing in luna and I dont think there is a category for that here, but this probably is just general code. But if its in the wrong place, my apologies.

local function animate(event)

    local rads = degrees * (Math.PI / 180);
    ballOne.x = 20 * Math.cos(rad);
    ballOne.y = 20 * Math.sin(rad);
    degrees = degrees + 1

end

Runtime:addEventListener("enterFrame", animate)
  • 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-17T06:27:52+00:00Added an answer on May 17, 2026 at 6:27 am

    You might try 20.0 and 180.0 to force them to floating point, otherwise your calculations might end up being integer which won’t work well, otherwise everything seems fine.

    Also I suggest a unit test or two for this. If you pass in 0, 90, 180 and 260 you should get even numbers out (+/- 20,0 or 0,20). That will help you tweak it and let you believe in the results.

    — edit —
    Wrote a groovy version of your program because I don’t recognize a lot of your code. Found a problem with rad vs rads (mentioned in the comments). Here’s a groovy dump of your algorithm:

    float degrees=0.0
    float rads = degrees * (Math.PI / 180.0);
    float x = 20.0 * Math.cos(rads);
    float y = 20.0 * Math.sin(rads);
    degrees = degrees + 1
    println x
    println y
    

    This works. What I meant by unit test is that you can set up something that calls your method with “0.0” degrees and ensure that the output has x of 20.0 and y of 0.0, then call it with 90 and you should get 0,20 (Actually you may get a slight floating point error, just test to see that x is less than .001 or something)

    If you are using a google-approved framework to develop these apps I’m 100% sure there will be some “Official” way to do unit testing, I highly recommend you look into it, especially with a dynamic language unit tests can be absolutely critical.

    One of the most important parts of unit tests is that you can run them all with a single touch inside your development environment. This ensures that no matter what code you add, everything that used to work still works. It can give you confidence to go and refactor existing code without worrying about breaking something you didn’t even know interacted.

    Most people who work in dynamic languages consider unit tests an absolute requirement, and even in statically typed languages they are very important as your project grows beyond a trivial size.

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

Sidebar

Related Questions

Attempting to render a model object into a JSON structure via a partial, like
Attempting to decide on how to implement our RPC on the server side. From
Attempting to use a custom hex color for my css triangle (border). However since
Attempting to deserialize JSON data and update each object's prototype and inherit a common
Attempting to do TDD, I often need to execute all my tests - in
Attempting something like public string MyText { get {return lbl.Text;} set {lbl.Text = value;}}
Attempting to cutover our EF4 solution to EF CTP5, and ran into a problem.
Attempting to get LocationUpdates in my Service, however, it doesnt ever seem to fire
Attempting to set up jenkins and its container deploy plugin. However, I am receiving
Attempting to insert an escape character into a table results in a warning. For

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.