Physion

  • Increase font size
  • Default font size
  • Decrease font size
Welcome, Guest
Username Password: Remember me

Something for Lynxx
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Something for Lynxx

Something for Lynxx 4 years, 6 months ago #622

Hi Lynxx.
Sorry, if this is slightly off-topic, (Java, not Physion/Javascript)...

I was researching on the net, while laid up and distracting myself. For maths to
automatically define evenly spaced set positions around a circle, is obviously easy.
I got to wondering about spheres, and many sites/sources said that their is no single
algorithm to compute evenly spaced points on a shere! (Other than obvious points
like 0, 90, 180 deg etc on x,y,z planes). Thought that sounded wierd !
Seems it's true, and is done using some complex zero-ing in recursive itterations.
As a consequence, i found this guy, Ken Perlin, Professor in Computer Science,
hwo specializes in teaching through the use of Java, and especially 3D stuff....
cs.nyu.edu/~perlin/

It reminded me of your Physion scene on Virus growth visuals. Especially...
mrl.nyu.edu/~perlin/experiments/repel/
which places any number of objects around a sphere. And a subset...
mrl.nyu.edu/~perlin/experiments/repel/index2.html
where the objects tend to 'populate' in groups, upon the sphere.
I damn well spent HOURS on his site, checking out stuff. All done in Java, that is
your expertise. Thought you might be interested. MOST includes source code!

Other interesting pages are, (they are all interesting!)....
mrl.nyu.edu/~perlin/experiments/incompressible/
and...
mrl.nyu.edu/~perlin/experiments/demox/Hyper.html
The last one mentioned requires understanding 4th dimention hypercubes !!
This guy must really like his work, and programming, and teaching.
Just thought I'd pass it along.
Glenn.
1x1 square diag = root-2. Cube diag = root-3. Beautiful !
Last Edit: 4 years, 6 months ago by Glenn555.

Re: Something for Lynxx 4 years, 6 months ago #625

  • Lynxx
  • OFFLINE
  • Gold Boarder
  • Java/C#-Developer
  • Posts: 211
Glenn555 wrote:
..I got to wondering about spheres, and many sites/sources said that their is no single algorithm to compute evenly spaced points on a shere! (Other than obvious points
like 0, 90, 180 deg etc on x,y,z planes). Thought that sounded wierd !
Seems it's true, and is done using some complex zero-ing in recursive itterations.

Na, that's not true, can be done without iteration & recursion: (C# code)
public static Vertex[] CreateSphere(float radius, float height, byte segments, byte rings, out ushort[] elements) {
var num_vertices = segments * rings;
ushort[] elementsArray = new ushort[num_vertices * 6];
var data = new Vertex[num_vertices];
 
short i = 0;
for (double y = 0; y < rings; y++) {
double phi = (y / (rings - 1)) * Math.PI;
for (double x = 0; x < segments; x++) {
double theta = (x / (segments - 1)) * 2 * Math.PI;
Vector3 v = new Vector3() {
X = (float)(radius * Math.Sin(phi) * Math.Cos(theta)),
Y = (float)(height * Math.Cos(phi)),
Z = (float)(radius * Math.Sin(phi) * Math.Sin(theta)),
};
Vector3 n = Vector3.Normalize(v);
Vector2 uv = new Vector2() {
X = (float)-(x / (segments - 1)),
Y = (float)(y / (rings - 1))
};
data[i++] = new Vertex() { Position = v, Normal = n, TexCoord = uv };
}
}
 
i = 0;
for (byte y = 0; y < rings - 1; y++) {
for (byte x = 0; x < segments - 1; x++) {
elementsArray[i++] = (ushort)((y + 0) * segments + x);
elementsArray[i++] = (ushort)((y + 1) * segments + x);
elementsArray[i++] = (ushort)((y + 1) * segments + x + 1);
elementsArray[i++] = (ushort)((y + 1) * segments + x + 1);
elementsArray[i++] = (ushort)((y + 0) * segments + x + 1);
elementsArray[i++] = (ushort)((y + 0) * segments + x);
}
}
 
// Verify that we don't access any vertices out of bounds:
foreach (int index in elementsArray)
if (index >= segments * rings)
throw new IndexOutOfRangeException();
 
elements = elementsArray;
 
return data;
}
 
public struct Vertex {
public Vector2 TexCoord;
public Vector3 Normal;
public Vector3 Position;
}


I guess Codeviewing wont work, look here instead: CreateSphere.cs

As a consequence, i found this guy, Ken Perlin, Professor in Computer Science,
hwo specializes in teaching through the use of Java, and especially 3D stuff...

I know him, i'm currently working on a "Galaxy-Blanker", therefore i needed Perlin Noise to create nebula in the background. (But Perlin-Noise is slow, so it ported it to C++) And i also needed something like the above Sphere-Creationcode to create a rotating planet in front of the blanker-scene .. Other things like fluid simulation i had done back in 2004 Water.
Infinity is vast, especially near end.
bye, Lynxx

Re: Something for Lynxx 4 years, 6 months ago #627

Thanks for that Lynxx.
The code-view came out ok, and I've made a copy. Should be easy to port from C#.
I had noticed the 'Perlin Noise' link before. Good for more organic natural looks.
Good luck with your new project. Have seen parts of your site before, and I knew
all that would be right up your alley !
Have a good day/night.
1x1 square diag = root-2. Cube diag = root-3. Beautiful !

Re: Something for Lynxx 4 years, 6 months ago #638

  • Lynxx
  • OFFLINE
  • Gold Boarder
  • Java/C#-Developer
  • Posts: 211
I've uploaded a small preview of my current work, but youtube-compression made a total mess of it.

Infinity is vast, especially near end.
bye, Lynxx
Last Edit: 4 years, 6 months ago by Lynxx.

Re: Something for Lynxx 4 years, 6 months ago #639

  • Lynxx
  • OFFLINE
  • Gold Boarder
  • Java/C#-Developer
  • Posts: 211


Megavideo-link here in Forum wont work properly:
Infinity is vast, especially near end.
bye, Lynxx
Last Edit: 4 years, 6 months ago by Lynxx.

Re: Something for Lynxx 4 years, 6 months ago #644

Very clever !
Takes awhile for me to download at the moment.
At the moment, just using a portable laptop, wireless-usb broadband.
In a crappy area at the moment, where the signal is weak!
1x1 square diag = root-2. Cube diag = root-3. Beautiful !
  • Page:
  • 1
  • 2
Moderators: Glenn555
Time to create page: 0.14 seconds