Blender  V2.93
BCMath.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #pragma once
22 
23 #include "BlenderTypes.h"
24 
25 #include "BKE_object.h"
26 
27 #include "BLI_math.h"
28 
29 class BCQuat {
30  private:
31  mutable Quat q;
32 
33  public:
34  BCQuat(const BCQuat &other)
35  {
36  copy_v4_v4(q, other.q);
37  }
38 
39  BCQuat(Quat &other)
40  {
41  copy_v4_v4(q, other);
42  }
43 
45  {
46  unit_qt(q);
47  }
48 
49  Quat &quat()
50  {
51  return q;
52  }
53 
54  void rotate_to(Matrix &mat_to);
55 };
56 
57 class BCMatrix {
58 
59  private:
60  mutable float matrix[4][4];
61  mutable float size[3];
62  mutable float rot[3];
63  mutable float loc[3];
64  mutable float q[4];
65 
66  void unit();
67  void copy(Matrix &r, Matrix &a);
68 
69  public:
70  float (&location() const)[3];
71  float (&rotation() const)[3];
72  float (&scale() const)[3];
73  float (&quat() const)[4];
74 
75  BCMatrix(BC_global_forward_axis global_forward_axis, BC_global_up_axis global_up_axis);
76  BCMatrix(const BCMatrix &mat);
77  BCMatrix(Matrix &mat);
78  BCMatrix(Object *ob);
79  BCMatrix();
80 
81  void get_matrix(DMatrix &matrix, const bool transposed = false, const int precision = -1) const;
82  void get_matrix(Matrix &matrix,
83  const bool transposed = false,
84  const int precision = -1,
85  const bool inverted = false) const;
86  void set_transform(Object *ob);
87  void set_transform(Matrix &mat);
88  void add_transform(Matrix &to,
89  const Matrix &transform,
90  const Matrix &from,
91  const bool inverted = false);
92  void apply_transform(Matrix &to,
93  const Matrix &transform,
94  const Matrix &from,
95  const bool inverse = false);
96  void add_inverted_transform(Matrix &to, const Matrix &transform, const Matrix &from);
97  void add_transform(const Matrix &matrix, const bool inverted = false);
98  void add_transform(const BCMatrix &matrix, const bool inverted = false);
99  void apply_transform(const BCMatrix &matrix, const bool inverted = false);
100 
101  bool in_range(const BCMatrix &other, float distance) const;
102 
103  static void sanitize(Matrix &matrix, int precision);
104  static void sanitize(DMatrix &matrix, int precision);
105  static void transpose(Matrix &matrix);
106 };
typedef float(TangentPoint)[2]
General operations, lookup, etc. for blender objects.
void unit_qt(float q[4])
Definition: math_rotation.c:46
MINLINE void copy_v4_v4(float r[4], const float a[4])
BC_global_up_axis
Definition: BlenderTypes.h:38
BC_global_forward_axis
Definition: BlenderTypes.h:29
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
btMatrix3x3 inverse() const
Return the inverse of the matrix.
Definition: btTransform.h:182
static void transpose(Matrix &matrix)
Definition: BCMath.cpp:153
void apply_transform(Matrix &to, const Matrix &transform, const Matrix &from, const bool inverse=false)
Definition: BCMath.cpp:106
void get_matrix(DMatrix &matrix, const bool transposed=false, const int precision=-1) const
Definition: BCMath.cpp:187
float(& rotation() const)[3]
Definition: BCMath.cpp:237
void add_inverted_transform(Matrix &to, const Matrix &transform, const Matrix &from)
Definition: BCMath.cpp:122
void set_transform(Object *ob)
Definition: BCMath.cpp:129
float(& scale() const)[3]
Definition: BCMath.cpp:242
float(& location() const)[3]
Definition: BCMath.cpp:232
float(& quat() const)[4]
Definition: BCMath.cpp:247
BCMatrix()
Definition: BCMath.cpp:58
void add_transform(Matrix &to, const Matrix &transform, const Matrix &from, const bool inverted=false)
Definition: BCMath.cpp:91
static void sanitize(Matrix &matrix, int precision)
Definition: BCMath.cpp:158
bool in_range(const BCMatrix &other, float distance) const
Definition: BCMath.cpp:220
Definition: BCMath.h:29
void rotate_to(Matrix &mat_to)
Definition: BCMath.cpp:25
BCQuat(const BCQuat &other)
Definition: BCMath.h:34
BCQuat(Quat &other)
Definition: BCMath.h:39
BCQuat()
Definition: BCMath.h:44
Quat & quat()
Definition: BCMath.h:49
StackEntry * from
static unsigned a[3]
Definition: RandGen.cpp:92
ccl_device_inline float distance(const float2 &a, const float2 &b)