You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
1.9 KiB
102 lines
1.9 KiB
//
|
|
// main.cpp
|
|
// AwesomeAttractorND
|
|
//
|
|
// Created by Joshua Moerman on 10/24/11.
|
|
// Copyright 2011 Vadovas. All rights reserved.
|
|
//
|
|
|
|
#include <iostream>
|
|
|
|
#include "nd_array.hpp"
|
|
#include "Canvas.hpp"
|
|
#include "Tonemapper.hpp"
|
|
#include "Image.hpp"
|
|
|
|
const size_t width = 512;
|
|
const size_t height = 64;
|
|
const size_t depth = 32;
|
|
|
|
typedef nd_array<double, 3> array;
|
|
|
|
double calculate1(array & c){
|
|
double mean = 0.0;
|
|
for (unsigned int x = 0; x < width; ++x) {
|
|
for (unsigned int y = 0; y < height; ++y) {
|
|
for (unsigned int z = 0; z < depth; ++z) {
|
|
mean += 1.0/(width*height*depth) * c[x][y][z];
|
|
}
|
|
}
|
|
}
|
|
return mean;
|
|
}
|
|
|
|
void calculate2(array & c, double mean){
|
|
for (unsigned int x = 0; x < width; ++x) {
|
|
for (unsigned int y = 0; y < height; ++y) {
|
|
for (unsigned int z = 0; z < depth; ++z) {
|
|
c[x][y][z] = c[x/3][y][z/2] * mean / 200.0 + mean - x;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void calculate(array & c){
|
|
std::cout << "Calculating..." << std::endl;
|
|
|
|
for (unsigned int i = 0; i < 1000; ++i) {
|
|
double mean = calculate1(c);
|
|
calculate2(c, mean);
|
|
}
|
|
}
|
|
|
|
void fill(array & c){
|
|
std::cout << "Filling..." << std::endl;
|
|
|
|
for (unsigned int x = 0; x < width; ++x) {
|
|
for (unsigned int y = 0; y < height; ++y) {
|
|
for (unsigned int z = 0; z < depth; ++z) {
|
|
c[x][y][z] = x + z;
|
|
if (y == 5) {
|
|
c[x][y][z] = 5;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void output(array & c){
|
|
std::cout << "Outputting..." << std::endl;
|
|
|
|
for (unsigned int y = 0; y < 10; ++y) {
|
|
for (unsigned int x = 0; x < 10; ++x) {
|
|
std::cout << c[x][y][2] << '\t';
|
|
}
|
|
std::cout << '\n';
|
|
}
|
|
|
|
std::cout << "Outputting addresses..." << std::endl;
|
|
|
|
for (unsigned int z = 20; z < 30; ++z) {
|
|
double & n = c[32][64][z];
|
|
std::cout << &n << '\n';
|
|
}
|
|
}
|
|
|
|
int main (int argc, const char * argv[]){
|
|
|
|
std::cout << "Creating..." << std::endl;
|
|
|
|
array c(width, height, depth);
|
|
|
|
fill(c);
|
|
|
|
calculate(c);
|
|
|
|
output(c);
|
|
|
|
std::cout << "Done" << std::endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|