Physion

  • Increase font size
  • Default font size
  • Decrease font size
Welcome, Guest
Please Login or Register.    Lost Password?

Something for Lynxx
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: Something for Lynxx
#622
Something for Lynxx 2 Years, 6 Months ago  
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.
Glenn555
Expert Boarder
Posts: 80
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: Adelaide, South Australia Birthday: 05/01
Last Edit: 2011/10/05 11:19 By Glenn555.
1x1 square diag = root-2. Cube diag = root-3. Beautiful !
The administrator has disabled public write access.
 
#625
Re: Something for Lynxx 2 Years, 6 Months ago  
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)
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.
Lynxx
Java/C#-Developer
Gold Boarder
Posts: 198
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Lynxx Homepage Location: Germany Birthday: 03/20
Infinity is vast, especially near end.
bye, Lynxx
The administrator has disabled public write access.
 
#627
Re: Something for Lynxx 2 Years, 6 Months ago  
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.
Glenn555
Expert Boarder
Posts: 80
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: Adelaide, South Australia Birthday: 05/01
1x1 square diag = root-2. Cube diag = root-3. Beautiful !
The administrator has disabled public write access.
 
#638
Re: Something for Lynxx 2 Years, 6 Months ago  
I've uploaded a small preview of my current work, but youtube-compression made a total mess of it.

Lynxx
Java/C#-Developer
Gold Boarder
Posts: 198
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Lynxx Homepage Location: Germany Birthday: 03/20
Last Edit: 2011/10/07 00:59 By Lynxx.
Infinity is vast, especially near end.
bye, Lynxx
The administrator has disabled public write access.
 
#639
Re: Something for Lynxx 2 Years, 6 Months ago  


Megavideo-link here in Forum wont work properly:
Lynxx
Java/C#-Developer
Gold Boarder
Posts: 198
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Lynxx Homepage Location: Germany Birthday: 03/20
Last Edit: 2011/10/07 08:32 By Lynxx.
Infinity is vast, especially near end.
bye, Lynxx
The administrator has disabled public write access.
 
#644
Re: Something for Lynxx 2 Years, 6 Months ago  
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!
Glenn555
Expert Boarder
Posts: 80
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: Adelaide, South Australia Birthday: 05/01
1x1 square diag = root-2. Cube diag = root-3. Beautiful !
The administrator has disabled public write access.
 
Go to topPage: 12