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(%newobject buildRotateLookAt;)
66  virtual HOM_Matrix4 *buildRotateLookAt(
67  const HOM_Vector3 &_from,
68  const HOM_Vector3 &to,
69  const HOM_Vector3 &up) = 0;
70 
71  SWIGOUT(%kwargs buildTransform;)
72  SWIGOUT(%newobject buildTransform;)
73  virtual HOM_Matrix4* buildTransform(
74  const std::map<std::string, std::vector<double> > &values_dict,
75  const char *transform_order="srt",
76  const char *rotate_order="xyz") = 0;
77 
78  SWIGOUT(%newobject _buildTransformTRS;)
79  virtual HOM_Matrix4* _buildTransformTRS(
80  const HOM_Vector3 &translate,
81  const HOM_Vector3 &rotate,
82  const HOM_Vector3 &scale,
83  const char *transform_order="srt",
84  const char *rotate_order="xyz") = 0;
85 
86  SWIGOUT(%newobject _buildTransformTRSS;)
87  virtual HOM_Matrix4* _buildTransformTRSS(
88  const HOM_Vector3 &translate,
89  const HOM_Vector3 &rotate,
90  const HOM_Vector3 &scale,
91  const HOM_Vector3 &shear,
92  const char *transform_order="srt",
93  const char *rotate_order="xyz") = 0;
94 
95  SWIGOUT(%newobject _buildTransformTR;)
96  virtual HOM_Matrix4* _buildTransformTR(
97  const HOM_Vector3 &translate,
98  const HOM_Vector3 &rotate,
99  const char *transform_order="srt",
100  const char *rotate_order="xyz") = 0;
101 
102  SWIGOUT(%newobject _buildTransform;)
103  virtual HOM_Matrix4* _buildTransform(
104  const HOM_Vector3 &translate,
105  const HOM_Vector3 &rotate,
106  const HOM_Vector3 &scale,
107  const HOM_Vector3 &shear,
108  const HOM_Vector3 &pivot,
109  const HOM_Vector3 &pivot_rotate,
110  const char *transform_order="srt",
111  const char *rotate_order="xyz") = 0;
112 
113 
114  virtual double degToRad(double degrees) = 0;
115  virtual double radToDeg(double radians) = 0;
116 
117  virtual double noise1d(const std::vector<double> &pos) const = 0;
118 
119  virtual HOM_Vector3 noise3d(const std::vector<double> &pos) const = 0;
120 
121  double fit(
122  double value, double oldmin, double oldmax,
123  double newmin, double newmax)
124  { return SYSfit(value, oldmin, oldmax, newmin, newmax); }
125 
126  double fit01(double value, double newmin, double newmax)
127  { return SYSfit(value, 0, 1, newmin, newmax); }
128 
129  double fit10(double value, double newmin, double newmax)
130  { return SYSfit(value, 1, 0, newmin, newmax); }
131 
132  double fit11(double value, double newmin, double newmax)
133  { return SYSfit(value, -1, 1, newmin, newmax); }
134 
135  double sign(double value)
136  { return value < 0 ? -1 : (value > 0); }
137 
138  double clamp(double value, double min, double max)
139  { return SYSclamp(value, min, max); }
140 
141  double smooth(double value, double min, double max)
142  {
143  // Caution, the order of the arguments is switched around here
144  return SYSsmooth(min, max, value);
145  }
146 
147  virtual double wrap(double value, double min, double max) const = 0;
148 
149  virtual double rand(double seed) const = 0;
150 
151  virtual double orient2d(
152  const std::vector<double> &pa,
153  const std::vector<double> &pb,
154  const std::vector<double> &point) = 0;
155  virtual double orient3d(
156  const std::vector<double> &pa,
157  const std::vector<double> &pb,
158  const std::vector<double> &pc,
159  const std::vector<double> &point) = 0;
160  virtual double inCircle(
161  const std::vector<double> &pa,
162  const std::vector<double> &pb,
163  const std::vector<double> &pc,
164  const std::vector<double> &point) = 0;
165  virtual double inSphere(
166  const std::vector<double> &pa,
167  const std::vector<double> &pb,
168  const std::vector<double> &pc,
169  const std::vector<double> &pd,
170  const std::vector<double> &point) = 0;
171 
172  virtual HOM_Vector3 intersectPlane(
173  HOM_Vector3 const& plane_point,
174  HOM_Vector3 const& plane_dir,
175  HOM_Vector3 const& line_origin,
176  HOM_Vector3 const& line_dir
177  ) = 0;
178 
179  SWIGOUT(%ignore scaleInheritanceModeForEnumValue;)
180  static UT_ScaleInheritanceMode scaleInheritanceModeForEnumValue(
181  HOM_EnumValue &enum_value);
182  SWIGOUT(%ignore scaleInheritanceModeToEnumValue;)
183  static HOM_EnumValue& scaleInheritanceModeToEnumValue(
185 
186  SWIGOUT(%newobject combineLocalTransform;)
187  SWIGOUT(%kwargs combineLocalTransform;)
188  virtual HOM_Matrix4 *combineLocalTransform(
189  HOM_Matrix4& local,
190  HOM_Matrix4& parent_world,
191  HOM_Matrix4& parent_local,
193 
194  SWIGOUT(%newobject extractLocalTransform;)
195  SWIGOUT(%kwargs extractLocalTransform;)
196  virtual HOM_Matrix4 *extractLocalTransform(
197  HOM_Matrix4& world,
198  HOM_Matrix4& target_parent_world,
199  HOM_Matrix4& target_parent_local,
201  HOM_Matrix4* effective_local = nullptr) = 0;
202 
203 
204  SWIGOUT(%newobject slerpTransforms;)
205  SWIGOUT(%kwargs slerpTransforms;)
206  virtual HOM_Matrix4 *slerpTransforms(
207  const std::vector<HOM_Matrix4>& xforms,
208  const std::vector<double>& input_weights,
209  bool normalize_weigths = true,
210  int slerp_method = 1,
211  int slerp_flip_mehtod = 1) = 0;
212 };
213 
214 #endif
double fit10(double value, double newmin, double newmax)
Definition: HOM_hmath.h:129
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:349
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:141
#define HOM_API
Definition: HOM_API.h:13
double fit11(double value, double newmin, double newmax)
Definition: HOM_hmath.h:132
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:138
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:121
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
GA_API const UT_StringHolder up
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:126
double sign(double value)
Definition: HOM_hmath.h:135
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