SeExpr

ExprBuiltins.h
Go to the documentation of this file.
1 /*
2 * Copyright Disney Enterprises, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License
6 * and the following modification to it: Section 6 Trademarks.
7 * deleted and replaced with:
8 *
9 * 6. Trademarks. This License does not grant permission to use the
10 * trade names, trademarks, service marks, or product names of the
11 * Licensor and its affiliates, except as required for reproducing
12 * the content of the NOTICE file.
13 *
14 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
16 */
17
18 #ifndef ExprBuiltins_h
19 #define ExprBuiltins_h
20
21 #include "ExprFunc.h"
22 #include "Platform.h"
23
24 namespace SeExpr2 {
25
26 void initPerlin();
27
28 // trig
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)); }
32 inline double sind(double x) { return sin(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)); }
38
39 // clamping
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; }
44
45 // blending / remapping
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);
52 double contrast(double x, double c);
53 double boxstep(double x, double a);
54 double linearstep(double x, double a, double b);
55 double smoothstep(double x, double a, double b);
56 double gaussstep(double x, double a, double b);
57 double remap(double x, double s, double r, double f, double interp);
58 double mix(double x, double y, double alpha);
59 Vec3d hsi(int n, const Vec3d* args);
60 Vec3d midhsi(int n, const Vec3d* args);
61 Vec3d rgbtohsl(const Vec3d& rgb);
62 Vec3d hsltorgb(const Vec3d& hsl);
63
64 // noise
65 double hash(int n, double* args);
66 double noise(int n, const Vec3d* args);
67 double snoise(const Vec3d& p);
68 Vec3d cnoise(const Vec3d& p);
69 Vec3d vnoise(const Vec3d& p);
70 double turbulence(int n, const Vec3d* args);
71 Vec3d vturbulence(int n, const Vec3d* args);
72 Vec3d cturbulence(int n, const Vec3d* args);
73 double fbm(int n, const Vec3d* args);
74 Vec3d vfbm(int n, const Vec3d* args);
75 Vec3d cfbm(int n, const Vec3d* args);
76 double cellnoise(const Vec3d& p);
77 Vec3d ccellnoise(const Vec3d& p);
78 double pnoise(const Vec3d& p, const Vec3d& period);
79
80 // vectors
81 double dist(double ax, double ay, double az, double bx, double by, double bz);
82 double length(const Vec3d& v);
83 double hypot(double x, double y);
84 double dot(const Vec3d& a, const Vec3d& b);
85 Vec3d norm(const Vec3d& a);
86 Vec3d cross(const Vec3d& a, const Vec3d& b);
87 double angle(const Vec3d& a, const Vec3d& b);
88 Vec3d ortho(const Vec3d& a, const Vec3d& b);
89 Vec3d up(const Vec3d& vec, const Vec3d& upvec);
90
91 // variations
92 double cycle(double index, double loRange, double hiRange);
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);
97
98 // add builtins to expression function table
99 void defineBuiltins(ExprFunc::Define define, ExprFunc::Define3 define3);
100 }
101
102 #endif
SeExpr2::compress
double compress(double x, double lo, double hi)
Definition: ExprBuiltins.cpp:92
SeExpr2::pnoise
double pnoise(const Vec3d &p, const Vec3d &period)
Definition: ExprBuiltins.cpp:749
SeExpr2::vfbm
Vec3d vfbm(int n, const Vec3d *args)
Definition: ExprBuiltins.cpp:633
SeExpr2::dot
double dot(const Vec3d &a, const Vec3d &b)
Definition: ExprBuiltins.cpp:1072
SeExpr2::noise
double noise(int n, const Vec3d *args)
Definition: ExprBuiltins.cpp:461
index
The result is computed int int< br >< div style="margin-left: 40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed). &nbsp
f
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)
Definition: varblocks.txt:35
SeExpr2::rad
double rad(double angle)
Definition: ExprBuiltins.h:30
SeExpr2::hsi
Vec3d hsi(int n, const Vec3d *args)
Definition: ExprBuiltins.cpp:223
SeExpr2::up
Vec3d up(const Vec3d &P, const Vec3d &upvec)
Definition: ExprBuiltins.cpp:1122
SeExpr2::cturbulence
Vec3d cturbulence(int n, const Vec3d *args)
Definition: ExprBuiltins.cpp:599
SeExpr2::atan2d
double atan2d(double y, double x)
Definition: ExprBuiltins.h:37
SeExpr2::asind
double asind(double x)
Definition: ExprBuiltins.h:35
SeExpr2::round
double round(double x)
Definition: ExprBuiltins.h:41
SeExpr2::remap
double remap(double x, double source, double range, double falloff, double interp)
Definition: ExprBuiltins.cpp:177
SeExpr2::ExprFunc::Define3
void(* Define3)(const char *name, ExprFunc f, const char *docString)
Definition: ExprFunc.h:65
SeExpr2::defineBuiltins
void defineBuiltins(ExprFunc::Define define, ExprFunc::Define3 define3)
Definition: ExprBuiltins.cpp:1603
SeExpr2::choose
double choose(int n, double *params)
Definition: ExprBuiltins.cpp:1207
SeExpr2::ccellnoise
Vec3d ccellnoise(const Vec3d &p)
Definition: ExprBuiltins.cpp:738
SeExpr2::sind
double sind(double x)
Definition: ExprBuiltins.h:32
SeExpr2::invert
double invert(double x)
Definition: ExprBuiltins.h:46
ExprFunc.h
SeExpr2::tand
double tand(double x)
Definition: ExprBuiltins.h:33
Platform.h
Platform-specific classes, functions, and includes.
SeExpr2::contrast
double contrast(double x, double c)
Definition: ExprBuiltins.cpp:118
SeExpr2::length
double length(const Vec3d &v)
Definition: ExprBuiltins.cpp:1062
SeExpr2::pick
double pick(int n, double *params)
Definition: ExprBuiltins.cpp:1146
y
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float y
Definition: userdoc.txt:218
SeExpr2::bias
double bias(double x, double b)
Definition: ExprBuiltins.cpp:110
SeExpr2::smoothstep
double smoothstep(double x, double a, double b)
Definition: ExprBuiltins.cpp:143
SeExpr2::cosd
double cosd(double x)
Definition: ExprBuiltins.h:31
SeExpr2::dist
double dist(double ax, double ay, double az, double bx, double by, double bz)
Definition: ExprBuiltins.cpp:1052
hiRange
The result is computed int int hiRange
Definition: userdoc.txt:322
SeExpr2
Definition: Context.h:22
loRange
The result is computed int loRange
Definition: userdoc.txt:322
SeExpr2::expand
double expand(double x, double lo, double hi)
Definition: ExprBuiltins.cpp:95
a1
Defined as float g float a1
Definition: userdoc.txt:162
SeExpr2::mix
double mix(double x, double y, double alpha)
Definition: ExprBuiltins.cpp:213
SeExpr2::min
double min(double x, double y)
Definition: ExprBuiltins.h:43
SeExpr2::vturbulence
Vec3d vturbulence(int n, const Vec3d *args)
Definition: ExprBuiltins.cpp:575
SeExpr2::cycle
double cycle(double index, double loRange, double hiRange)
Definition: ExprBuiltins.cpp:1131
SeExpr2::linearstep
double linearstep(double x, double a, double b)
Definition: ExprBuiltins.cpp:131
SeExpr2::cnoise
Vec3d cnoise(const Vec3d &p)
Definition: ExprBuiltins.cpp:521
SeExpr2::cross
Vec3d cross(const Vec3d &a, const Vec3d &b)
Definition: ExprBuiltins.cpp:1088
SeExpr2::clamp
double clamp(double x, double lo, double hi)
Definition: ExprBuiltins.h:40
SeExpr2::max
double max(double x, double y)
Definition: ExprBuiltins.h:42
SeExpr2::initPerlin
void initPerlin()
SeExpr2::midhsi
Vec3d midhsi(int n, const Vec3d *args)
Definition: ExprBuiltins.cpp:247
r
</pre > To parallelize evaluation per a simple parallel_for can be p blocked_range r
Definition: varblocks.txt:76
SeExpr2::snoise
double snoise(const Vec3d &p)
Definition: ExprBuiltins.cpp:501
SeExpr2::hypot
double hypot(double x, double y)
Definition: ExprBuiltins.cpp:1067
SeExpr2::deg
double deg(double angle)
Definition: ExprBuiltins.h:29
a
Defined as a *alpha b *alpha< br ></div >< br > float< b > float a
Definition: userdoc.txt:174
SeExpr2::acosd
double acosd(double x)
Definition: ExprBuiltins.h:34
SeExpr2::fit
double fit(double x, double a1, double b1, double a2, double b2)
Definition: ExprBuiltins.cpp:101
SeExpr2::vnoise
Vec3d vnoise(const Vec3d &p)
Definition: ExprBuiltins.cpp:511
SeExpr2::wchoose
double wchoose(int n, double *params)
Definition: ExprBuiltins.cpp:1219
SeExpr2::Vec3d
Vec< double, 3, false > Vec3d
Definition: Vec.h:384
SeExpr2::fbm
double fbm(int n, const Vec3d *args)
Definition: ExprBuiltins.cpp:601
SeExpr2::gamma
double gamma(double x, double g)
Definition: ExprBuiltins.cpp:107
SeExpr2::rgbtohsl
Vec3d rgbtohsl(const Vec3d &rgb)
Definition: ExprBuiltins.cpp:285
a2
Defined as float g float float float a2
Definition: userdoc.txt:162
SeExpr2::hsltorgb
Vec3d hsltorgb(const Vec3d &hsl)
Definition: ExprBuiltins.cpp:350
p
static const int p[514]
Definition: NoiseTables.h:20
b1
Defined as float g float float b1
Definition: userdoc.txt:162
SeExpr2::ortho
Vec3d ortho(const Vec3d &a, const Vec3d &b)
Definition: ExprBuiltins.cpp:1104
SeExpr2::angle
double angle(const Vec3d &a, const Vec3d &b)
Definition: ExprBuiltins.cpp:1095
SeExpr2::boxstep
double boxstep(double x, double a)
Definition: ExprBuiltins.cpp:128
SeExpr2::ExprFunc::Define
void(* Define)(const char *name, ExprFunc f)
Definition: ExprFunc.h:64
SeExpr2::atand
double atand(double x)
Definition: ExprBuiltins.h:36
SeExpr2::turbulence
double turbulence(int n, const Vec3d *args)
Definition: ExprBuiltins.cpp:551
sin
* 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
SeExpr2::hash
double hash(int n, double *args)
Definition: ExprBuiltins.cpp:409
x
</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
Definition: tutorial.txt:108
b
Between a and b
Definition: userdoc.txt:180
SeExpr2::cellnoise
double cellnoise(const Vec3d &p)
Definition: ExprBuiltins.cpp:727
SeExpr2::gaussstep
double gaussstep(double x, double a, double b)
Definition: ExprBuiltins.cpp:160
SeExpr2::cfbm
Vec3d cfbm(int n, const Vec3d *args)
Definition: ExprBuiltins.cpp:721
SeExpr2::norm
Vec3d norm(const Vec3d &a)
Definition: ExprBuiltins.cpp:1077
SeExpr2::spline
double spline(int n, double *params)
Definition: ExprBuiltins.cpp:1270