Blender  V3.3
BCMath.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include "BlenderTypes.h"
10 
11 #include "BKE_object.h"
12 
13 #include "BLI_math.h"
14 
15 class BCQuat {
16  private:
17  mutable Quat q;
18 
19  public:
20  BCQuat(const BCQuat &other)
21  {
22  copy_v4_v4(q, other.q);
23  }
24 
25  BCQuat(Quat &other)
26  {
27  copy_v4_v4(q, other);
28  }
29 
31  {
32  unit_qt(q);
33  }
34 
35  Quat &quat()
36  {
37  return q;
38  }
39 
40  void rotate_to(Matrix &mat_to);
41 };
42 
43 class BCMatrix {
44 
45  private:
46  mutable float matrix[4][4];
47  mutable float size[3];
48  mutable float rot[3];
49  mutable float loc[3];
50  mutable float q[4];
51 
52  void unit();
53  void copy(Matrix &r, Matrix &a);
54 
55  public:
56  float (&location() const)[3];
57  float (&rotation() const)[3];
58  float (&scale() const)[3];
59  float (&quat() const)[4];
60 
61  BCMatrix(BC_global_forward_axis global_forward_axis, BC_global_up_axis global_up_axis);
62  BCMatrix(const BCMatrix &mat);
63  BCMatrix(Matrix &mat);
64  BCMatrix(Object *ob);
65  BCMatrix();
66 
71  void get_matrix(DMatrix &matrix, bool transposed = false, int precision = -1) const;
72  void get_matrix(Matrix &matrix,
73  bool transposed = false,
74  int precision = -1,
75  bool inverted = false) const;
76  void set_transform(Object *ob);
77  void set_transform(Matrix &mat);
78  void add_transform(Matrix &to,
79  const Matrix &transform,
80  const Matrix &from,
81  bool inverted = false);
82  void apply_transform(Matrix &to,
83  const Matrix &transform,
84  const Matrix &from,
85  bool inverse = false);
86  void add_inverted_transform(Matrix &to, const Matrix &transform, const Matrix &from);
87  void add_transform(const Matrix &matrix, bool inverted = false);
88  void add_transform(const BCMatrix &matrix, bool inverted = false);
89  void apply_transform(const BCMatrix &matrix, bool inverted = false);
90 
91  bool in_range(const BCMatrix &other, float distance) const;
92 
93  static void sanitize(Matrix &matrix, int precision);
94  static void sanitize(DMatrix &matrix, int precision);
95  static void transpose(Matrix &matrix);
96 };
typedef float(TangentPoint)[2]
General operations, lookup, etc. for blender objects.
void unit_qt(float q[4])
Definition: math_rotation.c:27
MINLINE void copy_v4_v4(float r[4], const float a[4])
BC_global_up_axis
Definition: BlenderTypes.h:24
BC_global_forward_axis
Definition: BlenderTypes.h:15
_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:134
float(& rotation() const)[3]
Definition: BCMath.cpp:216
void add_transform(Matrix &to, const Matrix &transform, const Matrix &from, bool inverted=false)
Definition: BCMath.cpp:72
void add_inverted_transform(Matrix &to, const Matrix &transform, const Matrix &from)
Definition: BCMath.cpp:103
void set_transform(Object *ob)
Definition: BCMath.cpp:110
float(& scale() const)[3]
Definition: BCMath.cpp:221
void get_matrix(DMatrix &matrix, bool transposed=false, int precision=-1) const
Definition: BCMath.cpp:166
float(& location() const)[3]
Definition: BCMath.cpp:211
float(& quat() const)[4]
Definition: BCMath.cpp:226
void apply_transform(Matrix &to, const Matrix &transform, const Matrix &from, bool inverse=false)
Definition: BCMath.cpp:87
BCMatrix()
Definition: BCMath.cpp:42
static void sanitize(Matrix &matrix, int precision)
Definition: BCMath.cpp:139
bool in_range(const BCMatrix &other, float distance) const
Definition: BCMath.cpp:199
Definition: BCMath.h:15
void rotate_to(Matrix &mat_to)
Definition: BCMath.cpp:9
BCQuat(const BCQuat &other)
Definition: BCMath.h:20
BCQuat(Quat &other)
Definition: BCMath.h:25
BCQuat()
Definition: BCMath.h:30
Quat & quat()
Definition: BCMath.h:35
StackEntry * from
static unsigned a[3]
Definition: RandGen.cpp:78
T distance(const T &a, const T &b)