Blender V5.3
gpu_shader_math_matrix_compare.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8
9/* -------------------------------------------------------------------- */
12
17{
18 if (is_zero(a[0])) {
19 if (is_zero(a[1])) {
20 if (is_zero(a[2])) {
21 return true;
22 }
23 }
24 }
25 return false;
26}
27
31{
32 if (is_zero(a[0])) {
33 if (is_zero(a[1])) {
34 if (is_zero(a[2])) {
35 if (is_zero(a[3])) {
36 return true;
37 }
38 }
39 }
40 }
41 return false;
42}
43
48{
49 return determinant(mat) < 0.0f;
50}
51
58{
59 return is_negative(to_float3x3(mat));
60}
61
65bool is_equal(float2x2 a, float2x2 b, float epsilon)
66{
67 if (is_equal(a[0], b[0], epsilon)) {
68 if (is_equal(a[1], b[1], epsilon)) {
69 return true;
70 }
71 }
72 return false;
73}
74
77bool is_equal(float3x3 a, float3x3 b, float epsilon)
78{
79 if (is_equal(a[0], b[0], epsilon)) {
80 if (is_equal(a[1], b[1], epsilon)) {
81 if (is_equal(a[2], b[2], epsilon)) {
82 return true;
83 }
84 }
85 }
86 return false;
87}
88
91bool is_equal(float4x4 a, float4x4 b, float epsilon)
92{
93 if (is_equal(a[0], b[0], epsilon)) {
94 if (is_equal(a[1], b[1], epsilon)) {
95 if (is_equal(a[2], b[2], epsilon)) {
96 if (is_equal(a[3], b[3], epsilon)) {
97 return true;
98 }
99 }
100 }
101 }
102 return false;
103}
104
108{
109 if (abs(dot(mat[0], mat[1])) > 1e-5f) {
110 return false;
111 }
112 if (abs(dot(mat[1], mat[2])) > 1e-5f) {
113 return false;
114 }
115 if (abs(dot(mat[2], mat[0])) > 1e-5f) {
116 return false;
117 }
118 return true;
119}
120
124{
125 return is_orthogonal(to_float3x3(mat));
126}
127
132{
133 if (!is_orthogonal(mat)) {
134 return false;
135 }
136 if (abs(dot(mat[0], mat[0]) - 1.0f) > 1e-5f) {
137 return false;
138 }
139 if (abs(dot(mat[1], mat[1]) - 1.0f) > 1e-5f) {
140 return false;
141 }
142 if (abs(dot(mat[2], mat[2]) - 1.0f) > 1e-5f) {
143 return false;
144 }
145 return true;
146}
147
151{
152 return is_orthonormal(to_float3x3(mat));
153}
154
159{
160 if (!is_orthogonal(mat)) {
161 return false;
162 }
163 constexpr float eps = 1e-7f;
164 float x = dot(mat[0], mat[0]);
165 float y = dot(mat[1], mat[1]);
166 float z = dot(mat[2], mat[2]);
167 return (abs(x - y) < eps) && abs(x - z) < eps;
168}
169
173{
174 return is_uniformly_scaled(to_float3x3(mat));
175}
176
177/* Returns true if each individual columns are unit scaled. Mainly for assert usage. */
179{
180 if (is_unit_scale(m[0])) {
181 if (is_unit_scale(m[1])) {
182 if (is_unit_scale(m[2])) {
183 if (is_unit_scale(m[3])) {
184 return true;
185 }
186 }
187 }
188 }
189 return false;
190}
191/* Returns true if each individual columns are unit scaled. Mainly for assert usage. */
193{
194 if (is_unit_scale(m[0])) {
195 if (is_unit_scale(m[1])) {
196 if (is_unit_scale(m[2])) {
197 return true;
198 }
199 }
200 }
201 return false;
202}
203/* Returns true if each individual columns are unit scaled. Mainly for assert usage. */
205{
206 if (is_unit_scale(m[0])) {
207 if (is_unit_scale(m[1])) {
208 return true;
209 }
210 }
211 return false;
212}
213
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
b[1] b &&[1] b &&[1] b &&[1] b &&[1] b[3] b &&[1] b[3] float determinant(MatBase< C, R >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
#define abs
bool is_equal(float a, float b, const float epsilon)
bool is_unit_scale(float4x4 m)
bool is_zero(float3x3 a)
bool is_orthogonal(float3x3 mat)
bool is_uniformly_scaled(float3x3 mat)
bool is_negative(float3x3 mat)
bool is_orthonormal(float3x3 mat)
MatBase< float, 2, 2 > float2x2
MatBase< float, 4, 4 > float4x4
const btScalar eps
Definition poly34.cpp:11