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  SWIGOUT(%kwargs buildTransform;)
65  SWIGOUT(%newobject buildTransform;)
66  virtual HOM_Matrix4* buildTransform(
67  const std::map<std::string, std::vector<double> > &values_dict,
68  const char *transform_order="srt",
69  const char *rotate_order="xyz") = 0;
70 
71  SWIGOUT(%newobject _buildTransformTRS;)
72  virtual HOM_Matrix4* _buildTransformTRS(
73  const HOM_Vector3 &translate,
74  const HOM_Vector3 &rotate,
75  const HOM_Vector3 &scale,
76  const char *transform_order="srt",
77  const char *rotate_order="xyz") = 0;
78 
79  SWIGOUT(%newobject _buildTransformTRSS;)
80  virtual HOM_Matrix4* _buildTransformTRSS(
81  const HOM_Vector3 &translate,
82  const HOM_Vector3 &rotate,
83  const HOM_Vector3 &scale,
84  const HOM_Vector3 &shear,
85  const char *transform_order="srt",
86  const char *rotate_order="xyz") = 0;
87 
88  SWIGOUT(%newobject _buildTransformTR;)
89  virtual HOM_Matrix4* _buildTransformTR(
90  const HOM_Vector3 &translate,
91  const HOM_Vector3 &rotate,
92  const char *transform_order="srt",
93  const char *rotate_order="xyz") = 0;
94 
95  SWIGOUT(%newobject _buildTransform;)
96  virtual HOM_Matrix4* _buildTransform(
97  const HOM_Vector3 &translate,
98  const HOM_Vector3 &rotate,
99  const HOM_Vector3 &scale,
100  const HOM_Vector3 &shear,
101  const HOM_Vector3 &pivot,
102  const HOM_Vector3 &pivot_rotate,
103  const char *transform_order="srt",
104  const char *rotate_order="xyz") = 0;
105 
106 
107  virtual double degToRad(double degrees) = 0;
108  virtual double radToDeg(double radians) = 0;
109 
110  virtual double noise1d(const std::vector<double> &pos) const = 0;
111 
112  virtual HOM_Vector3 noise3d(const std::vector<double> &pos) const = 0;
113 
114  double fit(
115  double value, double oldmin, double oldmax,
116  double newmin, double newmax)
117  { return SYSfit(value, oldmin, oldmax, newmin, newmax); }
118 
119  double fit01(double value, double newmin, double newmax)
120  { return SYSfit(value, 0, 1, newmin, newmax); }
121 
122  double fit10(double value, double newmin, double newmax)
123  { return SYSfit(value, 1, 0, newmin, newmax); }
124 
125  double fit11(double value, double newmin, double newmax)
126  { return SYSfit(value, -1, 1, newmin, newmax); }
127 
128  double sign(double value)
129  { return value < 0 ? -1 : (value > 0); }
130 
131  double clamp(double value, double min, double max)
132  { return SYSclamp(value, min, max); }
133 
134  double smooth(double value, double min, double max)
135  {
136  // Caution, the order of the arguments is switched around here
137  return SYSsmooth(min, max, value);
138  }
139 
140  virtual double wrap(double value, double min, double max) const = 0;
141 
142  virtual double rand(double seed) const = 0;
143 
144  virtual double orient2d(
145  const std::vector<double> &pa,
146  const std::vector<double> &pb,
147  const std::vector<double> &point) = 0;
148  virtual double orient3d(
149  const std::vector<double> &pa,
150  const std::vector<double> &pb,
151  const std::vector<double> &pc,
152  const std::vector<double> &point) = 0;
153  virtual double inCircle(
154  const std::vector<double> &pa,
155  const std::vector<double> &pb,
156  const std::vector<double> &pc,
157  const std::vector<double> &point) = 0;
158  virtual double inSphere(
159  const std::vector<double> &pa,
160  const std::vector<double> &pb,
161  const std::vector<double> &pc,
162  const std::vector<double> &pd,
163  const std::vector<double> &point) = 0;
164 
165  virtual HOM_Vector3 intersectPlane(
166  HOM_Vector3 const& plane_point,
167  HOM_Vector3 const& plane_dir,
168  HOM_Vector3 const& line_origin,
169  HOM_Vector3 const& line_dir
170  ) = 0;
171 
172  SWIGOUT(%ignore scaleInheritanceModeForEnumValue;)
173  static UT_ScaleInheritanceMode scaleInheritanceModeForEnumValue(
174  HOM_EnumValue &enum_value);
175  SWIGOUT(%ignore scaleInheritanceModeToEnumValue;)
176  static HOM_EnumValue& scaleInheritanceModeToEnumValue(
178 
179  SWIGOUT(%newobject combineLocalTransform;)
180  SWIGOUT(%kwargs combineLocalTransform;)
181  virtual HOM_Matrix4 *combineLocalTransform(
182  HOM_Matrix4& local,
183  HOM_Matrix4& parent_world,
184  HOM_Matrix4& parent_local,
185  HOM_EnumValue& mode = HOM_scaleInheritanceMode::Default) = 0;
186 
187  SWIGOUT(%newobject extractLocalTransform;)
188  SWIGOUT(%kwargs extractLocalTransform;)
189  virtual HOM_Matrix4 *extractLocalTransform(
190  HOM_Matrix4& world,
191  HOM_Matrix4& target_parent_world,
192  HOM_Matrix4& target_parent_local,
193  HOM_EnumValue& mode = HOM_scaleInheritanceMode::Default,
194  HOM_Matrix4* effective_local = nullptr) = 0;
195 
196 
197  SWIGOUT(%newobject slerpTransforms;)
198  SWIGOUT(%kwargs slerpTransforms;)
199  virtual HOM_Matrix4 *slerpTransforms(
200  const std::vector<HOM_Matrix4>& xforms,
201  const std::vector<double>& input_weights,
202  bool normalize_weigths = true,
203  int slerp_method = 1,
204  int slerp_flip_mehtod = 1) = 0;
205 };
206 
207 #endif
double fit10(double value, double newmin, double newmax)
Definition: HOM_hmath.h:122
MatType shear(Axis axis0, Axis axis1, typename MatType::value_type shear)
Set the matrix to a shear along axis0 by a fraction of axis1.
Definition: Mat.h:688
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:352
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GA_API const UT_StringHolder scale
double smooth(double value, double min, double max)
Definition: HOM_hmath.h:134
#define HOM_API
Definition: HOM_API.h:13
double fit11(double value, double newmin, double newmax)
Definition: HOM_hmath.h:125
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
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:131
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
Definition: UT_Vector3.h:1057
GLdouble GLdouble GLint GLint order
Definition: glad.h:2676
ImageBuf OIIO_API rotate(const ImageBuf &src, float angle, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ROI roi={}, int nthreads=0)
GLenum mode
Definition: glcorearb.h:99
double fit(double value, double oldmin, double oldmax, double newmin, double newmax)
Definition: HOM_hmath.h:114
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GA_API const UT_StringHolder pivot
double fit01(double value, double newmin, double newmax)
Definition: HOM_hmath.h:119
double sign(double value)
Definition: HOM_hmath.h:128
Definition: core.h:1131
PUGI__FN char_t * translate(char_t *buffer, const char_t *from, const char_t *to, size_t to_length)
Definition: pugixml.cpp:8352
UT_ScaleInheritanceMode
Scale inheritance modes.
OIIO_FORCEINLINE OIIO_HOSTDEVICE T radians(T deg)
Convert degrees to radians.
Definition: fmath.h:669
SYS_FORCE_INLINE REAL orient2d(const REAL pa[2], const REAL pb[2], const REAL pc[2])
virtual ~HOM_hmath()
Definition: HOM_hmath.h:31
OIIO_FORCEINLINE OIIO_HOSTDEVICE T degrees(T rad)
Convert radians to degrees.
Definition: fmath.h:673