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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:13:02+00:00 2026-06-10T12:13:02+00:00

This is more of a fun experiment than an issue, I’m more curious as

  • 0

This is more of a fun experiment than an issue, I’m more curious as to what causes it.

I’m generating 2D points, stored as floats, in order to draw a collection of lines in pattern. When generating a new point, I make a copy of the last point, and move it in a certain direction based on a heading (x += cos(heading), y += sin(heading)). Heading is also stored as a float. I change the heading at a given rate (say, 90 degrees), which would imply that every new point is either parallel with the last point or at a right angle to it.

This works, but after many (1000s) of iterations, the outer edges of the pattern start to get slightly thicker, and then the newly plotted points start being moved at a slightly askew (but consistent) location. The entire pattern then starts to spin.

What I’m curious of is how something that shouldn’t break breaks. My best guess is the heading (a float which is constantly being reduced) is losing definition when it reaches a certain size.

Essentially, the code (for producing the exact pattern below) looks like this

float distance = 25;
int theta = 90;
float heading = 0;

    public static void main(String[] args) {
    turnLeft();
    func();
    turnRight();
    func();
    turnRight();
    turnRight();
    func();
}

public void func() {
    drawForward();
    turnRight();
    drawForward();
    turnRight();
    turnRight();
    drawForward();
    turnRight();
    drawForward();
    drawForward();
}

    public void turnLeft() {
    heading += degToRad(theta);
}

public void turnRight() {
    heading -= degToRad(theta);
}

public float degToRad(float degrees) {
    return (float) (degrees * (Math.PI / 180.0));
}

public void drawForward() {
    FPoint newFp = new FPoint(array[array.length - 1]); //copy last point

    movePoint(newFp, (float) (distance * Math.cos(heading)),
            (float) (distance * Math.sin(heading)));

    appendPoint(newFp); //add point to end of array

}

public void movePoint(FPoint fp, float x, float y) {
    fp.x += x;
    fp.y += y;
}

Any thoughts on the matter would be greatly appreciated!

  • 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-10T12:13:04+00:00Added an answer on June 10, 2026 at 12:13 pm

    See if you are at the exact same place when you move forward and backward. If you are not at the same location, then you subtract half of the difference from each forward movement.

    This could be in relation with numerical stability and precision of the calculations. http://en.wikipedia.org/wiki/Numerical_stability .

    Since you dont have a go backward , you just use forward + right + forward +right …. until you reach the starting place, then subtract if it is different then starting value. Then use this as an offset error value to subtract(but divide the error by number of movements first)(of course the would be like “FRFRFRFECC” )

    This is called BFECC back and forth error correction compensation. Greatly reduces the error if it is about unavoidable errors.

    I saw someone testing BFECC on Zalesak’s Turning Disk to see if disk becomes corrupt after thousands of rotation iterations.

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

Sidebar

Related Questions

I am writing a compiler (more for fun than anything else), but I want
This design problem is turning out to be a bit more interesting than I'd
I want to know this more in detail. Is it a realtime scheduler? An
To make this more clear, I'm going to put code samples: $file = fopen('filename.ext',
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history
I am wondering if there is a way to handle this more elegantly. After
Ok, I'm going to try to make this more clear because my last question
I have a label on my asp.net page, it looks like this: more info
This is more of a design question. I have a template class, and I
This is more for information then a problem. (On searching Stack Overflow I found

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.