18 #ifndef ExprBuiltins_h
19 #define ExprBuiltins_h
29 inline double deg(
double angle) {
return angle * (180 / M_PI); }
30 inline double rad(
double angle) {
return angle * (M_PI / 180); }
31 inline double cosd(
double x) {
return cos(
rad(x)); }
33 inline double tand(
double x) {
return tan(
rad(x)); }
34 inline double acosd(
double x) {
return deg(acos(x)); }
35 inline double asind(
double x) {
return deg(asin(x)); }
36 inline double atand(
double x) {
return deg(atan(x)); }
37 inline double atan2d(
double y,
double x) {
return deg(atan2(y, x)); }
40 inline double clamp(
double x,
double lo,
double hi) {
return x < lo ? lo : x > hi ? hi :
x; }
41 inline double round(
double x) {
return x < 0 ? ceil(x - 0.5) : floor(x + 0.5); }
42 inline double max(
double x,
double y) {
return x > y ? x :
y; }
43 inline double min(
double x,
double y) {
return x < y ? x :
y; }
46 inline double invert(
double x) {
return 1 -
x; }
47 double compress(
double x,
double lo,
double hi);
48 double expand(
double x,
double lo,
double hi);
49 double fit(
double x,
double a1,
double b1,
double a2,
double b2);
50 double gamma(
double x,
double g);
51 double bias(
double x,
double b);
57 double remap(
double x,
double s,
double r,
double f,
double interp);
58 double mix(
double x,
double y,
double alpha);
65 double hash(
int n,
double* args);
73 double fbm(
int n,
const Vec3d* args);
81 double dist(
double ax,
double ay,
double az,
double bx,
double by,
double bz);
83 double hypot(
double x,
double y);
93 double pick(
int n,
double* params);
94 double choose(
int n,
double* params);
95 double wchoose(
int n,
double* params);
96 double spline(
int n,
double* params);
double cellnoise(const Vec3d &p)
void(* Define3)(const char *name, ExprFunc f, const char *docString)
Defined as float g float float float a2
Vec3d hsi(int n, const Vec3d *args)
Vec3d up(const Vec3d &P, const Vec3d &upvec)
double dot(const Vec3d &a, const Vec3d &b)
Vec3d vfbm(int n, const Vec3d *args)
double atan2d(double y, double x)
Vec3d ccellnoise(const Vec3d &p)
Vec3d cturbulence(int n, const Vec3d *args)
void defineBuiltins(ExprFunc::Define define, ExprFunc::Define3 define3)
The result is computed int loRange
The result is computed int int hiRange
double remap(double x, double source, double range, double falloff, double interp)
double expand(double x, double lo, double hi)
double choose(int n, double *params)
double smoothstep(double x, double a, double b)
double pick(int n, double *params)
with numParticles numAttributes A variable block contains variable names and types but doesn t care what the values are< pre > void f(const std::string &s, MyParticleData *p, int outputDim=3)
double length(const Vec3d &v)
Vec3d cnoise(const Vec3d &p)
double max(double x, double y)
double bias(double x, double b)
The result is computed int int< br >< divstyle="margin-left:40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed). 
Defined as float g float a1
double cycle(double index, double loRange, double hiRange)
Vec< double, 3, false > Vec3d
double contrast(double x, double c)
double min(double x, double y)
double wchoose(int n, double *params)
double fbm(int n, const Vec3d *args)
Vec3d vnoise(const Vec3d &p)
double dist(double ax, double ay, double az, double bx, double by, double bz)
double gamma(double x, double g)
double linearstep(double x, double a, double b)
void(* Define)(const char *name, ExprFunc f)
</pre >< h3 > A simple variable reference</h3 > This is not a very interesting subclass of expression until we add some additional variables Variables on some applications may be very dynamic In this we only need x
Vec3d cross(const Vec3d &a, const Vec3d &b)
double mix(double x, double y, double alpha)
double fit(double x, double a1, double b1, double a2, double b2)
Vec3d midhsi(int n, const Vec3d *args)
Vec3d vturbulence(int n, const Vec3d *args)
double boxstep(double x, double a)
double clamp(double x, double lo, double hi)
Defined as float g float float b1
double hypot(double x, double y)
double turbulence(int n, const Vec3d *args)
double angle(const Vec3d &a, const Vec3d &b)
double snoise(const Vec3d &p)
Vec3d rgbtohsl(const Vec3d &rgb)
double spline(int n, double *params)
Vec3d hsltorgb(const Vec3d &hsl)
Defined as a *alpha b *alpha< br ></div >< br > float< b > float a
Vec3d norm(const Vec3d &a)
double compress(double x, double lo, double hi)
* sin(val)/val" </pre> we would get <pre> | | | | | </pre> or if we did <pre> ./asciiGraph "x-3" </pre> we'd get <pre> | | ------------------------------|----------------- | | | | | </pre> <h2>Implement the subclass</h2> First we subclass Expression and give it a const ructor
double pnoise(const Vec3d &p, const Vec3d &period)
Vec3d ortho(const Vec3d &a, const Vec3d &b)
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float y
double hash(int n, double *args)
double noise(int n, const Vec3d *args)
double gaussstep(double x, double a, double b)
Vec3d cfbm(int n, const Vec3d *args)