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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:35:18+00:00 2026-05-31T21:35:18+00:00

I have an array: int[][] lawn = new int[980][1280]; wich stores the values of

  • 0

I have an array: int[][] lawn = new int[980][1280];

wich stores the values of the height of the blades in the lawn.

In my simulation i have a robot that goes around the lawn and cuts the blades.

my robot has the form of a circle with a diameter (rDiameter).
The coordinate system is done with Double and my lawn is in Integer.

I have developped two “algorithms” that allows the robot to cut the lawn but i’m not satisfied because the precisions of my algorithms is not high enough and the performance also.

My question is, is there a way to do this other than the ideas that I have already thought of?

Or do I need to change the implementation of my lawn to get better results?

Feel free to ask anything if i was not clear enough.

Here is the code for my two algorithms (k stands for the robot), centerPosition returns the center of my robot(so the center of the circle)

approach with square
    int bottomLeftCornerX = (int) (k.getCenterPosition().getX() - simulParams.getKDiameter() / 2);
    int bottomLeftCornerY = (int) (k.getCenterPosition().getY() - simulParams.getKDiameter() / 2);

    for (int i = bottomLeftCornerX; i < bottomLeftCornerX + simulParams.getKDiameter(); i++) {
        for (int j = bottomLeftCornerY; j < bottomLeftCornerY + simulParams.getKDiameter(); j++) {
            ((LawnArea) lawn.getBladeHeight()).cutBladeInArea(j, i);
        }
    }

And here the one with the circle approach (basically it’s the circonference formule present in wikipedia…):

for (int r = 0; r < simulParams.getKDiameter() / 2; r++) {

        for (double t = 0; t < 2 * Math.PI; t = t + 0.1) {
            Point2D p = circumference(k.getCenterPosition().getX(), k.getCenterPosition().getY(), t, r);
            int intX = (int) Math.ceil(p.getX());
            int intY = (int) Math.ceil(p.getY());
                ((LawnArea) lawn.getBladeHeight()).cutBladeInArea(intY, intX);
            }
        }
    }
  • 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-31T21:35:20+00:00Added an answer on May 31, 2026 at 9:35 pm

    For readability:
    k.x is the x coordinate,
    k.y is the y coordinate,
    k.r is the radius.

    for(int y = (int)Math.max(0, Math.ceil(k.y - k.r)); y <= (int)Math.min(980, Math.floor(k.y + k.r)); y++) {
        doulbe dx = Math.sqrt(k.r * k.r - Math.abs(y-k.y) * Math.abs(y-k.y));
        for(int x = Math.max(0, (int)Math.ceil(k.x - dx)); x <= (int)Math.min(1280, Math.floor(k.x + dx)); x++) {
            cut(x,y);
        }
    }

    There are two loops:
    The first one is for the y-coordinate and starts at k.y - k.r and goes until k.y + k.r if the circle is completly on the field (I didn’t know if it always was, if yes then you can’t reach the corners), so from the top to the bottom of your screen.
    The second one is for the x coordinate. The smalles and biggest x are calculated with the help of the formular (k.x – x)² + (k.y – y)² = k.r².
    With that you only get points in your circle. It’s a little smaller because of double to int conversion.

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

Sidebar

Related Questions

suppose that we have three array int a[]=new int[]{4,6,8,9,11,12}; int b[]=new int[]{3,5,7,13,14}; int c[]=new
i have an array like below int[] array = new array[n];// n may be
I have an int array containing gray scale values from 0-254, i also have
I have an array of integers: int[] number = new int[] { 2,3,6,7 };
I have a prototype: int[] medianFileter(int[] data); and an array int[] intVal = new
I have an array: int test[]={10212,10202,11000,11000,11010}; I want to split the inetger values to
I have an array int arr[5] that is passed to a function fillarr(int arr[])
For example I have this array: int a[] = new int[]{3,4,6,2,1}; I need list
I have an int array int[] myArray = new int[100]; and want to get
I have a 3D array that I'm accessing this way Array(int x, int y,

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.