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 buildUniformScale;)
48  virtual HOM_Matrix4 *buildUniformScale(double s) = 0;
49 
50  SWIGOUT(%newobject buildShear;)
51  virtual HOM_Matrix4 *buildShear(double sxy, double sxz, double syz) = 0;
52  virtual HOM_Matrix4 *buildShear(const std::vector<double> &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 
60  SWIGOUT(%newobject buildRotateAboutAxis;)
61  virtual HOM_Matrix4 *buildRotateAboutAxis(
62  const std::vector<double> &axis, double angle_in_deg)= 0;
63 
64  SWIGOUT(%newobject buildRotateZToAxis;)
65  virtual HOM_Matrix4 *buildRotateZToAxis(
66  const std::vector<double> &axis) = 0;
67 
68  SWIGOUT(%newobject buildRotateLookAt;)
69  virtual HOM_Matrix4 *buildRotateLookAt(
70  const HOM_Vector3 &_from,
71  const HOM_Vector3 &to,
72  const HOM_Vector3 &up) = 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  SWIGOUT(%newobject _buildTransformTRS;)
82  virtual HOM_Matrix4* _buildTransformTRS(
83  const HOM_Vector3 &translate,
84  const HOM_Vector3 &rotate,
85  const HOM_Vector3 &scale,
86  const char *transform_order="srt",
87  const char *rotate_order="xyz") = 0;
88 
89  SWIGOUT(%newobject _buildTransformTRSS;)
90  virtual HOM_Matrix4* _buildTransformTRSS(
91  const HOM_Vector3 &translate,
92  const HOM_Vector3 &rotate,
93  const HOM_Vector3 &scale,
94  const HOM_Vector3 &shear,
95  const char *transform_order="srt",
96  const char *rotate_order="xyz") = 0;
97 
98  SWIGOUT(%newobject _buildTransformTR;)
99  virtual HOM_Matrix4* _buildTransformTR(
100  const HOM_Vector3 &translate,
101  const HOM_Vector3 &rotate,
102  const char *transform_order="srt",
103  const char *rotate_order="xyz") = 0;
104 
105  SWIGOUT(%newobject _buildTransform;)
106  virtual HOM_Matrix4* _buildTransform(
107  const HOM_Vector3 &translate,
108  const HOM_Vector3 &rotate,
109  const HOM_Vector3 &scale,
110  const HOM_Vector3 &shear,
111  const HOM_Vector3 &pivot,
112  const HOM_Vector3 &pivot_rotate,
113  const char *transform_order="srt",
114  const char *rotate_order="xyz") = 0;
115 
116 
117  virtual double degToRad(double degrees) = 0;
118  virtual double radToDeg(double radians) = 0;
119 
120  virtual double noise1d(const std::vector<double> &pos) const = 0;
121 
122  virtual HOM_Vector3 noise3d(const std::vector<double> &pos) const = 0;
123 
124  double fit(
125  double value, double oldmin, double oldmax,
126  double newmin, double newmax)
127  { return SYSfit(value, oldmin, oldmax, newmin, newmax); }
128 
129  double fit01(double value, double newmin, double newmax)
130  { return SYSfit(value, 0, 1, newmin, newmax); }
131 
132  double fit10(double value, double newmin, double newmax)
133  { return SYSfit(value, 1, 0, newmin, newmax); }
134 
135  double fit11(double value, double newmin, double newmax)
136  { return SYSfit(value, -1, 1, newmin, newmax); }
137 
138  double sign(double value)
139  { return value < 0 ? -1 : (value > 0); }
140 
141  double clamp(double value, double min, double max)
142  { return SYSclamp(value, min, max); }
143 
144  double smooth(double value, double min, double max)
145  {
146  // Caution, the order of the arguments is switched around here
147  return SYSsmooth(min, max, value);
148  }
149 
150  virtual double wrap(double value, double min, double max) const = 0;
151 
152  virtual double rand(double seed) const = 0;
153 
154  virtual double orient2d(
155  const std::vector<double> &pa,
156  const std::vector<double> &pb,
157  const std::vector<double> &point) = 0;
158  virtual double orient3d(
159  const std::vector<double> &pa,
160  const std::vector<double> &pb,
161  const std::vector<double> &pc,
162  const std::vector<double> &point) = 0;
163  virtual double inCircle(
164  const std::vector<double> &pa,
165  const std::vector<double> &pb,
166  const std::vector<double> &pc,
167  const std::vector<double> &point) = 0;
168  virtual double inSphere(
169  const std::vector<double> &pa,
170  const std::vector<double> &pb,
171  const std::vector<double> &pc,
172  const std::vector<double> &pd,
173  const std::vector<double> &point) = 0;
174 
175  virtual HOM_Vector3 intersectPlane(
176  HOM_Vector3 const& plane_point,
177  HOM_Vector3 const& plane_dir,
178  HOM_Vector3 const& line_origin,
179  HOM_Vector3 const& line_dir
180  ) = 0;
181 
182  SWIGOUT(%ignore scaleInheritanceModeForEnumValue;)
183  static UT_ScaleInheritanceMode scaleInheritanceModeForEnumValue(
184  HOM_EnumValue &enum_value);
185  SWIGOUT(%ignore scaleInheritanceModeToEnumValue;)
186  static HOM_EnumValue& scaleInheritanceModeToEnumValue(
188 
189  SWIGOUT(%newobject combineLocalTransform;)
190  SWIGOUT(%kwargs combineLocalTransform;)
191  virtual HOM_Matrix4 *combineLocalTransform(
192  HOM_Matrix4& local,
193  HOM_Matrix4& parent_world,
194  HOM_Matrix4& parent_local,
196 
197  SWIGOUT(%newobject extractLocalTransform;)
198  SWIGOUT(%kwargs extractLocalTransform;)
199  virtual HOM_Matrix4 *extractLocalTransform(
200  HOM_Matrix4& world,
201  HOM_Matrix4& target_parent_world,
202  HOM_Matrix4& target_parent_local,
204  HOM_Matrix4* effective_local = nullptr) = 0;
205 
206 
207  SWIGOUT(%newobject slerpTransforms;)
208  SWIGOUT(%kwargs slerpTransforms;)
209  virtual HOM_Matrix4 *slerpTransforms(
210  const std::vector<HOM_Matrix4>& xforms,
211  const std::vector<double>& input_weights,
212  bool normalize_weigths = true,
213  int slerp_method = 1,
214  int slerp_flip_mehtod = 1) = 0;
215 };
216 
217 #endif
double fit10(double value, double newmin, double newmax)
Definition: HOM_hmath.h:132
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 GLfloat * value
Definition: glcorearb.h:824
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
GLdouble s
Definition: glad.h:3009
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:312
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:144
#define HOM_API
Definition: HOM_API.h:13
double fit11(double value, double newmin, double newmax)
Definition: HOM_hmath.h:135
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:141
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
Definition: UT_Vector3.h:1059
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:124
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:129
double sign(double value)
Definition: HOM_hmath.h:138
PUGI__FN char_t * translate(char_t *buffer, const char_t *from, const char_t *to, size_t to_length)
Definition: pugixml.cpp:8574
UT_ScaleInheritanceMode
Scale inheritance modes.
OIIO_FORCEINLINE OIIO_HOSTDEVICE T radians(T deg)
Convert degrees to radians.
Definition: fmath.h:677
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:681