World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 04-05-2010, 01:09 AM   #1
wobster
Senior Java Developer/Consultant
 
wobster's Avatar
 
Join Date: Oct 2007
Location: Austin, Texas
Posts: 118
wobster is on a distinguished road
Default Why are 1-D arrays used in Analytic Surface?

Hi,

I've been looking at the Analytic Surface demo (shown below) and was curious what the motivation was to use 1D arrays for what is essentially a more natural 2D set of data. I imagine it had to do with passing the buffers around in an optimal manner, but I'd be interested to know the full architectural motivation and optimization trade-offs for this for my own edification

Thanks!

Rob


package gov.nasa.worldwind.examples.analytics;
class AnalyticSurfaceDemo ... {

public static BufferWrapper randomGridValues(int width, int height, double min, double max, int numIterations,
double smoothness, BufferFactory factory)
{
int numValues = width * height;
double[] values = new double[numValues];

for (int i = 0; i < numIterations; i++)
{
double offset = 1d - (i / (double) numIterations);

int x1 = (int) Math.round(Math.random() * (width - 1));
int x2 = (int) Math.round(Math.random() * (width - 1));
int y1 = (int) Math.round(Math.random() * (height - 1));
int y2 = (int) Math.round(Math.random() * (height - 1));
int dx1 = x2 - x1;
int dy1 = y2 - y1;

for (int y = 0; y < height; y++)
{
int dy2 = y - y1;
for (int x = 0; x < width; x++)
{
int dx2 = x - x1;

if ((dx2 * dy1 - dx1 * dy2) >= 0)
values[x + y * width] += offset;
}
}
}

smoothValues(width, height, values, smoothness);
scaleValues(values, numValues, min, max);
BufferWrapper buffer = factory.newBuffer(numValues);
buffer.putDouble(0, values, 0, numValues);

return buffer;
}
wobster is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Analytic Surface Available dcollins Feature Discussion 0 12-01-2009 07:37 PM
Rendering Markers on the Surface jas511 Development Help 1 11-07-2009 02:51 PM
[Solved] Performance problem with the new surface shape vash Development Help 16 09-19-2009 08:18 AM
Big surface shape problem Fous31 Development Help 3 05-19-2009 04:30 PM
Snapshot Error jediwashuu Bug Reports 4 11-06-2004 03:39 AM


All times are GMT +1. The time now is 09:27 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.