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 "HOM_Matrix4.h"
20 #include <UT/UT_TransformUtil.h>
21 #include <SYS/SYS_Math.h>
22 #include <vector>
23 #include <map>
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 
43  SWIGOUT(%newobject buildScale;)
44  virtual HOM_Matrix4 *buildScale(double sx, double sy, double sz) = 0;
45  virtual HOM_Matrix4 *buildScale(const std::vector<double> &values) = 0;
46 
47  SWIGOUT(%newobject buildShear;)
48  virtual HOM_Matrix4 *buildShear(double sxy, double sxz, double syz) = 0;
49  virtual HOM_Matrix4 *buildShear(const std::vector<double> &values) = 0;
50 
51  SWIGOUT(%newobject buildRotate;)
52  virtual HOM_Matrix4 *buildRotate(
53  double rx, double ry, double rz, const char *order="xyz") = 0;
54  virtual HOM_Matrix4 *buildRotate(
55  const std::vector<double> &values, const char *order="xyz") = 0;
56 
57  SWIGOUT(%newobject buildRotateAboutAxis;)
58  virtual HOM_Matrix4 *buildRotateAboutAxis(
59  const std::vector<double> &axis, double angle_in_deg)= 0;
60 
61  SWIGOUT(%newobject buildRotateZToAxis;)
62  virtual HOM_Matrix4 *buildRotateZToAxis(
63  const std::vector<double> &axis) = 0;
64 
65  SWIGOUT(%kwargs buildTransform;)
66  SWIGOUT(%newobject buildTransform;)
67  virtual HOM_Matrix4* buildTransform(
68  const std::map<std::string, std::vector<double> > &values_dict,
69  const char *transform_order="srt",
70  const char *rotate_order="xyz") = 0;
71 
72 
73  virtual double degToRad(double degrees) = 0;
74  virtual double radToDeg(double radians) = 0;
75 
76  virtual double noise1d(const std::vector<double> &pos) const = 0;
77 
78  virtual HOM_Vector3 noise3d(const std::vector<double> &pos) const = 0;
79 
80  double fit(
81  double value, double oldmin, double oldmax,
82  double newmin, double newmax)
83  { return SYSfit(value, oldmin, oldmax, newmin, newmax); }
84 
85  double fit01(double value, double newmin, double newmax)
86  { return SYSfit(value, 0, 1, newmin, newmax); }
87 
88  double fit10(double value, double newmin, double newmax)
89  { return SYSfit(value, 1, 0, newmin, newmax); }
90 
91  double fit11(double value, double newmin, double newmax)
92  { return SYSfit(value, -1, 1, newmin, newmax); }
93 
94  double sign(double value)
95  { return value < 0 ? -1 : (value > 0); }
96 
97  double clamp(double value, double min, double max)
98  { return SYSclamp(value, min, max); }
99 
100  double smooth(double value, double min, double max)
101  {
102  // Caution, the order of the arguments is switched around here
103  return SYSsmooth(min, max, value);
104  }
105 
106  virtual double wrap(double value, double min, double max) const = 0;
107 
108  virtual double rand(double seed) const = 0;
109 
110  virtual double orient2d(
111  const std::vector<double> &pa,
112  const std::vector<double> &pb,
113  const std::vector<double> &point) = 0;
114  virtual double orient3d(
115  const std::vector<double> &pa,
116  const std::vector<double> &pb,
117  const std::vector<double> &pc,
118  const std::vector<double> &point) = 0;
119  virtual double inCircle(
120  const std::vector<double> &pa,
121  const std::vector<double> &pb,
122  const std::vector<double> &pc,
123  const std::vector<double> &point) = 0;
124  virtual double inSphere(
125  const std::vector<double> &pa,
126  const std::vector<double> &pb,
127  const std::vector<double> &pc,
128  const std::vector<double> &pd,
129  const std::vector<double> &point) = 0;
130 
131  virtual HOM_Vector3 intersectPlane(
132  HOM_Vector3 const& plane_point,
133  HOM_Vector3 const& plane_dir,
134  HOM_Vector3 const& line_origin,
135  HOM_Vector3 const& line_dir
136  ) = 0;
137 
138  SWIGOUT(%ignore scaleInheritanceModeForEnumValue;)
139  static UT_ScaleInheritanceMode scaleInheritanceModeForEnumValue(
140  HOM_EnumValue &enum_value);
141  SWIGOUT(%ignore scaleInheritanceModeToEnumValue;)
142  static HOM_EnumValue& scaleInheritanceModeToEnumValue(
144 
145  SWIGOUT(%newobject combineLocalTransform;)
146  SWIGOUT(%kwargs combineLocalTransform;)
147  virtual HOM_Matrix4 *combineLocalTransform(
148  HOM_Matrix4& local,
149  HOM_Matrix4& parent_world,
150  HOM_Matrix4& parent_local,
151  HOM_EnumValue& mode = HOM_scaleInheritanceMode::Default) = 0;
152 
153  SWIGOUT(%newobject extractLocalTransform;)
154  SWIGOUT(%kwargs extractLocalTransform;)
155  virtual HOM_Matrix4 *extractLocalTransform(
156  HOM_Matrix4& world,
157  HOM_Matrix4& target_parent_world,
158  HOM_Matrix4& target_parent_local,
159  HOM_EnumValue& mode = HOM_scaleInheritanceMode::Default,
160  HOM_Matrix4* effective_local = nullptr) = 0;
161 
162 
163  SWIGOUT(%newobject slerpTransforms;)
164  SWIGOUT(%kwargs slerpTransforms;)
165  virtual HOM_Matrix4 *slerpTransforms(
166  const std::vector<HOM_Matrix4>& xforms,
167  const std::vector<double>& input_weights,
168  bool normalize_weigths = true,
169  int slerp_method = 1,
170  int slerp_flip_mehtod = 1) = 0;
171 };
172 
173 #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:88
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:100
#define HOM_API
Definition: HOM_API.h:13
double fit11(double value, double newmin, double newmax)
Definition: HOM_hmath.h:91
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:97
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
Definition: UT_Vector3.h:836
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:80
double fit01(double value, double newmin, double newmax)
Definition: HOM_hmath.h:85
double sign(double value)
Definition: HOM_hmath.h:94
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