This commit is contained in:
martin_837013 2016-12-05 11:01:12 -06:00
parent ef4b170a26
commit a615b6bcef

View file

@ -7,10 +7,34 @@
#include <vector> #include <vector>
#include "../include/CompFab.h" #include "../include/CompFab.h"
#include "../include/Mesh.h" #include "../include/Mesh.h"
#include "../include/ppm.h"
#include "../include/PerlinNoise.h"
#include <math.h> #include <math.h>
#define PI 3.14159265 #define PI 3.14159265
double distanceA2B(double ax, double ay, double bx, double by){
return sqrt((bx-ax)*(bx-ax) + (by-ay)*(by-ay));
}
double jerfunc(double x, double y, PerlinNoise pnoise){
double n = 0;
double m = 0;
//perlin noise
n = 20 * pnoise.noise(x,y,0.8);
n = n - floor(n);
//Central distrobution
//distance from point to center
m = distanceA2B(x,y,0.5,0.5);
return (m*0.15)+(n*0.85);
}
//A function to find the X and Y dimensions of the template obj //A function to find the X and Y dimensions of the template obj
void findLW(Mesh &m, double &l, double &w) void findLW(Mesh &m, double &l, double &w)
{ {
@ -56,6 +80,8 @@ std::vector<CompFab::Vec3> createVec3d(int layers, double spacing, double length
// Vec3 to hold our current translation matrix. // Vec3 to hold our current translation matrix.
CompFab::Vec3 *trans = new CompFab::Vec3(0, spacing, 0); CompFab::Vec3 *trans = new CompFab::Vec3(0, spacing, 0);
CompFab::Vec3 *coord = new CompFab::Vec3(0.5,0.5,0);
// cl for current layer. // cl for current layer.
for(int cl = 1; cl < layers; cl++) for(int cl = 1; cl < layers; cl++)
{ {
@ -70,6 +96,11 @@ std::vector<CompFab::Vec3> createVec3d(int layers, double spacing, double length
*temp = *temp + *trans; *temp = *temp + *trans;
output->push_back(*temp); output->push_back(*temp);
*coord = *coord + mmult(trans, Vec3(1/(layers*2-1)/2),1/(layers*2-1)/2,0);
*temp=mmult(temp,Vec3(1,1,n));
} }
} }
@ -125,8 +156,8 @@ int main(int argc, char **argv)
// Debugging // Debugging
if(argc > 3) if(argc > 3)
{ {
if(strcmp(argv[3], "-d") == 0)
{ // {
for(int j = 0; j < output->v.size(); j++) for(int j = 0; j < output->v.size(); j++)
{ {
std::cout << output->v[j].m_x << " " << output->v[j].m_y << " " << output->v[j].m_z << std::endl; std::cout << output->v[j].m_x << " " << output->v[j].m_y << " " << output->v[j].m_z << std::endl;