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

  • Home
  • SEARCH
  • 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 8767827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:54:57+00:00 2026-06-13T16:54:57+00:00

I have a point moving with the speed V(vectorX, vectorY). Initially V = (1,

  • 0

I have a point moving with the speed V(vectorX, vectorY). Initially V = (1, 0).
I repeatedly rotate it by random angle using:

vectorX = vectorX * Math.cos(radianAngle) – vectorY * Math.sin(radianAngle);
vectorY = vectorX * Math.sin(radianAngle) + vectorY * Math.cos(radianAngle);

Rotation should not adjust vector length. But this solution decreases my vector length overtime:

0.9999999164020167
0.9989817245134542
0.9990928546670482
0.9990920078686215
0.9990307271300217
0.9990123195664165
0.9990122314933966
0.9958140526821458
0.9953881407397223
0.9953002497794944
0.9953739080312035
0.9953762669739241
0.9951229086200286
0.9951022010798389
0.9950609497602859
0.9950608230271147
0.9948941861659032
0.9949385678072231

I know that sin and cos functions give approximated results. But why exactly I get decreasing length? And how it can be solved?

  • 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-13T16:54:58+00:00Added an answer on June 13, 2026 at 4:54 pm

    Welcome to the world of non-exact floating-point arithmetic. You lose precision. That’s a fact of life.

    You should probably rotate the initial fixed vector by an increasing angle instead.

    I.e.:

    angle = angle + radianAngle;
    vectorX = initialVectorX * Math.cos(angle) - initialVectorY * Math.sin(angle);
    vectorY = initialVectorX * Math.sin(angle) + initialVectorY * Math.cos(angle);
    

    This way you won’t accumulate precision loss.

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

Sidebar

Related Questions

I have a point in a rectangle that I need to rotate an arbitrary
I'm making an animation in Processing. I have some random points moving randomly and
I'm working on moving some Photoshop comps into code and have reached a point
I have a list of points moving in two dimensions ( x - and
I need to use IBM Informix for my project where I have point coordinates
I have a point, and a point normal defined to it. Suppose I also
i have bug that i cannot find, i have Class Point with method who
I'm pretty confused. I have a point: x= -12669114.702301 y= 5561132.6760608 That I got
I have played many Point and Click adventure game (Broken Sword, Sam & Max,
I have a floating point value X which is animated. When in rest it's

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.