Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Creating a circular "grid" ?  (Read 1861 times)
0 Members and 1 Guest are viewing this topic.
Offline EliwoodL

Senior Newbie





« Posted 2013-11-11 16:55:33 »

My quest is to essentially create different-sized rings, centered around the same point, that are made of 1-unit pieces.

My problems are that I have difficulty understanding the math required to create such.  I know how to create rings that are made of differing SIZED pieces, like 360 degrees = 360 pieces per ring, but the pieces get progressively larger as you go away from the origin point.  I don't want that - I want the pieces to stay the same size, instead creating more as you go outward.

I was hoping someone would help me figure out how to fix up my code in order to do this.


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      float radians = (float) Math.toRadians(degrees);
     
      float[] data = new float[] {};
     
      float circ = MathUtil.getCircumference(depth); // Get the circumference at the chosen depth
     float circt = MathUtil.fastfloor(circ); // Round the circumference
     
      for (int c = 0; c < circt; c++) { // For every 1 "unit" do
        float rads = (float) c / circt; // Dividing the count by the circumference gives us the radian measure for each block
       
      }


That was as far as I had gotten before this made itself clear to my mind.
Offline jonjava
« Reply #1 - Posted 2013-11-11 17:12:13 »

Just use a normal "square" grid and don't draw/make the ones that don't fit your desired shape  moot.

Hexagonal grids, for instance, also just use a normal "square" grid jut viewed at a funny angle basically. The "data" that makes up the grids are essentially the same.

Offline EliwoodL

Senior Newbie





« Reply #2 - Posted 2013-11-11 17:17:46 »

I would do it that way, were it not for that you're supposed to be viewing these at all angles - the "up" can be in any direction along this single plane.  But since it's like that, it's supposed to look like everything is going towards the center - if I were to use a square grid in this case, if you were looking at it at a 45 degree angle, everything would be diagonal.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jonjava
« Reply #3 - Posted 2013-11-11 17:22:37 »

Data doesn't care about angles, though :D

Offline DrZoidberg

Senior Member


Medals: 15



« Reply #4 - Posted 2013-11-11 19:34:47 »

You need to multiply by 2*pi to get the angle in rads.
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #5 - Posted 2013-11-11 22:12:11 »

At the moment I'm under the impression you want a set of concentric rings broken into segments, with each segment of every ring having the same area as every other segment.

If this is not the case, maybe you should show us a diagram to better explain what it is you're after.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline saucymeatman
« Reply #6 - Posted 2013-11-11 22:22:38 »

I agree with jonjava, for just storing data, angles and other like calculations are irrelevant. Smiley
Watch, as I magically store boolean values for a magical 4-dimensional grid :
(psuedo-code for times sake)
1  
2  
3  
4DGrid grid = new 4DGrid();
 grid.point(1,3,5,7) = false;
 grid.point(10,3,5,64) = true;

Now, I couldnt DRAW that grid, it would be impossible.  Tongue
Offline philfrei
« Reply #7 - Posted 2013-11-11 23:06:50 »

Interesting problem.

If the length of the piece of circumference for a piece is to stay the same, then you will be limited to radii that allow whole-number multiples of the unit size.

C = 2 PI R

If your distance of a unit is, say 10, possible circumferences are multiples of 10, and you can calculate your radii from there.

8 units = total circumference of 80, so radius would be 40 / PI.
12 units = total circumference of 120, so radius would be 60 / PI.

There is also the matter of settling the 'phase' of each ring, i.e., at what angle the first unit starts.


"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline EliwoodL

Senior Newbie





« Reply #8 - Posted 2013-11-16 02:28:32 »

Abuse has the right idea, and philfrei goes a little more in depth.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (22 views)
2014-07-24 01:59:36

Riven (20 views)
2014-07-23 21:16:32

Riven (17 views)
2014-07-23 21:07:15

Riven (20 views)
2014-07-23 20:56:16

ctomni231 (48 views)
2014-07-18 06:55:21

Zero Volt (44 views)
2014-07-17 23:47:54

danieldean (35 views)
2014-07-17 23:41:23

MustardPeter (38 views)
2014-07-16 23:30:00

Cero (53 views)
2014-07-16 00:42:17

Riven (52 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!