Hey JGO,
Im just wondering how i could get the same effect as this:
I’ve dabbled in perlin noise but how would i modify that into a circle
so from this:
to the image above
thanks
ps. sorry if this is confusing ???
Hey JGO,
Im just wondering how i could get the same effect as this:
I’ve dabbled in perlin noise but how would i modify that into a circle
so from this:
to the image above
thanks
ps. sorry if this is confusing ???
Yay! Polar coords!
Been a while since I did this, but I /think/ it’s something like this:
Given a variable ‘pos’:
double x = Math.cos(pos) * perlinNoise(pos);
double y = Math.sin(pos) * perlinNoise(pos);
Should get you a x and a y value from the original perlinNoise func. I’m not too certain though.
I dont undertand this st all, what does pos represent exactally?
Ah sorry I meant to explain that but I forgot
I was assuming you had a function, which I called “perlinNoise” which takes one argument, and that the second image on your thread was a graph (y=perlinNoise(x)).
‘pos’ was meant to be the argument you were originally passing to your perlinNoise function.
Is this 2D? 3D? LWJGL? Java2D? LibGDX? Give us some details.
A very simple solution is to draw a circle in arc segments, but choose a random value between X and Y as your radius for each segment. That way it will have a bumpy perimeter. You can smooth out the randomness by using linear interpolation between the two random samples (i.e. value noise). Chances are you will only need 1D noise. Here’s a great intro to value noise:
http://www.scratchapixel.com/lessons/3d-advanced-lessons/noise-part-1/introduction/
If you are also looking to create a procedural texture for the earth, you can do so fairly easily in a frag shader. A common approach is to generate a terrain texture and apply it to a spherical mesh. I explain a different approach in the following thread; by rendering the planet entirely in a fragment shader:
http://slick.javaunlimited.net/viewtopic.php?p=34417#p34417
im making this in java2d, 2d
Following on from @DeadlyFugu. Essentially when you make a circle, you want to decide how many vertices will make up the curve. Then you divide 360 (or 2 PI) by the number which gives you the angle between each point (as in the angle between two radii to two of the points). Then to work out the coords of a point, use trig to transform the polar coords to Cartesian. Code:
float cx = whatever; //the x centre of the circle
float cy = whatever; //the y centre of the circle
float r = whatever; //the radius of the circle
int lod = whatever; //(the number of vertices)
float inc = ( 2 * PI ) / lod;
float theta = 0;
for(int i = 0; i < lod; i++, theta += inc) {
float xCoord = cx + ( cos(theta) * r );
float yCoord = cx + ( sin(theta) * r );
//Construct your vertex as appropriate.
}
So what @DeadlyFungu shows is using a noise value (I’m assuming you understand perlin / simplex noise) for the radius of the circle so that it will have varying “size” at different points as per your image. One thing I would suggest is that you use:
float noise = perlinNoise(theta) * ( r / 16 ); //Where r is the radius again. Assuming the function returns 0 - 1 range
double x = Math.cos(theta) * ( r + noise );
double y = Math.sin(theta) * ( r + noise );
This way, the noise works as an offset to the planets radius rather than just on its own. I’ve also made it so that the noise ranges between 0 and 1/16th the planets radius which I figured would look like an atmosphere. Obviously customize to look better.