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
24namespace SeExpr2 {
25
27
28// trig
29inline double deg(double angle) { return angle * (180 / M_PI); }
30inline double rad(double angle) { return angle * (M_PI / 180); }
31inline double cosd(double x) { return cos(rad(x)); }
32inline double sind(double x) { return sin(rad(x)); }
33inline double tand(double x) { return tan(rad(x)); }
34inline double acosd(double x) { return deg(acos(x)); }
35inline double asind(double x) { return deg(asin(x)); }
36inline double atand(double x) { return deg(atan(x)); }
37inline double atan2d(double y, double x) { return deg(atan2(y, x)); }
38
39// clamping
40inline double clamp(double x, double lo, double hi) { return x < lo ? lo : x > hi ? hi : x; }
41inline double round(double x) { return x < 0 ? ceil(x - 0.5) : floor(x + 0.5); }
42inline double max(double x, double y) { return x > y ? x : y; }
43inline double min(double x, double y) { return x < y ? x : y; }
44
45// blending / remapping
46inline double invert(double x) { return 1 - x; }
47double compress(double x, double lo, double hi);
48double expand(double x, double lo, double hi);
49double fit(double x, double a1, double b1, double a2, double b2);
50double gamma(double x, double g);
51double bias(double x, double b);
52double contrast(double x, double c);
53double boxstep(double x, double a);
54double linearstep(double x, double a, double b);
55double smoothstep(double x, double a, double b);
56double gaussstep(double x, double a, double b);
57double remap(double x, double s, double r, double f, double interp);
58double mix(double x, double y, double alpha);
59Vec3d hsi(int n, const Vec3d* args);
60Vec3d midhsi(int n, const Vec3d* args);
61Vec3d rgbtohsl(const Vec3d& rgb);
62Vec3d hsltorgb(const Vec3d& hsl);
63
64// noise
65double hash(int n, double* args);
66double noise(int n, const Vec3d* args);
67double snoise(const Vec3d& p);
68Vec3d cnoise(const Vec3d& p);
69Vec3d vnoise(const Vec3d& p);
70double turbulence(int n, const Vec3d* args);
71Vec3d vturbulence(int n, const Vec3d* args);
72Vec3d cturbulence(int n, const Vec3d* args);
73double fbm(int n, const Vec3d* args);
74Vec3d vfbm(int n, const Vec3d* args);
75Vec3d cfbm(int n, const Vec3d* args);
76double cellnoise(const Vec3d& p);
77Vec3d ccellnoise(const Vec3d& p);
78double pnoise(const Vec3d& p, const Vec3d& period);
79
80// vectors
81double dist(double ax, double ay, double az, double bx, double by, double bz);
82double length(const Vec3d& v);
83double hypot(double x, double y);
84double dot(const Vec3d& a, const Vec3d& b);
85Vec3d norm(const Vec3d& a);
86Vec3d cross(const Vec3d& a, const Vec3d& b);
87double angle(const Vec3d& a, const Vec3d& b);
88Vec3d ortho(const Vec3d& a, const Vec3d& b);
89Vec3d up(const Vec3d& vec, const Vec3d& upvec);
90
91// variations
92double cycle(double index, double loRange, double hiRange);
93double pick(int n, double* params);
94double choose(int n, double* params);
95double wchoose(int n, double* params);
96double spline(int n, double* params);
97
98// add builtins to expression function table
100}
101
102#endif
Platform-specific classes, functions, and includes.
void(* Define)(const char *name, ExprFunc f)
Definition: ExprFunc.h:64
void(* Define3)(const char *name, ExprFunc f, const char *docString)
Definition: ExprFunc.h:65
Vec3d ortho(const Vec3d &a, const Vec3d &b)
Vec3d norm(const Vec3d &a)
double rad(double angle)
Definition: ExprBuiltins.h:30
Vec< double, 3, false > Vec3d
Definition: Vec.h:384
double atan2d(double y, double x)
Definition: ExprBuiltins.h:37
Vec3d up(const Vec3d &P, const Vec3d &upvec)
void defineBuiltins(ExprFunc::Define define, ExprFunc::Define3 define3)
double hypot(double x, double y)
double boxstep(double x, double a)
double tand(double x)
Definition: ExprBuiltins.h:33
Vec3d vnoise(const Vec3d &p)
double cosd(double x)
Definition: ExprBuiltins.h:31
double bias(double x, double b)
double sind(double x)
Definition: ExprBuiltins.h:32
Vec3d cnoise(const Vec3d &p)
double contrast(double x, double c)
double smoothstep(double x, double a, double b)
double dot(const Vec3d &a, const Vec3d &b)
double angle(const Vec3d &a, const Vec3d &b)
Vec3d rgbtohsl(const Vec3d &rgb)
double deg(double angle)
Definition: ExprBuiltins.h:29
Vec3d vturbulence(int n, const Vec3d *args)
double round(double x)
Definition: ExprBuiltins.h:41
double mix(double x, double y, double alpha)
Vec3d hsi(int n, const Vec3d *args)
Vec3d cturbulence(int n, const Vec3d *args)
double linearstep(double x, double a, double b)
Vec3d hsltorgb(const Vec3d &hsl)
void initPerlin()
double wchoose(int n, double *params)
double dist(double ax, double ay, double az, double bx, double by, double bz)
double length(const Vec3d &v)
double noise(int n, const Vec3d *args)
double fbm(int n, const Vec3d *args)
Vec3d midhsi(int n, const Vec3d *args)
double gaussstep(double x, double a, double b)
double hash(int n, double *args)
Vec3d ccellnoise(const Vec3d &p)
double invert(double x)
Definition: ExprBuiltins.h:46
double turbulence(int n, const Vec3d *args)
Vec3d cfbm(int n, const Vec3d *args)
double max(double x, double y)
Definition: ExprBuiltins.h:42
Vec3d vfbm(int n, const Vec3d *args)
double compress(double x, double lo, double hi)
double pnoise(const Vec3d &p, const Vec3d &period)
double acosd(double x)
Definition: ExprBuiltins.h:34
Vec3d cross(const Vec3d &a, const Vec3d &b)
double clamp(double x, double lo, double hi)
Definition: ExprBuiltins.h:40
double min(double x, double y)
Definition: ExprBuiltins.h:43
double fit(double x, double a1, double b1, double a2, double b2)
double expand(double x, double lo, double hi)
double gamma(double x, double g)
double cellnoise(const Vec3d &p)
double snoise(const Vec3d &p)
double atand(double x)
Definition: ExprBuiltins.h:36
double asind(double x)
Definition: ExprBuiltins.h:35
* 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
</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
For< b ></b >< b ></b >< b > cycle
Definition: userdoc.txt:443
The result is computed int loRange
Definition: userdoc.txt:322
For< b ></b >< b ></b >< b ></b >< b > spline
Definition: userdoc.txt:443
Defined as float g float a1
Definition: userdoc.txt:162
For< b ></b >< b > choose
Definition: userdoc.txt:443
The result is computed int int hiRange
Definition: userdoc.txt:322
Defined as float g float float b1
Definition: userdoc.txt:162
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
Defined as float g float float float a2
Definition: userdoc.txt:162
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
For< b > pick
Definition: userdoc.txt:443
</pre > To parallelize evaluation per a simple parallel_for can be p blocked_range r
Definition: varblocks.txt:76
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