Intelligent Sigend Distance Fields
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.
 
 
 
 
 
 

79 lines
2.0 KiB

#include "functions.cuh"
__device__ float Max_function(float x, float y, float z)
{
auto fi = x * x + y * y + z * z - 0.5;
auto fj = (x - 0.5) * (x - 0.5) + y * y + z * z - 0.7;
auto result = max(fi, fj);
return result;
}
__device__ float Min_function(float x, float y, float z)
{
auto fi = x * x + y * y + z * z - 0.5;
auto fj = (x - 0.5) * (x - 0.5) + y * y + z * z - 0.7;
auto result = min(fi, fj);
return result;
}
__device__
float R_a_function(float x, float y, float z)
{
float a = 0.3f;
x = 2*M_PI*x+(2*M_PI);
y = 2*M_PI*y+(2*M_PI);
z = 2*M_PI*z+(2*M_PI);
auto fi = cos(x*10) + cos(y*10) + cos(z*10);
auto step = 0.2;
auto fj = cos((x - step)*10) + cos(y*10) + cos(z*10);
auto result = 1.0f / (1 + a) * (fi + fj + sqrt(fi * fi + fj * fj - 2 * a * fi * fj));
return result;
}
__device__ float R_0_m_function(float x, float y, float z)
{
//TODO
return 0;
}
__device__ float R_p_function(float x, float y, float z)
{
float p = 10;
x = 2*M_PI*x+(2*M_PI);
y = 2*M_PI*y+(2*M_PI);
z = 2*M_PI*z+(2*M_PI);
auto fi = cos(x*10) + cos(y*10) + cos(z*10);
auto step = 0.2;
auto fj = cos((x - step)*10) + cos(y*10) + cos(z*10);
auto result = fi + fj + pow((pow(fi, p), + pow(fj, p)), 1.0 / p);
return result;
}
__device__ float K_s_function(float x, float y, float z)
{
float p = 10;
x = 2*M_PI*x+(2*M_PI);
y = 2*M_PI*y+(2*M_PI);
z = 2*M_PI*z+(2*M_PI);
auto fi = cos(x*10) + cos(y*10) + cos(z*10);
auto step = 0.2;
auto fj = cos((x - step)*10) + cos(y*10) + cos(z*10);
auto fmax = max(fi, fj);
auto result = log(exp(p * (fi - fmax) ) + exp(p * (fj - fmax))) / p + fmax;
return result;
}
__device__ float P_norm(float x, float y , float z)
{
float p = 10;
x = 2*M_PI*x+(2*M_PI);
y = 2*M_PI*y+(2*M_PI);
z = 2*M_PI*z+(2*M_PI);
auto fi = cos(x*10) + cos(y*10) + cos(z*10);
auto step = 0.2;
auto fj = cos((x - step)*10) + cos(y*10) + cos(z*10);
auto result = pow(pow(fi, p) + pow(fj, p), 1 / p);
return result;
}