HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_hmath.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  * This "submodule" is named hou.hmath instead of hou.math to prevent
8  * conflicts with the python math module, since expression evaluation
9  * contexts have run from hou import *.
10  */
11 
12 #ifndef __HOM_hmath_h__
13 #define __HOM_hmath_h__
14 
15 #include "HOM_API.h"
16 #include "HOM_Defines.h"
17 #include "HOM_EnumModules.h"
18 #include "HOM_Errors.h"
19 #include <UT/UT_TransformUtil.h>
20 #include <SYS/SYS_Math.h>
21 #include <vector>
22 #include <map>
23 class HOM_Matrix4;
24 class HOM_Vector3;
25 
26 SWIGOUT(%rename(hmath) HOM_hmath;)
27 
29 {
30 public:
31  virtual ~HOM_hmath()
32  {}
33 
34  virtual std::string __repr__() = 0;
35 
36  SWIGOUT(%newobject identityTransform;)
37  virtual HOM_Matrix4 *identityTransform() = 0;
38 
39  SWIGOUT(%newobject buildTranslate;)
40  virtual HOM_Matrix4 *buildTranslate(double tx, double ty, double tz) = 0;
41  virtual HOM_Matrix4 *buildTranslate(const std::vector<double> &values) = 0;
42  virtual HOM_Matrix4 *buildTranslate(HOM_Vector3 &values) = 0;
43 
44  SWIGOUT(%newobject buildScale;)
45  virtual HOM_Matrix4 *buildScale(double sx, double sy, double sz) = 0;
46  virtual HOM_Matrix4 *buildScale(const std::vector<double> &values) = 0;
47  virtual HOM_Matrix4 *buildScale(HOM_Vector3 &values) = 0;
48 
49  SWIGOUT(%newobject buildShear;)
50  virtual HOM_Matrix4 *buildShear(double sxy, double sxz, double syz) = 0;
51  virtual HOM_Matrix4 *buildShear(const std::vector<double> &values) = 0;
52  virtual HOM_Matrix4 *buildShear(HOM_Vector3 &values) = 0;
53 
54  SWIGOUT(%newobject buildRotate;)
55  virtual HOM_Matrix4 *buildRotate(
56  double rx, double ry, double rz, const char *order="xyz") = 0;
57  virtual HOM_Matrix4 *buildRotate(
58  const std::vector<double> &values, const char *order="xyz") = 0;
59  virtual HOM_Matrix4 *buildRotate(
60  HOM_Vector3 &values, const char *order="xyz") = 0;
61 
62  SWIGOUT(%newobject buildRotateAboutAxis;)
63  virtual HOM_Matrix4 *buildRotateAboutAxis(
64  const std::vector<double> &axis, double angle_in_deg)= 0;
65  virtual HOM_Matrix4 *buildRotateAboutAxis(
66  HOM_Vector3 &axis, double angle_in_deg) = 0;
67 
68  SWIGOUT(%newobject buildRotateZToAxis;)
69  virtual HOM_Matrix4 *buildRotateZToAxis(
70  const std::vector<double> &axis) = 0;
71  virtual HOM_Matrix4 *buildRotateZToAxis(
72  HOM_Vector3 &axis) = 0;
73 
74  SWIGOUT(%kwargs buildTransform;)
75  SWIGOUT(%newobject buildTransform;)
76  virtual HOM_Matrix4* buildTransform(
77  const std::map<std::string, std::vector<double> > &values_dict,
78  const char *transform_order="srt",
79  const char *rotate_order="xyz") = 0;
80 
81 
82  virtual double degToRad(double degrees) = 0;
83  virtual double radToDeg(double radians) = 0;
84 
85  virtual double noise1d(const std::vector<double> &pos) const = 0;
86 
87  virtual HOM_Vector3 noise3d(const std::vector<double> &pos) const = 0;
88 
89  double fit(
90  double value, double oldmin, double oldmax,
91  double newmin, double newmax)
92  { return SYSfit(value, oldmin, oldmax, newmin, newmax); }
93 
94  double fit01(double value, double newmin, double newmax)
95  { return SYSfit(value, 0, 1, newmin, newmax); }
96 
97  double fit10(double value, double newmin, double newmax)
98  { return SYSfit(value, 1, 0, newmin, newmax); }
99 
100  double fit11(double value, double newmin, double newmax)
101  { return SYSfit(value, -1, 1, newmin, newmax); }
102 
103  double sign(double value)
104  { return value < 0 ? -1 : (value > 0); }
105 
106  double clamp(double value, double min, double max)
107  { return SYSclamp(value, min, max); }
108 
109  double smooth(double value, double min, double max)
110  {
111  // Caution, the order of the arguments is switched around here
112  return SYSsmooth(min, max, value);
113  }
114 
115  virtual double wrap(double value, double min, double max) const = 0;
116 
117  virtual double rand(double seed) const = 0;
118 
119  virtual double orient2d(
120  const std::vector<double> &pa,
121  const std::vector<double> &pb,
122  const std::vector<double> &point) = 0;
123  virtual double orient3d(
124  const std::vector<double> &pa,
125  const std::vector<double> &pb,
126  const std::vector<double> &pc,
127  const std::vector<double> &point) = 0;
128  virtual double inCircle(
129  const std::vector<double> &pa,
130  const std::vector<double> &pb,
131  const std::vector<double> &pc,
132  const std::vector<double> &point) = 0;
133  virtual double inSphere(
134  const std::vector<double> &pa,
135  const std::vector<double> &pb,
136  const std::vector<double> &pc,
137  const std::vector<double> &pd,
138  const std::vector<double> &point) = 0;
139 
140  virtual HOM_Vector3 intersectPlane(
141  HOM_Vector3 const& plane_point,
142  HOM_Vector3 const& plane_dir,
143  HOM_Vector3 const& line_origin,
144  HOM_Vector3 const& line_dir
145  ) = 0;
146 
147  SWIGOUT(%ignore scaleInheritanceModeForEnumValue;)
148  static UT_ScaleInheritanceMode scaleInheritanceModeForEnumValue(
149  HOM_EnumValue &enum_value);
150  SWIGOUT(%ignore scaleInheritanceModeToEnumValue;)
151  static HOM_EnumValue& scaleInheritanceModeToEnumValue(
153 
154  SWIGOUT(%newobject combineLocalTransform;)
155  SWIGOUT(%kwargs combineLocalTransform;)
156  virtual HOM_Matrix4 *combineLocalTransform(
157  HOM_Matrix4& local,
158  HOM_Matrix4& parent_world,
159  HOM_Matrix4& parent_local,
160  HOM_EnumValue& mode = HOM_scaleInheritanceMode::Default) = 0;
161 
162  SWIGOUT(%newobject extractLocalTransform;)
163  SWIGOUT(%kwargs extractLocalTransform;)
164  virtual HOM_Matrix4 *extractLocalTransform(
165  HOM_Matrix4& world,
166  HOM_Matrix4& target_parent_world,
167  HOM_Matrix4& target_parent_local,
168  HOM_EnumValue& mode = HOM_scaleInheritanceMode::Default,
169  HOM_Matrix4* effective_local = nullptr) = 0;
170 };
171 
172 #endif
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
double fit10(double value, double newmin, double newmax)
Definition: HOM_hmath.h:97
GLenum mode
Definition: glew.h:2163
OIIO_HOSTDEVICE T radians(T deg)
Convert degrees to radians.
Definition: fmath.h:525
OIIO_API bool rename(string_view from, string_view to, std::string &err)
GLint GLsizei const GLuint64 * values
Definition: glew.h:3612
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:349
GLuint GLdouble GLdouble GLint GLint order
Definition: glew.h:3446
double smooth(double value, double min, double max)
Definition: HOM_hmath.h:109
#define HOM_API
Definition: HOM_API.h:13
double fit11(double value, double newmin, double newmax)
Definition: HOM_hmath.h:100
SYS_FORCE_INLINE REAL orient3d(const REAL pa[3], const REAL pb[3], const REAL pc[3], const REAL pd[3])
double clamp(double value, double min, double max)
Definition: HOM_hmath.h:106
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
Definition: UT_Vector3.h:820
OIIO_HOSTDEVICE T degrees(T rad)
Convert radians to degrees.
Definition: fmath.h:529
GLsizei const GLchar *const * string
Definition: glew.h:1844
double fit(double value, double oldmin, double oldmax, double newmin, double newmax)
Definition: HOM_hmath.h:89
double fit01(double value, double newmin, double newmax)
Definition: HOM_hmath.h:94
double sign(double value)
Definition: HOM_hmath.h:103
vint4 min(const vint4 &a, const vint4 &b)
Definition: simd.h:4694
UT_ScaleInheritanceMode
Scale inheritance modes.
SYS_FORCE_INLINE REAL orient2d(const REAL pa[2], const REAL pb[2], const REAL pc[2])
GLsizei const GLfloat * value
Definition: glew.h:1849
virtual ~HOM_hmath()
Definition: HOM_hmath.h:31