00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef SeExprBuiltins_h
00012 #define SeExprBuiltins_h
00013
00014 #include "SeExprFunc.h"
00015 #include "SePlatform.h"
00016
00017 class SeVec3d;
00018
00019 namespace SeExpr
00020 {
00021 void initPerlin();
00022
00023
00024 inline double deg(double angle) { return angle * (180/M_PI); }
00025 inline double rad(double angle) { return angle * (M_PI/180); }
00026 inline double cosd(double x) { return cos(rad(x)); }
00027 inline double sind(double x) { return sin(rad(x)); }
00028 inline double tand(double x) { return tan(rad(x)); }
00029 inline double acosd(double x) { return deg(acos(x)); }
00030 inline double asind(double x) { return deg(asin(x)); }
00031 inline double atand(double x) { return deg(atan(x)); }
00032 inline double atan2d(double y, double x) { return deg(atan2(y,x)); }
00033
00034
00035 inline double clamp(double x, double lo, double hi) {
00036 return x < lo ? lo : x > hi ? hi : x;
00037 }
00038 inline double round(double x) { return x < 0 ? ceil(x-0.5) : floor(x+0.5); }
00039 inline double max(double x, double y) { return x > y ? x : y; }
00040 inline double min(double x, double y) { return x < y ? x : y; }
00041
00042
00043 inline double invert(double x) { return 1-x; }
00044 double compress(double x, double lo, double hi);
00045 double expand(double x, double lo, double hi);
00046 double fit(double x, double a1, double b1, double a2, double b2);
00047 double gamma(double x, double g);
00048 double bias(double x, double b);
00049 double contrast(double x, double c);
00050 double boxstep(double x, double a);
00051 double linearstep(double x, double a, double b);
00052 double smoothstep(double x, double a, double b);
00053 double gaussstep(double x, double a, double b);
00054 double remap(double x, double s, double r, double f, int interp);
00055 double mix(double x, double y, double alpha);
00056 SeVec3d hsi(int n, const SeVec3d* args);
00057 SeVec3d midhsi(int n, const SeVec3d* args);
00058 SeVec3d rgbtohsl(const SeVec3d& rgb);
00059 SeVec3d hsltorgb(const SeVec3d& hsl);
00060
00061
00062 double hash(int n, double* args);
00063 double noise(int n, const SeVec3d* args);
00064 double snoise(const SeVec3d& p);
00065 SeVec3d cnoise(const SeVec3d& p);
00066 SeVec3d vnoise(const SeVec3d& p);
00067 double turbulence(int n, const SeVec3d* args);
00068 SeVec3d vturbulence(int n, const SeVec3d* args);
00069 SeVec3d cturbulence(int n, const SeVec3d* args);
00070 double fbm(int n, const SeVec3d* args);
00071 SeVec3d vfbm(int n, const SeVec3d* args);
00072 SeVec3d cfbm(int n, const SeVec3d* args);
00073 double cellnoise(const SeVec3d& p);
00074 SeVec3d ccellnoise(const SeVec3d& p);
00075 double pnoise(const SeVec3d& p, const SeVec3d& period);
00076
00077
00078 double dist(double ax, double ay, double az, double bx, double by, double bz);
00079 double length(const SeVec3d& v);
00080 double hypot(double x, double y);
00081 double dot(const SeVec3d& a, const SeVec3d& b);
00082 SeVec3d norm(const SeVec3d& a);
00083 SeVec3d cross(const SeVec3d& a, const SeVec3d& b);
00084 double angle(const SeVec3d& a, const SeVec3d& b);
00085 SeVec3d ortho(const SeVec3d& a, const SeVec3d& b);
00086 SeVec3d up(const SeVec3d& vec, const SeVec3d& upvec);
00087
00088
00089 double cycle(double index, double loRange, double hiRange);
00090 double pick(int n, double* params);
00091 double choose(int n, double* params);
00092 double wchoose(int n, double* params);
00093 double spline(int n, double* params);
00094
00095
00096 void defineBuiltins(SeExprFunc::Define define,SeExprFunc::Define3 define3);
00097 }
00098
00099 #endif