Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c8
-rw-r--r--source/blender/blenlib/intern/array_utils.c6
-rw-r--r--source/blender/blenlib/intern/gsqueue.c14
-rw-r--r--source/blender/blenlib/intern/hash_mm3.c8
-rw-r--r--source/blender/blenlib/intern/jitter_2d.c46
-rw-r--r--source/blender/blenlib/intern/math_geom.c54
-rw-r--r--source/blender/blenlib/intern/math_matrix.c918
-rw-r--r--source/blender/blenlib/intern/math_rotation.c256
-rw-r--r--source/blender/blenlib/intern/math_vector.c102
-rw-r--r--source/blender/blenlib/intern/memory_utils.c14
-rw-r--r--source/blender/blenlib/intern/smallhash.c6
-rw-r--r--source/blender/blenlib/intern/storage.c14
12 files changed, 721 insertions, 725 deletions
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index f8d78213980..c39d8a05d08 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -393,14 +393,14 @@ void BLI_heap_node_value_update_ptr(Heap *heap, HeapNode *node, float value, voi
}
}
-float BLI_heap_node_value(const HeapNode *node)
+float BLI_heap_node_value(const HeapNode *heap)
{
- return node->value;
+ return heap->value;
}
-void *BLI_heap_node_ptr(const HeapNode *node)
+void *BLI_heap_node_ptr(const HeapNode *heap)
{
- return node->ptr;
+ return heap->ptr;
}
static bool heap_is_minheap(const Heap *heap, uint root)
diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c
index e9ef5e2a927..2da2bbbc2a5 100644
--- a/source/blender/blenlib/intern/array_utils.c
+++ b/source/blender/blenlib/intern/array_utils.c
@@ -88,7 +88,7 @@ void _bli_array_wrap(void *arr_v, unsigned int arr_len, size_t arr_stride, int d
*
* Access via #BLI_array_wrap
*/
-void _bli_array_permute(void *arr_v,
+void _bli_array_permute(void *arr,
const unsigned int arr_len,
const size_t arr_stride,
const unsigned int *order,
@@ -106,11 +106,11 @@ void _bli_array_permute(void *arr_v,
arr_orig = arr_temp;
}
- memcpy(arr_orig, arr_v, len);
+ memcpy(arr_orig, arr, len);
for (i = 0; i < arr_len; i++) {
BLI_assert(order[i] < arr_len);
- memcpy(POINTER_OFFSET(arr_v, arr_stride_uint * i),
+ memcpy(POINTER_OFFSET(arr, arr_stride_uint * i),
POINTER_OFFSET(arr_orig, arr_stride_uint * order[i]),
arr_stride);
}
diff --git a/source/blender/blenlib/intern/gsqueue.c b/source/blender/blenlib/intern/gsqueue.c
index 36040536cac..118d19418d4 100644
--- a/source/blender/blenlib/intern/gsqueue.c
+++ b/source/blender/blenlib/intern/gsqueue.c
@@ -114,12 +114,12 @@ void BLI_gsqueue_free(GSQueue *queue)
/**
* Copies the source value onto the end of the queue
*
- * \note This copies #GSQueue.elem_size bytes from \a src,
+ * \note This copies #GSQueue.elem_size bytes from \a item,
* (the pointer itself is not stored).
*
- * \param src: source data to be copied to the queue.
+ * \param item: source data to be copied to the queue.
*/
-void BLI_gsqueue_push(GSQueue *queue, const void *src)
+void BLI_gsqueue_push(GSQueue *queue, const void *item)
{
queue->chunk_last_index++;
queue->totelem++;
@@ -150,20 +150,20 @@ void BLI_gsqueue_push(GSQueue *queue, const void *src)
BLI_assert(queue->chunk_last_index < queue->chunk_elem_max);
/* Return last of queue */
- memcpy(queue_get_last_elem(queue), src, queue->elem_size);
+ memcpy(queue_get_last_elem(queue), item, queue->elem_size);
}
/**
* Retrieves and removes the first element from the queue.
- * The value is copies to \a dst, which must be at least \a elem_size bytes.
+ * The value is copies to \a r_item, which must be at least \a elem_size bytes.
*
* Does not reduce amount of allocated memory.
*/
-void BLI_gsqueue_pop(GSQueue *queue, void *dst)
+void BLI_gsqueue_pop(GSQueue *queue, void *r_item)
{
BLI_assert(BLI_gsqueue_is_empty(queue) == false);
- memcpy(dst, queue_get_first_elem(queue), queue->elem_size);
+ memcpy(r_item, queue_get_first_elem(queue), queue->elem_size);
queue->chunk_first_index++;
queue->totelem--;
diff --git a/source/blender/blenlib/intern/hash_mm3.c b/source/blender/blenlib/intern/hash_mm3.c
index e557789a5fd..4a175f67f30 100644
--- a/source/blender/blenlib/intern/hash_mm3.c
+++ b/source/blender/blenlib/intern/hash_mm3.c
@@ -83,9 +83,9 @@ BLI_INLINE uint64_t fmix64(uint64_t k)
return k;
}
-uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
+uint32_t BLI_hash_mm3(const unsigned char *data, size_t len, uint32_t seed)
{
- const uint8_t *data = (const uint8_t *)in;
+ const uint8_t *in_data = (const uint8_t *)data;
const int nblocks = len / 4;
uint32_t h1 = seed;
@@ -95,7 +95,7 @@ uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
/* body */
- const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4);
+ const uint32_t *blocks = (const uint32_t *)(in_data + nblocks * 4);
for (int i = -nblocks; i; i++) {
uint32_t k1 = getblock32(blocks, i);
@@ -111,7 +111,7 @@ uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
/* tail */
- const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
+ const uint8_t *tail = (const uint8_t *)(in_data + nblocks * 4);
uint32_t k1 = 0;
diff --git a/source/blender/blenlib/intern/jitter_2d.c b/source/blender/blenlib/intern/jitter_2d.c
index a5b13caf985..c92aeddb27d 100644
--- a/source/blender/blenlib/intern/jitter_2d.c
+++ b/source/blender/blenlib/intern/jitter_2d.c
@@ -31,7 +31,7 @@
#include "BLI_strict_flags.h"
-void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float rad1)
+void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float radius1)
{
int i, j, k;
float vecx, vecy, dvecx, dvecy, x, y, len;
@@ -45,30 +45,30 @@ void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float rad1)
vecx = jit1[j][0] - x - 1.0f;
vecy = jit1[j][1] - y - 1.0f;
for (k = 3; k > 0; k--) {
- if (fabsf(vecx) < rad1 && fabsf(vecy) < rad1) {
+ if (fabsf(vecx) < radius1 && fabsf(vecy) < radius1) {
len = sqrtf(vecx * vecx + vecy * vecy);
- if (len > 0 && len < rad1) {
- len = len / rad1;
+ if (len > 0 && len < radius1) {
+ len = len / radius1;
dvecx += vecx / len;
dvecy += vecy / len;
}
}
vecx += 1.0f;
- if (fabsf(vecx) < rad1 && fabsf(vecy) < rad1) {
+ if (fabsf(vecx) < radius1 && fabsf(vecy) < radius1) {
len = sqrtf(vecx * vecx + vecy * vecy);
- if (len > 0 && len < rad1) {
- len = len / rad1;
+ if (len > 0 && len < radius1) {
+ len = len / radius1;
dvecx += vecx / len;
dvecy += vecy / len;
}
}
vecx += 1.0f;
- if (fabsf(vecx) < rad1 && fabsf(vecy) < rad1) {
+ if (fabsf(vecx) < radius1 && fabsf(vecy) < radius1) {
len = sqrtf(vecx * vecx + vecy * vecy);
- if (len > 0 && len < rad1) {
- len = len / rad1;
+ if (len > 0 && len < radius1) {
+ len = len / radius1;
dvecx += vecx / len;
dvecy += vecy / len;
}
@@ -89,7 +89,7 @@ void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float rad1)
memcpy(jit1, jit2, 2 * (unsigned int)num * sizeof(float));
}
-void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float rad2)
+void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float radius2)
{
int i, j;
float vecx, vecy, dvecx, dvecy, x, y;
@@ -103,28 +103,28 @@ void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float rad2)
vecx = jit1[j][0] - x - 1.0f;
vecy = jit1[j][1] - y - 1.0f;
- if (fabsf(vecx) < rad2) {
- dvecx += vecx * rad2;
+ if (fabsf(vecx) < radius2) {
+ dvecx += vecx * radius2;
}
vecx += 1.0f;
- if (fabsf(vecx) < rad2) {
- dvecx += vecx * rad2;
+ if (fabsf(vecx) < radius2) {
+ dvecx += vecx * radius2;
}
vecx += 1.0f;
- if (fabsf(vecx) < rad2) {
- dvecx += vecx * rad2;
+ if (fabsf(vecx) < radius2) {
+ dvecx += vecx * radius2;
}
- if (fabsf(vecy) < rad2) {
- dvecy += vecy * rad2;
+ if (fabsf(vecy) < radius2) {
+ dvecy += vecy * radius2;
}
vecy += 1.0f;
- if (fabsf(vecy) < rad2) {
- dvecy += vecy * rad2;
+ if (fabsf(vecy) < radius2) {
+ dvecy += vecy * radius2;
}
vecy += 1.0f;
- if (fabsf(vecy) < rad2) {
- dvecy += vecy * rad2;
+ if (fabsf(vecy) < radius2) {
+ dvecy += vecy * radius2;
}
}
}
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 1afcf83bf73..9cf1341b16a 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -802,14 +802,14 @@ float dist_squared_ray_to_aabb_v3(const struct DistRayAABB_Precalc *data,
float dist_squared_ray_to_aabb_v3_simple(const float ray_origin[3],
const float ray_direction[3],
- const float bbmin[3],
- const float bbmax[3],
+ const float bb_min[3],
+ const float bb_max[3],
float r_point[3],
float *r_depth)
{
struct DistRayAABB_Precalc data;
dist_squared_ray_to_aabb_v3_precalc(&data, ray_origin, ray_direction);
- return dist_squared_ray_to_aabb_v3(&data, bbmin, bbmax, r_point, r_depth);
+ return dist_squared_ray_to_aabb_v3(&data, bb_min, bb_max, r_point, r_depth);
}
/** \} */
@@ -1022,31 +1022,31 @@ float dist_squared_to_projected_aabb_simple(const float projmat[4][4],
*
* Set 'r' to the point in triangle (a, b, c) closest to point 'p' */
void closest_on_tri_to_point_v3(
- float r[3], const float p[3], const float a[3], const float b[3], const float c[3])
+ float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
{
float ab[3], ac[3], ap[3], d1, d2;
float bp[3], d3, d4, vc, cp[3], d5, d6, vb, va;
float denom, v, w;
/* Check if P in vertex region outside A */
- sub_v3_v3v3(ab, b, a);
- sub_v3_v3v3(ac, c, a);
- sub_v3_v3v3(ap, p, a);
+ sub_v3_v3v3(ab, v2, v1);
+ sub_v3_v3v3(ac, v3, v1);
+ sub_v3_v3v3(ap, p, v1);
d1 = dot_v3v3(ab, ap);
d2 = dot_v3v3(ac, ap);
if (d1 <= 0.0f && d2 <= 0.0f) {
/* barycentric coordinates (1,0,0) */
- copy_v3_v3(r, a);
+ copy_v3_v3(r, v1);
return;
}
/* Check if P in vertex region outside B */
- sub_v3_v3v3(bp, p, b);
+ sub_v3_v3v3(bp, p, v2);
d3 = dot_v3v3(ab, bp);
d4 = dot_v3v3(ac, bp);
if (d3 >= 0.0f && d4 <= d3) {
/* barycentric coordinates (0,1,0) */
- copy_v3_v3(r, b);
+ copy_v3_v3(r, v2);
return;
}
/* Check if P in edge region of AB, if so return projection of P onto AB */
@@ -1054,16 +1054,16 @@ void closest_on_tri_to_point_v3(
if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) {
v = d1 / (d1 - d3);
/* barycentric coordinates (1-v,v,0) */
- madd_v3_v3v3fl(r, a, ab, v);
+ madd_v3_v3v3fl(r, v1, ab, v);
return;
}
/* Check if P in vertex region outside C */
- sub_v3_v3v3(cp, p, c);
+ sub_v3_v3v3(cp, p, v3);
d5 = dot_v3v3(ab, cp);
d6 = dot_v3v3(ac, cp);
if (d6 >= 0.0f && d5 <= d6) {
/* barycentric coordinates (0,0,1) */
- copy_v3_v3(r, c);
+ copy_v3_v3(r, v3);
return;
}
/* Check if P in edge region of AC, if so return projection of P onto AC */
@@ -1071,7 +1071,7 @@ void closest_on_tri_to_point_v3(
if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) {
w = d2 / (d2 - d6);
/* barycentric coordinates (1-w,0,w) */
- madd_v3_v3v3fl(r, a, ac, w);
+ madd_v3_v3v3fl(r, v1, ac, w);
return;
}
/* Check if P in edge region of BC, if so return projection of P onto BC */
@@ -1079,9 +1079,9 @@ void closest_on_tri_to_point_v3(
if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) {
w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
/* barycentric coordinates (0,1-w,w) */
- sub_v3_v3v3(r, c, b);
+ sub_v3_v3v3(r, v3, v2);
mul_v3_fl(r, w);
- add_v3_v3(r, b);
+ add_v3_v3(r, v2);
return;
}
@@ -1094,7 +1094,7 @@ void closest_on_tri_to_point_v3(
/* ac * w */
mul_v3_fl(ac, w);
/* a + ab * v */
- madd_v3_v3v3fl(r, a, ab, v);
+ madd_v3_v3v3fl(r, v1, ab, v);
/* a + ab * v + ac * w */
add_v3_v3(r, ac);
}
@@ -4972,28 +4972,28 @@ void projmat_from_subregion(const float projmat[4][4],
}
}
-static void i_multmatrix(const float icand[4][4], float Vm[4][4])
+static void i_multmatrix(const float icand[4][4], float mat[4][4])
{
int row, col;
float temp[4][4];
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++) {
- temp[row][col] = (icand[row][0] * Vm[0][col] + icand[row][1] * Vm[1][col] +
- icand[row][2] * Vm[2][col] + icand[row][3] * Vm[3][col]);
+ temp[row][col] = (icand[row][0] * mat[0][col] + icand[row][1] * mat[1][col] +
+ icand[row][2] * mat[2][col] + icand[row][3] * mat[3][col]);
}
}
- copy_m4_m4(Vm, temp);
+ copy_m4_m4(mat, temp);
}
-void polarview_m4(float Vm[4][4], float dist, float azimuth, float incidence, float twist)
+void polarview_m4(float mat[4][4], float dist, float azimuth, float incidence, float twist)
{
- unit_m4(Vm);
+ unit_m4(mat);
- translate_m4(Vm, 0.0, 0.0, -dist);
- rotate_m4(Vm, 'Z', -twist);
- rotate_m4(Vm, 'X', -incidence);
- rotate_m4(Vm, 'Z', -azimuth);
+ translate_m4(mat, 0.0, 0.0, -dist);
+ rotate_m4(mat, 'Z', -twist);
+ rotate_m4(mat, 'X', -incidence);
+ rotate_m4(mat, 'Z', -azimuth);
}
void lookat_m4(
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index f523bd07c09..08c7d3b1e91 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -204,20 +204,20 @@ void copy_m4d_m4(double m1[4][4], const float m2[4][4])
m1[3][3] = m2[3][3];
}
-void copy_m3_m3d(float R[3][3], const double A[3][3])
+void copy_m3_m3d(float m1[3][3], const double m2[3][3])
{
/* Keep it stupid simple for better data flow in CPU. */
- R[0][0] = (float)A[0][0];
- R[0][1] = (float)A[0][1];
- R[0][2] = (float)A[0][2];
+ m1[0][0] = (float)m2[0][0];
+ m1[0][1] = (float)m2[0][1];
+ m1[0][2] = (float)m2[0][2];
- R[1][0] = (float)A[1][0];
- R[1][1] = (float)A[1][1];
- R[1][2] = (float)A[1][2];
+ m1[1][0] = (float)m2[1][0];
+ m1[1][1] = (float)m2[1][1];
+ m1[1][2] = (float)m2[1][2];
- R[2][0] = (float)A[2][0];
- R[2][1] = (float)A[2][1];
- R[2][2] = (float)A[2][2];
+ m1[2][0] = (float)m2[2][0];
+ m1[2][1] = (float)m2[2][1];
+ m1[2][2] = (float)m2[2][2];
}
void swap_m3m3(float m1[3][3], float m2[3][3])
@@ -435,105 +435,105 @@ void mul_m3_m3m3_uniq(float R[3][3], const float A[3][3], const float B[3][3])
R[2][2] = B[2][0] * A[0][2] + B[2][1] * A[1][2] + B[2][2] * A[2][2];
}
-void mul_m4_m4m3(float m1[4][4], const float m3_[4][4], const float m2_[3][3])
+void mul_m4_m4m3(float R[4][4], const float A[4][4], const float B[3][3])
{
- float m2[3][3], m3[4][4];
+ float B_[3][3], A_[4][4];
- /* copy so it works when m1 is the same pointer as m2 or m3 */
+ /* copy so it works when R is the same pointer as A or B */
/* TODO: avoid copying when matrices are different */
- copy_m3_m3(m2, m2_);
- copy_m4_m4(m3, m3_);
+ copy_m4_m4(A_, A);
+ copy_m3_m3(B_, B);
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ R[0][0] = B_[0][0] * A_[0][0] + B_[0][1] * A_[1][0] + B_[0][2] * A_[2][0];
+ R[0][1] = B_[0][0] * A_[0][1] + B_[0][1] * A_[1][1] + B_[0][2] * A_[2][1];
+ R[0][2] = B_[0][0] * A_[0][2] + B_[0][1] * A_[1][2] + B_[0][2] * A_[2][2];
+ R[1][0] = B_[1][0] * A_[0][0] + B_[1][1] * A_[1][0] + B_[1][2] * A_[2][0];
+ R[1][1] = B_[1][0] * A_[0][1] + B_[1][1] * A_[1][1] + B_[1][2] * A_[2][1];
+ R[1][2] = B_[1][0] * A_[0][2] + B_[1][1] * A_[1][2] + B_[1][2] * A_[2][2];
+ R[2][0] = B_[2][0] * A_[0][0] + B_[2][1] * A_[1][0] + B_[2][2] * A_[2][0];
+ R[2][1] = B_[2][0] * A_[0][1] + B_[2][1] * A_[1][1] + B_[2][2] * A_[2][1];
+ R[2][2] = B_[2][0] * A_[0][2] + B_[2][1] * A_[1][2] + B_[2][2] * A_[2][2];
}
-/* m1 = m2 * m3, ignore the elements on the 4th row/column of m2 */
-void mul_m3_m3m4(float m1[3][3], const float m3_[3][3], const float m2_[4][4])
+/* R = A * B, ignore the elements on the 4th row/column of A */
+void mul_m3_m3m4(float R[3][3], const float A[3][3], const float B[4][4])
{
- float m2[4][4], m3[3][3];
+ float B_[4][4], A_[3][3];
- /* copy so it works when m1 is the same pointer as m2 or m3 */
+ /* copy so it works when R is the same pointer as A or B */
/* TODO: avoid copying when matrices are different */
- copy_m4_m4(m2, m2_);
- copy_m3_m3(m3, m3_);
+ copy_m3_m3(A_, A);
+ copy_m4_m4(B_, B);
- /* m1[i][j] = m2[i][k] * m3[k][j] */
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
+ /* R[i][j] = B_[i][k] * A_[k][j] */
+ R[0][0] = B_[0][0] * A_[0][0] + B_[0][1] * A_[1][0] + B_[0][2] * A_[2][0];
+ R[0][1] = B_[0][0] * A_[0][1] + B_[0][1] * A_[1][1] + B_[0][2] * A_[2][1];
+ R[0][2] = B_[0][0] * A_[0][2] + B_[0][1] * A_[1][2] + B_[0][2] * A_[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
+ R[1][0] = B_[1][0] * A_[0][0] + B_[1][1] * A_[1][0] + B_[1][2] * A_[2][0];
+ R[1][1] = B_[1][0] * A_[0][1] + B_[1][1] * A_[1][1] + B_[1][2] * A_[2][1];
+ R[1][2] = B_[1][0] * A_[0][2] + B_[1][1] * A_[1][2] + B_[1][2] * A_[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ R[2][0] = B_[2][0] * A_[0][0] + B_[2][1] * A_[1][0] + B_[2][2] * A_[2][0];
+ R[2][1] = B_[2][0] * A_[0][1] + B_[2][1] * A_[1][1] + B_[2][2] * A_[2][1];
+ R[2][2] = B_[2][0] * A_[0][2] + B_[2][1] * A_[1][2] + B_[2][2] * A_[2][2];
}
-/* m1 = m2 * m3, ignore the elements on the 4th row/column of m3 */
-void mul_m3_m4m3(float m1[3][3], const float m3_[4][4], const float m2_[3][3])
+/* R = A * B, ignore the elements on the 4th row/column of B */
+void mul_m3_m4m3(float R[3][3], const float A[4][4], const float B[3][3])
{
- float m2[3][3], m3[4][4];
+ float B_[3][3], A_[4][4];
- /* copy so it works when m1 is the same pointer as m2 or m3 */
+ /* copy so it works when R is the same pointer as A or B */
/* TODO: avoid copying when matrices are different */
- copy_m3_m3(m2, m2_);
- copy_m4_m4(m3, m3_);
+ copy_m4_m4(A_, A);
+ copy_m3_m3(B_, B);
- /* m1[i][j] = m2[i][k] * m3[k][j] */
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
+ /* R[i][j] = B[i][k] * A[k][j] */
+ R[0][0] = B_[0][0] * A_[0][0] + B_[0][1] * A_[1][0] + B_[0][2] * A_[2][0];
+ R[0][1] = B_[0][0] * A_[0][1] + B_[0][1] * A_[1][1] + B_[0][2] * A_[2][1];
+ R[0][2] = B_[0][0] * A_[0][2] + B_[0][1] * A_[1][2] + B_[0][2] * A_[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
+ R[1][0] = B_[1][0] * A_[0][0] + B_[1][1] * A_[1][0] + B_[1][2] * A_[2][0];
+ R[1][1] = B_[1][0] * A_[0][1] + B_[1][1] * A_[1][1] + B_[1][2] * A_[2][1];
+ R[1][2] = B_[1][0] * A_[0][2] + B_[1][1] * A_[1][2] + B_[1][2] * A_[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ R[2][0] = B_[2][0] * A_[0][0] + B_[2][1] * A_[1][0] + B_[2][2] * A_[2][0];
+ R[2][1] = B_[2][0] * A_[0][1] + B_[2][1] * A_[1][1] + B_[2][2] * A_[2][1];
+ R[2][2] = B_[2][0] * A_[0][2] + B_[2][1] * A_[1][2] + B_[2][2] * A_[2][2];
}
-void mul_m4_m3m4(float m1[4][4], const float m3_[3][3], const float m2_[4][4])
+void mul_m4_m3m4(float R[4][4], const float A[3][3], const float B[4][4])
{
- float m2[4][4], m3[3][3];
+ float B_[4][4], A_[3][3];
- /* copy so it works when m1 is the same pointer as m2 or m3 */
+ /* copy so it works when R is the same pointer as A or B */
/* TODO: avoid copying when matrices are different */
- copy_m4_m4(m2, m2_);
- copy_m3_m3(m3, m3_);
+ copy_m3_m3(A_, A);
+ copy_m4_m4(B_, B);
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ R[0][0] = B_[0][0] * A_[0][0] + B_[0][1] * A_[1][0] + B_[0][2] * A_[2][0];
+ R[0][1] = B_[0][0] * A_[0][1] + B_[0][1] * A_[1][1] + B_[0][2] * A_[2][1];
+ R[0][2] = B_[0][0] * A_[0][2] + B_[0][1] * A_[1][2] + B_[0][2] * A_[2][2];
+ R[1][0] = B_[1][0] * A_[0][0] + B_[1][1] * A_[1][0] + B_[1][2] * A_[2][0];
+ R[1][1] = B_[1][0] * A_[0][1] + B_[1][1] * A_[1][1] + B_[1][2] * A_[2][1];
+ R[1][2] = B_[1][0] * A_[0][2] + B_[1][1] * A_[1][2] + B_[1][2] * A_[2][2];
+ R[2][0] = B_[2][0] * A_[0][0] + B_[2][1] * A_[1][0] + B_[2][2] * A_[2][0];
+ R[2][1] = B_[2][0] * A_[0][1] + B_[2][1] * A_[1][1] + B_[2][2] * A_[2][1];
+ R[2][2] = B_[2][0] * A_[0][2] + B_[2][1] * A_[1][2] + B_[2][2] * A_[2][2];
}
-void mul_m3_m4m4(float m1[3][3], const float m3[4][4], const float m2[4][4])
+void mul_m3_m4m4(float R[3][3], const float A[4][4], const float B[4][4])
{
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ R[0][0] = B[0][0] * A[0][0] + B[0][1] * A[1][0] + B[0][2] * A[2][0];
+ R[0][1] = B[0][0] * A[0][1] + B[0][1] * A[1][1] + B[0][2] * A[2][1];
+ R[0][2] = B[0][0] * A[0][2] + B[0][1] * A[1][2] + B[0][2] * A[2][2];
+ R[1][0] = B[1][0] * A[0][0] + B[1][1] * A[1][0] + B[1][2] * A[2][0];
+ R[1][1] = B[1][0] * A[0][1] + B[1][1] * A[1][1] + B[1][2] * A[2][1];
+ R[1][2] = B[1][0] * A[0][2] + B[1][1] * A[1][2] + B[1][2] * A[2][2];
+ R[2][0] = B[2][0] * A[0][0] + B[2][1] * A[1][0] + B[2][2] * A[2][0];
+ R[2][1] = B[2][0] * A[0][1] + B[2][1] * A[1][1] + B[2][2] * A[2][1];
+ R[2][2] = B[2][0] * A[0][2] + B[2][1] * A[1][2] + B[2][2] * A[2][2];
}
/** \name Macro helpers for: mul_m3_series
@@ -726,14 +726,14 @@ void mul_m3_v2(const float m[3][3], float r[2])
mul_v2_m3v2(r, m, r);
}
-void mul_m4_v3(const float mat[4][4], float vec[3])
+void mul_m4_v3(const float M[4][4], float r[3])
{
- const float x = vec[0];
- const float y = vec[1];
+ const float x = r[0];
+ const float y = r[1];
- vec[0] = x * mat[0][0] + y * mat[1][0] + mat[2][0] * vec[2] + mat[3][0];
- vec[1] = x * mat[0][1] + y * mat[1][1] + mat[2][1] * vec[2] + mat[3][1];
- vec[2] = x * mat[0][2] + y * mat[1][2] + mat[2][2] * vec[2] + mat[3][2];
+ r[0] = x * M[0][0] + y * M[1][0] + M[2][0] * r[2] + M[3][0];
+ r[1] = x * M[0][1] + y * M[1][1] + M[2][1] * r[2] + M[3][1];
+ r[2] = x * M[0][2] + y * M[1][2] + M[2][2] * r[2] + M[3][2];
}
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
@@ -788,14 +788,14 @@ void mul_m2_v2(const float mat[2][2], float vec[2])
}
/** Same as #mul_m4_v3() but doesn't apply translation component. */
-void mul_mat3_m4_v3(const float mat[4][4], float vec[3])
+void mul_mat3_m4_v3(const float M[4][4], float r[3])
{
- const float x = vec[0];
- const float y = vec[1];
+ const float x = r[0];
+ const float y = r[1];
- vec[0] = x * mat[0][0] + y * mat[1][0] + mat[2][0] * vec[2];
- vec[1] = x * mat[0][1] + y * mat[1][1] + mat[2][1] * vec[2];
- vec[2] = x * mat[0][2] + y * mat[1][2] + mat[2][2] * vec[2];
+ r[0] = x * M[0][0] + y * M[1][0] + M[2][0] * r[2];
+ r[1] = x * M[0][1] + y * M[1][1] + M[2][1] * r[2];
+ r[2] = x * M[0][2] + y * M[1][2] + M[2][2] * r[2];
}
void mul_v3_mat3_m4v3(float r[3], const float mat[4][4], const float vec[3])
@@ -934,164 +934,164 @@ void mul_m3_v3_db(const double M[3][3], double r[3])
mul_v3_m3v3_db(r, M, (const double[3]){UNPACK3(r)});
}
-void mul_transposed_m3_v3(const float mat[3][3], float vec[3])
+void mul_transposed_m3_v3(const float M[3][3], float r[3])
{
- const float x = vec[0];
- const float y = vec[1];
+ const float x = r[0];
+ const float y = r[1];
- vec[0] = x * mat[0][0] + y * mat[0][1] + mat[0][2] * vec[2];
- vec[1] = x * mat[1][0] + y * mat[1][1] + mat[1][2] * vec[2];
- vec[2] = x * mat[2][0] + y * mat[2][1] + mat[2][2] * vec[2];
+ r[0] = x * M[0][0] + y * M[0][1] + M[0][2] * r[2];
+ r[1] = x * M[1][0] + y * M[1][1] + M[1][2] * r[2];
+ r[2] = x * M[2][0] + y * M[2][1] + M[2][2] * r[2];
}
-void mul_transposed_mat3_m4_v3(const float mat[4][4], float vec[3])
+void mul_transposed_mat3_m4_v3(const float M[4][4], float r[3])
{
- const float x = vec[0];
- const float y = vec[1];
+ const float x = r[0];
+ const float y = r[1];
- vec[0] = x * mat[0][0] + y * mat[0][1] + mat[0][2] * vec[2];
- vec[1] = x * mat[1][0] + y * mat[1][1] + mat[1][2] * vec[2];
- vec[2] = x * mat[2][0] + y * mat[2][1] + mat[2][2] * vec[2];
+ r[0] = x * M[0][0] + y * M[0][1] + M[0][2] * r[2];
+ r[1] = x * M[1][0] + y * M[1][1] + M[1][2] * r[2];
+ r[2] = x * M[2][0] + y * M[2][1] + M[2][2] * r[2];
}
-void mul_m3_fl(float m[3][3], float f)
+void mul_m3_fl(float R[3][3], float f)
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m[i][j] *= f;
+ R[i][j] *= f;
}
}
}
-void mul_m4_fl(float m[4][4], float f)
+void mul_m4_fl(float R[4][4], float f)
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m[i][j] *= f;
+ R[i][j] *= f;
}
}
}
-void mul_mat3_m4_fl(float m[4][4], float f)
+void mul_mat3_m4_fl(float R[4][4], float f)
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m[i][j] *= f;
+ R[i][j] *= f;
}
}
}
-void negate_m3(float m[3][3])
+void negate_m3(float R[3][3])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m[i][j] *= -1.0f;
+ R[i][j] *= -1.0f;
}
}
}
-void negate_mat3_m4(float m[4][4])
+void negate_mat3_m4(float R[4][4])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m[i][j] *= -1.0f;
+ R[i][j] *= -1.0f;
}
}
}
-void negate_m4(float m[4][4])
+void negate_m4(float R[4][4])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m[i][j] *= -1.0f;
+ R[i][j] *= -1.0f;
}
}
}
-void mul_m3_v3_double(const float mat[3][3], double vec[3])
+void mul_m3_v3_double(const float M[3][3], double r[3])
{
- const double x = vec[0];
- const double y = vec[1];
+ const double x = r[0];
+ const double y = r[1];
- vec[0] = x * (double)mat[0][0] + y * (double)mat[1][0] + (double)mat[2][0] * vec[2];
- vec[1] = x * (double)mat[0][1] + y * (double)mat[1][1] + (double)mat[2][1] * vec[2];
- vec[2] = x * (double)mat[0][2] + y * (double)mat[1][2] + (double)mat[2][2] * vec[2];
+ r[0] = x * (double)M[0][0] + y * (double)M[1][0] + (double)M[2][0] * r[2];
+ r[1] = x * (double)M[0][1] + y * (double)M[1][1] + (double)M[2][1] * r[2];
+ r[2] = x * (double)M[0][2] + y * (double)M[1][2] + (double)M[2][2] * r[2];
}
-void add_m3_m3m3(float m1[3][3], const float m2[3][3], const float m3[3][3])
+void add_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m1[i][j] = m2[i][j] + m3[i][j];
+ R[i][j] = A[i][j] + B[i][j];
}
}
}
-void add_m4_m4m4(float m1[4][4], const float m2[4][4], const float m3[4][4])
+void add_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m1[i][j] = m2[i][j] + m3[i][j];
+ R[i][j] = A[i][j] + B[i][j];
}
}
}
-void madd_m3_m3m3fl(float m1[3][3], const float m2[3][3], const float m3[3][3], const float f)
+void madd_m3_m3m3fl(float R[3][3], const float A[3][3], const float B[3][3], const float f)
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m1[i][j] = m2[i][j] + m3[i][j] * f;
+ R[i][j] = A[i][j] + B[i][j] * f;
}
}
}
-void madd_m4_m4m4fl(float m1[4][4], const float m2[4][4], const float m3[4][4], const float f)
+void madd_m4_m4m4fl(float R[4][4], const float A[4][4], const float B[4][4], const float f)
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m1[i][j] = m2[i][j] + m3[i][j] * f;
+ R[i][j] = A[i][j] + B[i][j] * f;
}
}
}
-void sub_m3_m3m3(float m1[3][3], const float m2[3][3], const float m3[3][3])
+void sub_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m1[i][j] = m2[i][j] - m3[i][j];
+ R[i][j] = A[i][j] - B[i][j];
}
}
}
-void sub_m4_m4m4(float m1[4][4], const float m2[4][4], const float m3[4][4])
+void sub_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m1[i][j] = m2[i][j] - m3[i][j];
+ R[i][j] = A[i][j] - B[i][j];
}
}
}
@@ -1306,113 +1306,112 @@ void mul_m4_m4m4_aligned_scale(float R[4][4], const float A[4][4], const float B
/****************************** Linear Algebra *******************************/
-void transpose_m3(float mat[3][3])
+void transpose_m3(float R[3][3])
{
float t;
- t = mat[0][1];
- mat[0][1] = mat[1][0];
- mat[1][0] = t;
- t = mat[0][2];
- mat[0][2] = mat[2][0];
- mat[2][0] = t;
- t = mat[1][2];
- mat[1][2] = mat[2][1];
- mat[2][1] = t;
+ t = R[0][1];
+ R[0][1] = R[1][0];
+ R[1][0] = t;
+ t = R[0][2];
+ R[0][2] = R[2][0];
+ R[2][0] = t;
+ t = R[1][2];
+ R[1][2] = R[2][1];
+ R[2][1] = t;
}
-void transpose_m3_m3(float rmat[3][3], const float mat[3][3])
+void transpose_m3_m3(float R[3][3], const float M[3][3])
{
- BLI_assert(rmat != mat);
+ BLI_assert(R != M);
- rmat[0][0] = mat[0][0];
- rmat[0][1] = mat[1][0];
- rmat[0][2] = mat[2][0];
- rmat[1][0] = mat[0][1];
- rmat[1][1] = mat[1][1];
- rmat[1][2] = mat[2][1];
- rmat[2][0] = mat[0][2];
- rmat[2][1] = mat[1][2];
- rmat[2][2] = mat[2][2];
+ R[0][0] = M[0][0];
+ R[0][1] = M[1][0];
+ R[0][2] = M[2][0];
+ R[1][0] = M[0][1];
+ R[1][1] = M[1][1];
+ R[1][2] = M[2][1];
+ R[2][0] = M[0][2];
+ R[2][1] = M[1][2];
+ R[2][2] = M[2][2];
}
/* seems obscure but in-fact a common operation */
-void transpose_m3_m4(float rmat[3][3], const float mat[4][4])
+void transpose_m3_m4(float R[3][3], const float M[4][4])
{
- BLI_assert(&rmat[0][0] != &mat[0][0]);
+ BLI_assert(&R[0][0] != &M[0][0]);
- rmat[0][0] = mat[0][0];
- rmat[0][1] = mat[1][0];
- rmat[0][2] = mat[2][0];
- rmat[1][0] = mat[0][1];
- rmat[1][1] = mat[1][1];
- rmat[1][2] = mat[2][1];
- rmat[2][0] = mat[0][2];
- rmat[2][1] = mat[1][2];
- rmat[2][2] = mat[2][2];
+ R[0][0] = M[0][0];
+ R[0][1] = M[1][0];
+ R[0][2] = M[2][0];
+ R[1][0] = M[0][1];
+ R[1][1] = M[1][1];
+ R[1][2] = M[2][1];
+ R[2][0] = M[0][2];
+ R[2][1] = M[1][2];
+ R[2][2] = M[2][2];
}
-void transpose_m4(float mat[4][4])
+void transpose_m4(float R[4][4])
{
float t;
- t = mat[0][1];
- mat[0][1] = mat[1][0];
- mat[1][0] = t;
- t = mat[0][2];
- mat[0][2] = mat[2][0];
- mat[2][0] = t;
- t = mat[0][3];
- mat[0][3] = mat[3][0];
- mat[3][0] = t;
-
- t = mat[1][2];
- mat[1][2] = mat[2][1];
- mat[2][1] = t;
- t = mat[1][3];
- mat[1][3] = mat[3][1];
- mat[3][1] = t;
-
- t = mat[2][3];
- mat[2][3] = mat[3][2];
- mat[3][2] = t;
-}
-
-void transpose_m4_m4(float rmat[4][4], const float mat[4][4])
-{
- BLI_assert(rmat != mat);
-
- rmat[0][0] = mat[0][0];
- rmat[0][1] = mat[1][0];
- rmat[0][2] = mat[2][0];
- rmat[0][3] = mat[3][0];
- rmat[1][0] = mat[0][1];
- rmat[1][1] = mat[1][1];
- rmat[1][2] = mat[2][1];
- rmat[1][3] = mat[3][1];
- rmat[2][0] = mat[0][2];
- rmat[2][1] = mat[1][2];
- rmat[2][2] = mat[2][2];
- rmat[2][3] = mat[3][2];
- rmat[3][0] = mat[0][3];
- rmat[3][1] = mat[1][3];
- rmat[3][2] = mat[2][3];
- rmat[3][3] = mat[3][3];
-}
-
-/* TODO: return bool */
-int compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit)
+ t = R[0][1];
+ R[0][1] = R[1][0];
+ R[1][0] = t;
+ t = R[0][2];
+ R[0][2] = R[2][0];
+ R[2][0] = t;
+ t = R[0][3];
+ R[0][3] = R[3][0];
+ R[3][0] = t;
+
+ t = R[1][2];
+ R[1][2] = R[2][1];
+ R[2][1] = t;
+ t = R[1][3];
+ R[1][3] = R[3][1];
+ R[3][1] = t;
+
+ t = R[2][3];
+ R[2][3] = R[3][2];
+ R[3][2] = t;
+}
+
+void transpose_m4_m4(float R[4][4], const float M[4][4])
+{
+ BLI_assert(R != M);
+
+ R[0][0] = M[0][0];
+ R[0][1] = M[1][0];
+ R[0][2] = M[2][0];
+ R[0][3] = M[3][0];
+ R[1][0] = M[0][1];
+ R[1][1] = M[1][1];
+ R[1][2] = M[2][1];
+ R[1][3] = M[3][1];
+ R[2][0] = M[0][2];
+ R[2][1] = M[1][2];
+ R[2][2] = M[2][2];
+ R[2][3] = M[3][2];
+ R[3][0] = M[0][3];
+ R[3][1] = M[1][3];
+ R[3][2] = M[2][3];
+ R[3][3] = M[3][3];
+}
+
+bool compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit)
{
if (compare_v4v4(mat1[0], mat2[0], limit)) {
if (compare_v4v4(mat1[1], mat2[1], limit)) {
if (compare_v4v4(mat1[2], mat2[2], limit)) {
if (compare_v4v4(mat1[3], mat2[3], limit)) {
- return 1;
+ return true;
}
}
}
}
- return 0;
+ return false;
}
/**
@@ -1420,88 +1419,88 @@ int compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit)
*
* \param axis: Axis to build the orthonormal basis around.
*/
-void orthogonalize_m3(float mat[3][3], int axis)
+void orthogonalize_m3(float R[3][3], int axis)
{
float size[3];
- mat3_to_size(size, mat);
- normalize_v3(mat[axis]);
+ mat3_to_size(size, R);
+ normalize_v3(R[axis]);
switch (axis) {
case 0:
- if (dot_v3v3(mat[0], mat[1]) < 1) {
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ if (dot_v3v3(R[0], R[1]) < 1) {
+ cross_v3_v3v3(R[2], R[0], R[1]);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
- else if (dot_v3v3(mat[0], mat[2]) < 1) {
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
- normalize_v3(mat[1]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ else if (dot_v3v3(R[0], R[2]) < 1) {
+ cross_v3_v3v3(R[1], R[2], R[0]);
+ normalize_v3(R[1]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
else {
float vec[3];
- vec[0] = mat[0][1];
- vec[1] = mat[0][2];
- vec[2] = mat[0][0];
+ vec[0] = R[0][1];
+ vec[1] = R[0][2];
+ vec[2] = R[0][0];
- cross_v3_v3v3(mat[2], mat[0], vec);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ cross_v3_v3v3(R[2], R[0], vec);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
break;
case 1:
- if (dot_v3v3(mat[1], mat[0]) < 1) {
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
+ if (dot_v3v3(R[1], R[0]) < 1) {
+ cross_v3_v3v3(R[2], R[0], R[1]);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[0], R[1], R[2]);
}
- else if (dot_v3v3(mat[0], mat[2]) < 1) {
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ else if (dot_v3v3(R[0], R[2]) < 1) {
+ cross_v3_v3v3(R[0], R[1], R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
else {
float vec[3];
- vec[0] = mat[1][1];
- vec[1] = mat[1][2];
- vec[2] = mat[1][0];
+ vec[0] = R[1][1];
+ vec[1] = R[1][2];
+ vec[2] = R[1][0];
- cross_v3_v3v3(mat[0], mat[1], vec);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ cross_v3_v3v3(R[0], R[1], vec);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
break;
case 2:
- if (dot_v3v3(mat[2], mat[0]) < 1) {
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
- normalize_v3(mat[1]);
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
+ if (dot_v3v3(R[2], R[0]) < 1) {
+ cross_v3_v3v3(R[1], R[2], R[0]);
+ normalize_v3(R[1]);
+ cross_v3_v3v3(R[0], R[1], R[2]);
}
- else if (dot_v3v3(mat[2], mat[1]) < 1) {
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ else if (dot_v3v3(R[2], R[1]) < 1) {
+ cross_v3_v3v3(R[0], R[1], R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
else {
float vec[3];
- vec[0] = mat[2][1];
- vec[1] = mat[2][2];
- vec[2] = mat[2][0];
+ vec[0] = R[2][1];
+ vec[1] = R[2][2];
+ vec[2] = R[2][0];
- cross_v3_v3v3(mat[0], vec, mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ cross_v3_v3v3(R[0], vec, R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
break;
default:
BLI_assert(0);
break;
}
- mul_v3_fl(mat[0], size[0]);
- mul_v3_fl(mat[1], size[1]);
- mul_v3_fl(mat[2], size[2]);
+ mul_v3_fl(R[0], size[0]);
+ mul_v3_fl(R[1], size[1]);
+ mul_v3_fl(R[2], size[2]);
}
/**
@@ -1509,88 +1508,88 @@ void orthogonalize_m3(float mat[3][3], int axis)
*
* \param axis: Axis to build the orthonormal basis around.
*/
-void orthogonalize_m4(float mat[4][4], int axis)
+void orthogonalize_m4(float R[4][4], int axis)
{
float size[3];
- mat4_to_size(size, mat);
- normalize_v3(mat[axis]);
+ mat4_to_size(size, R);
+ normalize_v3(R[axis]);
switch (axis) {
case 0:
- if (dot_v3v3(mat[0], mat[1]) < 1) {
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ if (dot_v3v3(R[0], R[1]) < 1) {
+ cross_v3_v3v3(R[2], R[0], R[1]);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
- else if (dot_v3v3(mat[0], mat[2]) < 1) {
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
- normalize_v3(mat[1]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ else if (dot_v3v3(R[0], R[2]) < 1) {
+ cross_v3_v3v3(R[1], R[2], R[0]);
+ normalize_v3(R[1]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
else {
float vec[3];
- vec[0] = mat[0][1];
- vec[1] = mat[0][2];
- vec[2] = mat[0][0];
+ vec[0] = R[0][1];
+ vec[1] = R[0][2];
+ vec[2] = R[0][0];
- cross_v3_v3v3(mat[2], mat[0], vec);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ cross_v3_v3v3(R[2], R[0], vec);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
break;
case 1:
- if (dot_v3v3(mat[1], mat[0]) < 1) {
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
+ if (dot_v3v3(R[1], R[0]) < 1) {
+ cross_v3_v3v3(R[2], R[0], R[1]);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[0], R[1], R[2]);
}
- else if (dot_v3v3(mat[0], mat[2]) < 1) {
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ else if (dot_v3v3(R[0], R[2]) < 1) {
+ cross_v3_v3v3(R[0], R[1], R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
else {
float vec[3];
- vec[0] = mat[1][1];
- vec[1] = mat[1][2];
- vec[2] = mat[1][0];
+ vec[0] = R[1][1];
+ vec[1] = R[1][2];
+ vec[2] = R[1][0];
- cross_v3_v3v3(mat[0], mat[1], vec);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ cross_v3_v3v3(R[0], R[1], vec);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
break;
case 2:
- if (dot_v3v3(mat[2], mat[0]) < 1) {
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
- normalize_v3(mat[1]);
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
+ if (dot_v3v3(R[2], R[0]) < 1) {
+ cross_v3_v3v3(R[1], R[2], R[0]);
+ normalize_v3(R[1]);
+ cross_v3_v3v3(R[0], R[1], R[2]);
}
- else if (dot_v3v3(mat[2], mat[1]) < 1) {
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ else if (dot_v3v3(R[2], R[1]) < 1) {
+ cross_v3_v3v3(R[0], R[1], R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
else {
float vec[3];
- vec[0] = mat[2][1];
- vec[1] = mat[2][2];
- vec[2] = mat[2][0];
+ vec[0] = R[2][1];
+ vec[1] = R[2][2];
+ vec[2] = R[2][0];
- cross_v3_v3v3(mat[0], vec, mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ cross_v3_v3v3(R[0], vec, R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
break;
default:
BLI_assert(0);
break;
}
- mul_v3_fl(mat[0], size[0]);
- mul_v3_fl(mat[1], size[1]);
- mul_v3_fl(mat[2], size[2]);
+ mul_v3_fl(R[0], size[0]);
+ mul_v3_fl(R[1], size[1]);
+ mul_v3_fl(R[2], size[2]);
}
/** Make an orthonormal basis around v1 in a way that is stable and symmetric. */
@@ -1793,84 +1792,84 @@ bool is_uniform_scaled_m4(const float m[4][4])
return is_uniform_scaled_m3(t);
}
-void normalize_m2_ex(float mat[2][2], float r_scale[2])
+void normalize_m2_ex(float R[2][2], float r_scale[2])
{
int i;
for (i = 0; i < 2; i++) {
- r_scale[i] = normalize_v2(mat[i]);
+ r_scale[i] = normalize_v2(R[i]);
}
}
-void normalize_m2(float mat[2][2])
+void normalize_m2(float R[2][2])
{
int i;
for (i = 0; i < 2; i++) {
- normalize_v2(mat[i]);
+ normalize_v2(R[i]);
}
}
-void normalize_m2_m2_ex(float rmat[2][2], const float mat[2][2], float r_scale[2])
+void normalize_m2_m2_ex(float R[2][2], const float M[2][2], float r_scale[2])
{
int i;
for (i = 0; i < 2; i++) {
- r_scale[i] = normalize_v2_v2(rmat[i], mat[i]);
+ r_scale[i] = normalize_v2_v2(R[i], M[i]);
}
}
-void normalize_m2_m2(float rmat[2][2], const float mat[2][2])
+void normalize_m2_m2(float R[2][2], const float M[2][2])
{
int i;
for (i = 0; i < 2; i++) {
- normalize_v2_v2(rmat[i], mat[i]);
+ normalize_v2_v2(R[i], M[i]);
}
}
-void normalize_m3_ex(float mat[3][3], float r_scale[3])
+void normalize_m3_ex(float R[3][3], float r_scale[3])
{
int i;
for (i = 0; i < 3; i++) {
- r_scale[i] = normalize_v3(mat[i]);
+ r_scale[i] = normalize_v3(R[i]);
}
}
-void normalize_m3(float mat[3][3])
+void normalize_m3(float R[3][3])
{
int i;
for (i = 0; i < 3; i++) {
- normalize_v3(mat[i]);
+ normalize_v3(R[i]);
}
}
-void normalize_m3_m3_ex(float rmat[3][3], const float mat[3][3], float r_scale[3])
+void normalize_m3_m3_ex(float R[3][3], const float M[3][3], float r_scale[3])
{
int i;
for (i = 0; i < 3; i++) {
- r_scale[i] = normalize_v3_v3(rmat[i], mat[i]);
+ r_scale[i] = normalize_v3_v3(R[i], M[i]);
}
}
-void normalize_m3_m3(float rmat[3][3], const float mat[3][3])
+void normalize_m3_m3(float R[3][3], const float M[3][3])
{
int i;
for (i = 0; i < 3; i++) {
- normalize_v3_v3(rmat[i], mat[i]);
+ normalize_v3_v3(R[i], M[i]);
}
}
-void normalize_m4_ex(float mat[4][4], float r_scale[3])
+void normalize_m4_ex(float R[4][4], float r_scale[3])
{
int i;
for (i = 0; i < 3; i++) {
- r_scale[i] = normalize_v3(mat[i]);
+ r_scale[i] = normalize_v3(R[i]);
if (r_scale[i] != 0.0f) {
- mat[i][3] /= r_scale[i];
+ R[i][3] /= r_scale[i];
}
}
}
-void normalize_m4(float mat[4][4])
+void normalize_m4(float R[4][4])
{
int i;
for (i = 0; i < 3; i++) {
- float len = normalize_v3(mat[i]);
+ float len = normalize_v3(R[i]);
if (len != 0.0f) {
- mat[i][3] /= len;
+ R[i][3] /= len;
}
}
}
@@ -1894,75 +1893,75 @@ void normalize_m4_m4(float rmat[4][4], const float mat[4][4])
copy_v4_v4(rmat[3], mat[3]);
}
-void adjoint_m2_m2(float m1[2][2], const float m[2][2])
+void adjoint_m2_m2(float R[2][2], const float M[2][2])
{
- BLI_assert(m1 != m);
- m1[0][0] = m[1][1];
- m1[0][1] = -m[0][1];
- m1[1][0] = -m[1][0];
- m1[1][1] = m[0][0];
+ BLI_assert(R != M);
+ R[0][0] = M[1][1];
+ R[0][1] = -M[0][1];
+ R[1][0] = -M[1][0];
+ R[1][1] = M[0][0];
}
-void adjoint_m3_m3(float m1[3][3], const float m[3][3])
+void adjoint_m3_m3(float R[3][3], const float M[3][3])
{
- BLI_assert(m1 != m);
- m1[0][0] = m[1][1] * m[2][2] - m[1][2] * m[2][1];
- m1[0][1] = -m[0][1] * m[2][2] + m[0][2] * m[2][1];
- m1[0][2] = m[0][1] * m[1][2] - m[0][2] * m[1][1];
+ BLI_assert(R != M);
+ R[0][0] = M[1][1] * M[2][2] - M[1][2] * M[2][1];
+ R[0][1] = -M[0][1] * M[2][2] + M[0][2] * M[2][1];
+ R[0][2] = M[0][1] * M[1][2] - M[0][2] * M[1][1];
- m1[1][0] = -m[1][0] * m[2][2] + m[1][2] * m[2][0];
- m1[1][1] = m[0][0] * m[2][2] - m[0][2] * m[2][0];
- m1[1][2] = -m[0][0] * m[1][2] + m[0][2] * m[1][0];
+ R[1][0] = -M[1][0] * M[2][2] + M[1][2] * M[2][0];
+ R[1][1] = M[0][0] * M[2][2] - M[0][2] * M[2][0];
+ R[1][2] = -M[0][0] * M[1][2] + M[0][2] * M[1][0];
- m1[2][0] = m[1][0] * m[2][1] - m[1][1] * m[2][0];
- m1[2][1] = -m[0][0] * m[2][1] + m[0][1] * m[2][0];
- m1[2][2] = m[0][0] * m[1][1] - m[0][1] * m[1][0];
+ R[2][0] = M[1][0] * M[2][1] - M[1][1] * M[2][0];
+ R[2][1] = -M[0][0] * M[2][1] + M[0][1] * M[2][0];
+ R[2][2] = M[0][0] * M[1][1] - M[0][1] * M[1][0];
}
-void adjoint_m4_m4(float out[4][4], const float in[4][4]) /* out = ADJ(in) */
+void adjoint_m4_m4(float R[4][4], const float M[4][4]) /* out = ADJ(in) */
{
float a1, a2, a3, a4, b1, b2, b3, b4;
float c1, c2, c3, c4, d1, d2, d3, d4;
- a1 = in[0][0];
- b1 = in[0][1];
- c1 = in[0][2];
- d1 = in[0][3];
+ a1 = M[0][0];
+ b1 = M[0][1];
+ c1 = M[0][2];
+ d1 = M[0][3];
- a2 = in[1][0];
- b2 = in[1][1];
- c2 = in[1][2];
- d2 = in[1][3];
+ a2 = M[1][0];
+ b2 = M[1][1];
+ c2 = M[1][2];
+ d2 = M[1][3];
- a3 = in[2][0];
- b3 = in[2][1];
- c3 = in[2][2];
- d3 = in[2][3];
+ a3 = M[2][0];
+ b3 = M[2][1];
+ c3 = M[2][2];
+ d3 = M[2][3];
- a4 = in[3][0];
- b4 = in[3][1];
- c4 = in[3][2];
- d4 = in[3][3];
+ a4 = M[3][0];
+ b4 = M[3][1];
+ c4 = M[3][2];
+ d4 = M[3][3];
- out[0][0] = determinant_m3(b2, b3, b4, c2, c3, c4, d2, d3, d4);
- out[1][0] = -determinant_m3(a2, a3, a4, c2, c3, c4, d2, d3, d4);
- out[2][0] = determinant_m3(a2, a3, a4, b2, b3, b4, d2, d3, d4);
- out[3][0] = -determinant_m3(a2, a3, a4, b2, b3, b4, c2, c3, c4);
+ R[0][0] = determinant_m3(b2, b3, b4, c2, c3, c4, d2, d3, d4);
+ R[1][0] = -determinant_m3(a2, a3, a4, c2, c3, c4, d2, d3, d4);
+ R[2][0] = determinant_m3(a2, a3, a4, b2, b3, b4, d2, d3, d4);
+ R[3][0] = -determinant_m3(a2, a3, a4, b2, b3, b4, c2, c3, c4);
- out[0][1] = -determinant_m3(b1, b3, b4, c1, c3, c4, d1, d3, d4);
- out[1][1] = determinant_m3(a1, a3, a4, c1, c3, c4, d1, d3, d4);
- out[2][1] = -determinant_m3(a1, a3, a4, b1, b3, b4, d1, d3, d4);
- out[3][1] = determinant_m3(a1, a3, a4, b1, b3, b4, c1, c3, c4);
+ R[0][1] = -determinant_m3(b1, b3, b4, c1, c3, c4, d1, d3, d4);
+ R[1][1] = determinant_m3(a1, a3, a4, c1, c3, c4, d1, d3, d4);
+ R[2][1] = -determinant_m3(a1, a3, a4, b1, b3, b4, d1, d3, d4);
+ R[3][1] = determinant_m3(a1, a3, a4, b1, b3, b4, c1, c3, c4);
- out[0][2] = determinant_m3(b1, b2, b4, c1, c2, c4, d1, d2, d4);
- out[1][2] = -determinant_m3(a1, a2, a4, c1, c2, c4, d1, d2, d4);
- out[2][2] = determinant_m3(a1, a2, a4, b1, b2, b4, d1, d2, d4);
- out[3][2] = -determinant_m3(a1, a2, a4, b1, b2, b4, c1, c2, c4);
+ R[0][2] = determinant_m3(b1, b2, b4, c1, c2, c4, d1, d2, d4);
+ R[1][2] = -determinant_m3(a1, a2, a4, c1, c2, c4, d1, d2, d4);
+ R[2][2] = determinant_m3(a1, a2, a4, b1, b2, b4, d1, d2, d4);
+ R[3][2] = -determinant_m3(a1, a2, a4, b1, b2, b4, c1, c2, c4);
- out[0][3] = -determinant_m3(b1, b2, b3, c1, c2, c3, d1, d2, d3);
- out[1][3] = determinant_m3(a1, a2, a3, c1, c2, c3, d1, d2, d3);
- out[2][3] = -determinant_m3(a1, a2, a3, b1, b2, b3, d1, d2, d3);
- out[3][3] = determinant_m3(a1, a2, a3, b1, b2, b3, c1, c2, c3);
+ R[0][3] = -determinant_m3(b1, b2, b3, c1, c2, c3, d1, d2, d3);
+ R[1][3] = determinant_m3(a1, a2, a3, c1, c2, c3, d1, d2, d3);
+ R[2][3] = -determinant_m3(a1, a2, a3, b1, b2, b3, d1, d2, d3);
+ R[3][3] = determinant_m3(a1, a2, a3, b1, b2, b3, c1, c2, c3);
}
float determinant_m2(float a, float b, float c, float d)
@@ -2017,65 +2016,65 @@ float determinant_m4(const float m[4][4])
/****************************** Transformations ******************************/
-void size_to_mat3(float mat[3][3], const float size[3])
+void size_to_mat3(float R[3][3], const float size[3])
{
- mat[0][0] = size[0];
- mat[0][1] = 0.0f;
- mat[0][2] = 0.0f;
- mat[1][1] = size[1];
- mat[1][0] = 0.0f;
- mat[1][2] = 0.0f;
- mat[2][2] = size[2];
- mat[2][1] = 0.0f;
- mat[2][0] = 0.0f;
+ R[0][0] = size[0];
+ R[0][1] = 0.0f;
+ R[0][2] = 0.0f;
+ R[1][1] = size[1];
+ R[1][0] = 0.0f;
+ R[1][2] = 0.0f;
+ R[2][2] = size[2];
+ R[2][1] = 0.0f;
+ R[2][0] = 0.0f;
}
-void size_to_mat4(float mat[4][4], const float size[3])
+void size_to_mat4(float R[4][4], const float size[3])
{
- mat[0][0] = size[0];
- mat[0][1] = 0.0f;
- mat[0][2] = 0.0f;
- mat[0][3] = 0.0f;
- mat[1][0] = 0.0f;
- mat[1][1] = size[1];
- mat[1][2] = 0.0f;
- mat[1][3] = 0.0f;
- mat[2][0] = 0.0f;
- mat[2][1] = 0.0f;
- mat[2][2] = size[2];
- mat[2][3] = 0.0f;
- mat[3][0] = 0.0f;
- mat[3][1] = 0.0f;
- mat[3][2] = 0.0f;
- mat[3][3] = 1.0f;
+ R[0][0] = size[0];
+ R[0][1] = 0.0f;
+ R[0][2] = 0.0f;
+ R[0][3] = 0.0f;
+ R[1][0] = 0.0f;
+ R[1][1] = size[1];
+ R[1][2] = 0.0f;
+ R[1][3] = 0.0f;
+ R[2][0] = 0.0f;
+ R[2][1] = 0.0f;
+ R[2][2] = size[2];
+ R[2][3] = 0.0f;
+ R[3][0] = 0.0f;
+ R[3][1] = 0.0f;
+ R[3][2] = 0.0f;
+ R[3][3] = 1.0f;
}
-void mat3_to_size(float size[3], const float mat[3][3])
+void mat3_to_size(float size[3], const float M[3][3])
{
- size[0] = len_v3(mat[0]);
- size[1] = len_v3(mat[1]);
- size[2] = len_v3(mat[2]);
+ size[0] = len_v3(M[0]);
+ size[1] = len_v3(M[1]);
+ size[2] = len_v3(M[2]);
}
-void mat4_to_size(float size[3], const float mat[4][4])
+void mat4_to_size(float size[3], const float M[4][4])
{
- size[0] = len_v3(mat[0]);
- size[1] = len_v3(mat[1]);
- size[2] = len_v3(mat[2]);
+ size[0] = len_v3(M[0]);
+ size[1] = len_v3(M[1]);
+ size[2] = len_v3(M[2]);
}
/**
* Extract scale factors from the matrix, with correction to ensure
* exact volume in case of a sheared matrix.
*/
-void mat4_to_size_fix_shear(float size[3], const float mat[4][4])
+void mat4_to_size_fix_shear(float size[3], const float M[4][4])
{
- mat4_to_size(size, mat);
+ mat4_to_size(size, M);
float volume = size[0] * size[1] * size[2];
if (volume != 0.0f) {
- mul_v3_fl(size, cbrtf(fabsf(mat4_to_volume_scale(mat) / volume)));
+ mul_v3_fl(size, cbrtf(fabsf(mat4_to_volume_scale(M) / volume)));
}
}
@@ -2203,22 +2202,22 @@ void mat3_polar_decompose(const float mat3[3][3], float r_U[3][3], float r_P[3][
}
#endif
-void scale_m3_fl(float m[3][3], float scale)
+void scale_m3_fl(float R[3][3], float scale)
{
- m[0][0] = m[1][1] = m[2][2] = scale;
- m[0][1] = m[0][2] = 0.0;
- m[1][0] = m[1][2] = 0.0;
- m[2][0] = m[2][1] = 0.0;
+ R[0][0] = R[1][1] = R[2][2] = scale;
+ R[0][1] = R[0][2] = 0.0;
+ R[1][0] = R[1][2] = 0.0;
+ R[2][0] = R[2][1] = 0.0;
}
-void scale_m4_fl(float m[4][4], float scale)
+void scale_m4_fl(float R[4][4], float scale)
{
- m[0][0] = m[1][1] = m[2][2] = scale;
- m[3][3] = 1.0;
- m[0][1] = m[0][2] = m[0][3] = 0.0;
- m[1][0] = m[1][2] = m[1][3] = 0.0;
- m[2][0] = m[2][1] = m[2][3] = 0.0;
- m[3][0] = m[3][1] = m[3][2] = 0.0;
+ R[0][0] = R[1][1] = R[2][2] = scale;
+ R[3][3] = 1.0;
+ R[0][1] = R[0][2] = R[0][3] = 0.0;
+ R[1][0] = R[1][2] = R[1][3] = 0.0;
+ R[2][0] = R[2][1] = R[2][3] = 0.0;
+ R[3][0] = R[3][1] = R[3][2] = 0.0;
}
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
@@ -2486,14 +2485,14 @@ bool equals_m4m4(const float mat1[4][4], const float mat2[4][4])
* Make a 4x4 matrix out of 3 transform components.
* Matrices are made in the order: `scale * rot * loc`
*/
-void loc_rot_size_to_mat4(float mat[4][4],
+void loc_rot_size_to_mat4(float R[4][4],
const float loc[3],
const float rot[3][3],
const float size[3])
{
- copy_m4_m3(mat, rot);
- rescale_m4(mat, size);
- copy_v3_v3(mat[3], loc);
+ copy_m4_m3(R, rot);
+ rescale_m4(R, size);
+ copy_v3_v3(R[3], loc);
}
/**
@@ -2502,7 +2501,7 @@ void loc_rot_size_to_mat4(float mat[4][4],
*
* TODO: need to have a version that allows for rotation order...
*/
-void loc_eul_size_to_mat4(float mat[4][4],
+void loc_eul_size_to_mat4(float R[4][4],
const float loc[3],
const float eul[3],
const float size[3])
@@ -2510,7 +2509,7 @@ void loc_eul_size_to_mat4(float mat[4][4],
float rmat[3][3], smat[3][3], tmat[3][3];
/* initialize new matrix */
- unit_m4(mat);
+ unit_m4(R);
/* make rotation + scaling part */
eul_to_mat3(rmat, eul);
@@ -2518,19 +2517,19 @@ void loc_eul_size_to_mat4(float mat[4][4],
mul_m3_m3m3(tmat, rmat, smat);
/* copy rot/scale part to output matrix*/
- copy_m4_m3(mat, tmat);
+ copy_m4_m3(R, tmat);
/* copy location to matrix */
- mat[3][0] = loc[0];
- mat[3][1] = loc[1];
- mat[3][2] = loc[2];
+ R[3][0] = loc[0];
+ R[3][1] = loc[1];
+ R[3][2] = loc[2];
}
/**
* Make a 4x4 matrix out of 3 transform components.
* Matrices are made in the order: `scale * rot * loc`
*/
-void loc_eulO_size_to_mat4(float mat[4][4],
+void loc_eulO_size_to_mat4(float R[4][4],
const float loc[3],
const float eul[3],
const float size[3],
@@ -2539,7 +2538,7 @@ void loc_eulO_size_to_mat4(float mat[4][4],
float rmat[3][3], smat[3][3], tmat[3][3];
/* initialize new matrix */
- unit_m4(mat);
+ unit_m4(R);
/* make rotation + scaling part */
eulO_to_mat3(rmat, eul, rotOrder);
@@ -2547,19 +2546,19 @@ void loc_eulO_size_to_mat4(float mat[4][4],
mul_m3_m3m3(tmat, rmat, smat);
/* copy rot/scale part to output matrix*/
- copy_m4_m3(mat, tmat);
+ copy_m4_m3(R, tmat);
/* copy location to matrix */
- mat[3][0] = loc[0];
- mat[3][1] = loc[1];
- mat[3][2] = loc[2];
+ R[3][0] = loc[0];
+ R[3][1] = loc[1];
+ R[3][2] = loc[2];
}
/**
* Make a 4x4 matrix out of 3 transform components.
* Matrices are made in the order: `scale * rot * loc`
*/
-void loc_quat_size_to_mat4(float mat[4][4],
+void loc_quat_size_to_mat4(float R[4][4],
const float loc[3],
const float quat[4],
const float size[3])
@@ -2567,7 +2566,7 @@ void loc_quat_size_to_mat4(float mat[4][4],
float rmat[3][3], smat[3][3], tmat[3][3];
/* initialize new matrix */
- unit_m4(mat);
+ unit_m4(R);
/* make rotation + scaling part */
quat_to_mat3(rmat, quat);
@@ -2575,23 +2574,20 @@ void loc_quat_size_to_mat4(float mat[4][4],
mul_m3_m3m3(tmat, rmat, smat);
/* copy rot/scale part to output matrix*/
- copy_m4_m3(mat, tmat);
+ copy_m4_m3(R, tmat);
/* copy location to matrix */
- mat[3][0] = loc[0];
- mat[3][1] = loc[1];
- mat[3][2] = loc[2];
+ R[3][0] = loc[0];
+ R[3][1] = loc[1];
+ R[3][2] = loc[2];
}
-void loc_axisangle_size_to_mat4(float mat[4][4],
- const float loc[3],
- const float axis[3],
- const float angle,
- const float size[3])
+void loc_axisangle_size_to_mat4(
+ float R[4][4], const float loc[3], const float axis[3], const float angle, const float size[3])
{
float q[4];
axis_angle_to_quat(q, axis, angle);
- loc_quat_size_to_mat4(mat, loc, q, size);
+ loc_quat_size_to_mat4(R, loc, q, size);
}
/*********************************** Other ***********************************/
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index d38c081ec2b..7c4ac934695 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -50,12 +50,12 @@ void unit_qt(float q[4])
q[1] = q[2] = q[3] = 0.0f;
}
-void copy_qt_qt(float q1[4], const float q2[4])
+void copy_qt_qt(float q[4], const float a[4])
{
- q1[0] = q2[0];
- q1[1] = q2[1];
- q1[2] = q2[2];
- q1[3] = q2[3];
+ q[0] = a[0];
+ q[1] = a[1];
+ q[2] = a[2];
+ q[3] = a[3];
}
bool is_zero_qt(const float q[4])
@@ -63,14 +63,14 @@ bool is_zero_qt(const float q[4])
return (q[0] == 0 && q[1] == 0 && q[2] == 0 && q[3] == 0);
}
-void mul_qt_qtqt(float q[4], const float q1[4], const float q2[4])
+void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
{
float t0, t1, t2;
- t0 = q1[0] * q2[0] - q1[1] * q2[1] - q1[2] * q2[2] - q1[3] * q2[3];
- t1 = q1[0] * q2[1] + q1[1] * q2[0] + q1[2] * q2[3] - q1[3] * q2[2];
- t2 = q1[0] * q2[2] + q1[2] * q2[0] + q1[3] * q2[1] - q1[1] * q2[3];
- q[3] = q1[0] * q2[3] + q1[3] * q2[0] + q1[1] * q2[2] - q1[2] * q2[1];
+ t0 = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
+ t1 = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
+ t2 = a[0] * b[2] + a[2] * b[0] + a[3] * b[1] - a[1] * b[3];
+ q[3] = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
q[0] = t0;
q[1] = t1;
q[2] = t2;
@@ -95,22 +95,22 @@ void mul_qt_qtqt(float q[4], const float q1[4], const float q2[4])
*
* \note Multiplying by 3x3 matrix is ~25% faster.
*/
-void mul_qt_v3(const float q[4], float v[3])
+void mul_qt_v3(const float q[4], float r[3])
{
float t0, t1, t2;
- t0 = -q[1] * v[0] - q[2] * v[1] - q[3] * v[2];
- t1 = q[0] * v[0] + q[2] * v[2] - q[3] * v[1];
- t2 = q[0] * v[1] + q[3] * v[0] - q[1] * v[2];
- v[2] = q[0] * v[2] + q[1] * v[1] - q[2] * v[0];
- v[0] = t1;
- v[1] = t2;
+ t0 = -q[1] * r[0] - q[2] * r[1] - q[3] * r[2];
+ t1 = q[0] * r[0] + q[2] * r[2] - q[3] * r[1];
+ t2 = q[0] * r[1] + q[3] * r[0] - q[1] * r[2];
+ r[2] = q[0] * r[2] + q[1] * r[1] - q[2] * r[0];
+ r[0] = t1;
+ r[1] = t2;
- t1 = t0 * -q[1] + v[0] * q[0] - v[1] * q[3] + v[2] * q[2];
- t2 = t0 * -q[2] + v[1] * q[0] - v[2] * q[1] + v[0] * q[3];
- v[2] = t0 * -q[3] + v[2] * q[0] - v[0] * q[2] + v[1] * q[1];
- v[0] = t1;
- v[1] = t2;
+ t1 = t0 * -q[1] + r[0] * q[0] - r[1] * q[3] + r[2] * q[2];
+ t2 = t0 * -q[2] + r[1] * q[0] - r[2] * q[1] + r[0] * q[3];
+ r[2] = t0 * -q[3] + r[2] * q[0] - r[0] * q[2] + r[1] * q[1];
+ r[0] = t1;
+ r[1] = t2;
}
void conjugate_qt_qt(float q1[4], const float q2[4])
@@ -128,9 +128,9 @@ void conjugate_qt(float q[4])
q[3] = -q[3];
}
-float dot_qtqt(const float q1[4], const float q2[4])
+float dot_qtqt(const float a[4], const float b[4])
{
- return q1[0] * q2[0] + q1[1] * q2[1] + q1[2] * q2[2] + q1[3] * q2[3];
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
}
void invert_qt(float q[4])
@@ -177,16 +177,16 @@ void mul_qt_fl(float q[4], const float f)
q[3] *= f;
}
-void sub_qt_qtqt(float q[4], const float q1[4], const float q2[4])
+void sub_qt_qtqt(float q[4], const float a[4], const float b[4])
{
- float nq2[4];
+ float n_b[4];
- nq2[0] = -q2[0];
- nq2[1] = q2[1];
- nq2[2] = q2[2];
- nq2[3] = q2[3];
+ n_b[0] = -b[0];
+ n_b[1] = b[1];
+ n_b[2] = b[2];
+ n_b[3] = b[3];
- mul_qt_qtqt(q, q1, nq2);
+ mul_qt_qtqt(q, a, n_b);
}
/* raise a unit quaternion to the specified power */
@@ -867,38 +867,38 @@ void interp_dot_slerp(const float t, const float cosom, float r_w[2])
}
}
-void interp_qt_qtqt(float result[4], const float quat1[4], const float quat2[4], const float t)
+void interp_qt_qtqt(float q[4], const float a[4], const float b[4], const float t)
{
float quat[4], cosom, w[2];
- BLI_ASSERT_UNIT_QUAT(quat1);
- BLI_ASSERT_UNIT_QUAT(quat2);
+ BLI_ASSERT_UNIT_QUAT(a);
+ BLI_ASSERT_UNIT_QUAT(b);
- cosom = dot_qtqt(quat1, quat2);
+ cosom = dot_qtqt(a, b);
/* rotate around shortest angle */
if (cosom < 0.0f) {
cosom = -cosom;
- negate_v4_v4(quat, quat1);
+ negate_v4_v4(quat, a);
}
else {
- copy_qt_qt(quat, quat1);
+ copy_qt_qt(quat, a);
}
interp_dot_slerp(t, cosom, w);
- result[0] = w[0] * quat[0] + w[1] * quat2[0];
- result[1] = w[0] * quat[1] + w[1] * quat2[1];
- result[2] = w[0] * quat[2] + w[1] * quat2[2];
- result[3] = w[0] * quat[3] + w[1] * quat2[3];
+ q[0] = w[0] * quat[0] + w[1] * b[0];
+ q[1] = w[0] * quat[1] + w[1] * b[1];
+ q[2] = w[0] * quat[2] + w[1] * b[2];
+ q[3] = w[0] * quat[3] + w[1] * b[3];
}
-void add_qt_qtqt(float result[4], const float quat1[4], const float quat2[4], const float t)
+void add_qt_qtqt(float q[4], const float a[4], const float b[4], const float t)
{
- result[0] = quat1[0] + t * quat2[0];
- result[1] = quat1[1] + t * quat2[1];
- result[2] = quat1[2] + t * quat2[2];
- result[3] = quat1[3] + t * quat2[3];
+ q[0] = a[0] + t * b[0];
+ q[1] = a[1] + t * b[1];
+ q[2] = a[2] + t * b[2];
+ q[3] = a[3] + t * b[3];
}
/* same as tri_to_quat() but takes pre-computed normal from the triangle
@@ -958,12 +958,12 @@ void tri_to_quat_ex(
/**
* \return the length of the normal, use to test for degenerate triangles.
*/
-float tri_to_quat(float quat[4], const float v1[3], const float v2[3], const float v3[3])
+float tri_to_quat(float q[4], const float a[3], const float b[3], const float c[3])
{
float vec[3];
- const float len = normal_tri_v3(vec, v1, v2, v3);
+ const float len = normal_tri_v3(vec, a, b, c);
- tri_to_quat_ex(quat, v1, v2, v3, vec);
+ tri_to_quat_ex(q, a, b, c, vec);
return len;
}
@@ -974,25 +974,25 @@ void print_qt(const char *str, const float q[4])
/******************************** Axis Angle *********************************/
-void axis_angle_normalized_to_quat(float q[4], const float axis[3], const float angle)
+void axis_angle_normalized_to_quat(float r[4], const float axis[3], const float angle)
{
const float phi = 0.5f * angle;
const float si = sinf(phi);
const float co = cosf(phi);
BLI_ASSERT_UNIT_V3(axis);
- q[0] = co;
- mul_v3_v3fl(q + 1, axis, si);
+ r[0] = co;
+ mul_v3_v3fl(r + 1, axis, si);
}
-void axis_angle_to_quat(float q[4], const float axis[3], const float angle)
+void axis_angle_to_quat(float r[4], const float axis[3], const float angle)
{
float nor[3];
if (LIKELY(normalize_v3_v3(nor, axis) != 0.0f)) {
- axis_angle_normalized_to_quat(q, nor, angle);
+ axis_angle_normalized_to_quat(r, nor, angle);
}
else {
- unit_qt(q);
+ unit_qt(r);
}
}
@@ -1094,33 +1094,33 @@ void axis_angle_normalized_to_mat3_ex(float mat[3][3],
mat[2][2] = n_22 + angle_cos;
}
-void axis_angle_normalized_to_mat3(float mat[3][3], const float axis[3], const float angle)
+void axis_angle_normalized_to_mat3(float R[3][3], const float axis[3], const float angle)
{
- axis_angle_normalized_to_mat3_ex(mat, axis, sinf(angle), cosf(angle));
+ axis_angle_normalized_to_mat3_ex(R, axis, sinf(angle), cosf(angle));
}
/* axis angle to 3x3 matrix - safer version (normalization of axis performed) */
-void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle)
+void axis_angle_to_mat3(float R[3][3], const float axis[3], const float angle)
{
float nor[3];
/* normalize the axis first (to remove unwanted scaling) */
if (normalize_v3_v3(nor, axis) == 0.0f) {
- unit_m3(mat);
+ unit_m3(R);
return;
}
- axis_angle_normalized_to_mat3(mat, nor, angle);
+ axis_angle_normalized_to_mat3(R, nor, angle);
}
/* axis angle to 4x4 matrix - safer version (normalization of axis performed) */
-void axis_angle_to_mat4(float mat[4][4], const float axis[3], const float angle)
+void axis_angle_to_mat4(float R[4][4], const float axis[3], const float angle)
{
float tmat[3][3];
axis_angle_to_mat3(tmat, axis, angle);
- unit_m4(mat);
- copy_m4_m3(mat, tmat);
+ unit_m4(R);
+ copy_m4_m3(R, tmat);
}
/* 3x3 matrix to axis angle */
@@ -1165,52 +1165,52 @@ void mat4_to_axis_angle(float axis[3], float *angle, const float mat[4][4])
quat_to_axis_angle(axis, angle, q);
}
-void axis_angle_to_mat4_single(float mat[4][4], const char axis, const float angle)
+void axis_angle_to_mat4_single(float R[4][4], const char axis, const float angle)
{
float mat3[3][3];
axis_angle_to_mat3_single(mat3, axis, angle);
- copy_m4_m3(mat, mat3);
+ copy_m4_m3(R, mat3);
}
/* rotation matrix from a single axis */
-void axis_angle_to_mat3_single(float mat[3][3], const char axis, const float angle)
+void axis_angle_to_mat3_single(float R[3][3], const char axis, const float angle)
{
const float angle_cos = cosf(angle);
const float angle_sin = sinf(angle);
switch (axis) {
case 'X': /* rotation around X */
- mat[0][0] = 1.0f;
- mat[0][1] = 0.0f;
- mat[0][2] = 0.0f;
- mat[1][0] = 0.0f;
- mat[1][1] = angle_cos;
- mat[1][2] = angle_sin;
- mat[2][0] = 0.0f;
- mat[2][1] = -angle_sin;
- mat[2][2] = angle_cos;
+ R[0][0] = 1.0f;
+ R[0][1] = 0.0f;
+ R[0][2] = 0.0f;
+ R[1][0] = 0.0f;
+ R[1][1] = angle_cos;
+ R[1][2] = angle_sin;
+ R[2][0] = 0.0f;
+ R[2][1] = -angle_sin;
+ R[2][2] = angle_cos;
break;
case 'Y': /* rotation around Y */
- mat[0][0] = angle_cos;
- mat[0][1] = 0.0f;
- mat[0][2] = -angle_sin;
- mat[1][0] = 0.0f;
- mat[1][1] = 1.0f;
- mat[1][2] = 0.0f;
- mat[2][0] = angle_sin;
- mat[2][1] = 0.0f;
- mat[2][2] = angle_cos;
+ R[0][0] = angle_cos;
+ R[0][1] = 0.0f;
+ R[0][2] = -angle_sin;
+ R[1][0] = 0.0f;
+ R[1][1] = 1.0f;
+ R[1][2] = 0.0f;
+ R[2][0] = angle_sin;
+ R[2][1] = 0.0f;
+ R[2][2] = angle_cos;
break;
case 'Z': /* rotation around Z */
- mat[0][0] = angle_cos;
- mat[0][1] = angle_sin;
- mat[0][2] = 0.0f;
- mat[1][0] = -angle_sin;
- mat[1][1] = angle_cos;
- mat[1][2] = 0.0f;
- mat[2][0] = 0.0f;
- mat[2][1] = 0.0f;
- mat[2][2] = 1.0f;
+ R[0][0] = angle_cos;
+ R[0][1] = angle_sin;
+ R[0][2] = 0.0f;
+ R[1][0] = -angle_sin;
+ R[1][1] = angle_cos;
+ R[1][2] = 0.0f;
+ R[2][0] = 0.0f;
+ R[2][1] = 0.0f;
+ R[2][2] = 1.0f;
break;
default:
BLI_assert(0);
@@ -1218,16 +1218,16 @@ void axis_angle_to_mat3_single(float mat[3][3], const char axis, const float ang
}
}
-void angle_to_mat2(float mat[2][2], const float angle)
+void angle_to_mat2(float R[2][2], const float angle)
{
const float angle_cos = cosf(angle);
const float angle_sin = sinf(angle);
/* 2D rotation matrix */
- mat[0][0] = angle_cos;
- mat[0][1] = angle_sin;
- mat[1][0] = -angle_sin;
- mat[1][1] = angle_cos;
+ R[0][0] = angle_cos;
+ R[0][1] = angle_sin;
+ R[1][0] = -angle_sin;
+ R[1][1] = angle_cos;
}
void axis_angle_to_quat_single(float q[4], const char axis, const float angle)
@@ -1989,7 +1989,7 @@ void mat4_to_dquat(DualQuat *dq, const float basemat[4][4], const float mat[4][4
dq->trans[3] = 0.5f * (t[0] * q[2] - t[1] * q[1] + t[2] * q[0]);
}
-void dquat_to_mat4(float mat[4][4], const DualQuat *dq)
+void dquat_to_mat4(float R[4][4], const DualQuat *dq)
{
float len, q0[4];
const float *t;
@@ -2005,40 +2005,40 @@ void dquat_to_mat4(float mat[4][4], const DualQuat *dq)
mul_qt_fl(q0, len);
/* rotation */
- quat_to_mat4(mat, q0);
+ quat_to_mat4(R, q0);
/* translation */
t = dq->trans;
- mat[3][0] = 2.0f * (-t[0] * q0[1] + t[1] * q0[0] - t[2] * q0[3] + t[3] * q0[2]) * len;
- mat[3][1] = 2.0f * (-t[0] * q0[2] + t[1] * q0[3] + t[2] * q0[0] - t[3] * q0[1]) * len;
- mat[3][2] = 2.0f * (-t[0] * q0[3] - t[1] * q0[2] + t[2] * q0[1] + t[3] * q0[0]) * len;
+ R[3][0] = 2.0f * (-t[0] * q0[1] + t[1] * q0[0] - t[2] * q0[3] + t[3] * q0[2]) * len;
+ R[3][1] = 2.0f * (-t[0] * q0[2] + t[1] * q0[3] + t[2] * q0[0] - t[3] * q0[1]) * len;
+ R[3][2] = 2.0f * (-t[0] * q0[3] - t[1] * q0[2] + t[2] * q0[1] + t[3] * q0[0]) * len;
/* scaling */
if (dq->scale_weight) {
- mul_m4_m4m4(mat, mat, dq->scale);
+ mul_m4_m4m4(R, R, dq->scale);
}
}
-void add_weighted_dq_dq(DualQuat *dqsum, const DualQuat *dq, float weight)
+void add_weighted_dq_dq(DualQuat *dq_sum, const DualQuat *dq, float weight)
{
bool flipped = false;
/* make sure we interpolate quats in the right direction */
- if (dot_qtqt(dq->quat, dqsum->quat) < 0) {
+ if (dot_qtqt(dq->quat, dq_sum->quat) < 0) {
flipped = true;
weight = -weight;
}
/* interpolate rotation and translation */
- dqsum->quat[0] += weight * dq->quat[0];
- dqsum->quat[1] += weight * dq->quat[1];
- dqsum->quat[2] += weight * dq->quat[2];
- dqsum->quat[3] += weight * dq->quat[3];
+ dq_sum->quat[0] += weight * dq->quat[0];
+ dq_sum->quat[1] += weight * dq->quat[1];
+ dq_sum->quat[2] += weight * dq->quat[2];
+ dq_sum->quat[3] += weight * dq->quat[3];
- dqsum->trans[0] += weight * dq->trans[0];
- dqsum->trans[1] += weight * dq->trans[1];
- dqsum->trans[2] += weight * dq->trans[2];
- dqsum->trans[3] += weight * dq->trans[3];
+ dq_sum->trans[0] += weight * dq->trans[0];
+ dq_sum->trans[1] += weight * dq->trans[1];
+ dq_sum->trans[2] += weight * dq->trans[2];
+ dq_sum->trans[3] += weight * dq->trans[3];
/* Interpolate scale - but only if there is scale present. If any dual
* quaternions without scale are added, they will be compensated for in
@@ -2053,8 +2053,8 @@ void add_weighted_dq_dq(DualQuat *dqsum, const DualQuat *dq, float weight)
copy_m4_m4(wmat, (float(*)[4])dq->scale);
mul_m4_fl(wmat, weight);
- add_m4_m4m4(dqsum->scale, dqsum->scale, wmat);
- dqsum->scale_weight += weight;
+ add_m4_m4m4(dq_sum->scale, dq_sum->scale, wmat);
+ dq_sum->scale_weight += weight;
}
}
@@ -2083,7 +2083,7 @@ void normalize_dq(DualQuat *dq, float totweight)
}
}
-void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
+void mul_v3m3_dq(float r[3], float R[3][3], DualQuat *dq)
{
float M[3][3], t[3], scalemat[3][3], len2;
float w = dq->quat[0], x = dq->quat[1], y = dq->quat[2], z = dq->quat[3];
@@ -2114,31 +2114,31 @@ void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
/* apply scaling */
if (dq->scale_weight) {
- mul_m4_v3(dq->scale, co);
+ mul_m4_v3(dq->scale, r);
}
/* apply rotation and translation */
- mul_m3_v3(M, co);
- co[0] = (co[0] + t[0]) * len2;
- co[1] = (co[1] + t[1]) * len2;
- co[2] = (co[2] + t[2]) * len2;
+ mul_m3_v3(M, r);
+ r[0] = (r[0] + t[0]) * len2;
+ r[1] = (r[1] + t[1]) * len2;
+ r[2] = (r[2] + t[2]) * len2;
/* Compute crazy-space correction matrix. */
- if (mat) {
+ if (R) {
if (dq->scale_weight) {
copy_m3_m4(scalemat, dq->scale);
- mul_m3_m3m3(mat, M, scalemat);
+ mul_m3_m3m3(R, M, scalemat);
}
else {
- copy_m3_m3(mat, M);
+ copy_m3_m3(R, M);
}
- mul_m3_fl(mat, len2);
+ mul_m3_fl(R, len2);
}
}
-void copy_dq_dq(DualQuat *dq1, const DualQuat *dq2)
+void copy_dq_dq(DualQuat *r, const DualQuat *dq)
{
- memcpy(dq1, dq2, sizeof(DualQuat));
+ memcpy(r, dq, sizeof(DualQuat));
}
/* axis matches eTrackToAxis_Modes */
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index dc6e213d0b5..4d7efa4b6f4 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -30,40 +30,40 @@
//******************************* Interpolation *******************************/
-void interp_v2_v2v2(float target[2], const float a[2], const float b[2], const float t)
+void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t)
{
const float s = 1.0f - t;
- target[0] = s * a[0] + t * b[0];
- target[1] = s * a[1] + t * b[1];
+ r[0] = s * a[0] + t * b[0];
+ r[1] = s * a[1] + t * b[1];
}
/* weight 3 2D vectors,
* 'w' must be unit length but is not a vector, just 3 weights */
void interp_v2_v2v2v2(
- float p[2], const float v1[2], const float v2[2], const float v3[2], const float w[3])
+ float r[2], const float a[2], const float b[2], const float c[2], const float t[3])
{
- p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2];
- p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2];
+ r[0] = a[0] * t[0] + b[0] * t[1] + c[0] * t[2];
+ r[1] = a[1] * t[0] + b[1] * t[1] + c[1] * t[2];
}
-void interp_v3_v3v3(float target[3], const float a[3], const float b[3], const float t)
+void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
{
const float s = 1.0f - t;
- target[0] = s * a[0] + t * b[0];
- target[1] = s * a[1] + t * b[1];
- target[2] = s * a[2] + t * b[2];
+ r[0] = s * a[0] + t * b[0];
+ r[1] = s * a[1] + t * b[1];
+ r[2] = s * a[2] + t * b[2];
}
-void interp_v4_v4v4(float target[4], const float a[4], const float b[4], const float t)
+void interp_v4_v4v4(float r[4], const float a[4], const float b[4], const float t)
{
const float s = 1.0f - t;
- target[0] = s * a[0] + t * b[0];
- target[1] = s * a[1] + t * b[1];
- target[2] = s * a[2] + t * b[2];
- target[3] = s * a[3] + t * b[3];
+ r[0] = s * a[0] + t * b[0];
+ r[1] = s * a[1] + t * b[1];
+ r[2] = s * a[2] + t * b[2];
+ r[3] = s * a[3] + t * b[3];
}
/**
@@ -267,17 +267,17 @@ void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], const
interp_v4_v4v4_uchar((uchar *)target, (const uchar *)a, (const uchar *)b, t);
}
-void mid_v3_v3v3(float v[3], const float v1[3], const float v2[3])
+void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
{
- v[0] = 0.5f * (v1[0] + v2[0]);
- v[1] = 0.5f * (v1[1] + v2[1]);
- v[2] = 0.5f * (v1[2] + v2[2]);
+ r[0] = 0.5f * (a[0] + b[0]);
+ r[1] = 0.5f * (a[1] + b[1]);
+ r[2] = 0.5f * (a[2] + b[2]);
}
-void mid_v2_v2v2(float v[2], const float v1[2], const float v2[2])
+void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
{
- v[0] = 0.5f * (v1[0] + v2[0]);
- v[1] = 0.5f * (v1[1] + v2[1]);
+ r[0] = 0.5f * (a[0] + b[0]);
+ r[1] = 0.5f * (a[1] + b[1]);
}
void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
@@ -408,12 +408,12 @@ bool is_finite_v4(const float v[4])
* note that when v1/v2/v3 represent 3 points along a straight line
* that the angle returned will be pi (180deg), rather then 0.0
*/
-float angle_v3v3v3(const float v1[3], const float v2[3], const float v3[3])
+float angle_v3v3v3(const float a[3], const float b[3], const float c[3])
{
float vec1[3], vec2[3];
- sub_v3_v3v3(vec1, v2, v1);
- sub_v3_v3v3(vec2, v2, v3);
+ sub_v3_v3v3(vec1, b, a);
+ sub_v3_v3v3(vec2, b, c);
normalize_v3(vec1);
normalize_v3(vec2);
@@ -434,25 +434,25 @@ float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3])
}
/* Return the shortest angle in radians between the 2 vectors */
-float angle_v3v3(const float v1[3], const float v2[3])
+float angle_v3v3(const float a[3], const float b[3])
{
float vec1[3], vec2[3];
- normalize_v3_v3(vec1, v1);
- normalize_v3_v3(vec2, v2);
+ normalize_v3_v3(vec1, a);
+ normalize_v3_v3(vec2, b);
return angle_normalized_v3v3(vec1, vec2);
}
-float angle_v2v2v2(const float v1[2], const float v2[2], const float v3[2])
+float angle_v2v2v2(const float a[2], const float b[2], const float c[2])
{
float vec1[2], vec2[2];
- vec1[0] = v2[0] - v1[0];
- vec1[1] = v2[1] - v1[1];
+ vec1[0] = b[0] - a[0];
+ vec1[1] = b[1] - a[1];
- vec2[0] = v2[0] - v3[0];
- vec2[1] = v2[1] - v3[1];
+ vec2[0] = b[0] - c[0];
+ vec2[1] = b[1] - c[1];
normalize_v2(vec1);
normalize_v2(vec2);
@@ -474,15 +474,15 @@ float cos_v2v2v2(const float p1[2], const float p2[2], const float p3[2])
}
/* Return the shortest angle in radians between the 2 vectors */
-float angle_v2v2(const float v1[2], const float v2[2])
+float angle_v2v2(const float a[2], const float b[2])
{
float vec1[2], vec2[2];
- vec1[0] = v1[0];
- vec1[1] = v1[1];
+ vec1[0] = a[0];
+ vec1[1] = a[1];
- vec2[0] = v2[0];
- vec2[1] = v2[1];
+ vec2[0] = b[0];
+ vec2[1] = b[1];
normalize_v2(vec1);
normalize_v2(vec2);
@@ -512,20 +512,20 @@ float angle_normalized_v3v3(const float v1[3], const float v2[3])
return (float)M_PI - 2.0f * saasin(len_v3v3(v1, v2_n) / 2.0f);
}
-float angle_normalized_v2v2(const float v1[2], const float v2[2])
+float angle_normalized_v2v2(const float a[2], const float b[2])
{
/* double check they are normalized */
- BLI_ASSERT_UNIT_V2(v1);
- BLI_ASSERT_UNIT_V2(v2);
+ BLI_ASSERT_UNIT_V2(a);
+ BLI_ASSERT_UNIT_V2(b);
/* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */
- if (dot_v2v2(v1, v2) >= 0.0f) {
- return 2.0f * saasin(len_v2v2(v1, v2) / 2.0f);
+ if (dot_v2v2(a, b) >= 0.0f) {
+ return 2.0f * saasin(len_v2v2(a, b) / 2.0f);
}
float v2_n[2];
- negate_v2_v2(v2_n, v2);
- return (float)M_PI - 2.0f * saasin(len_v2v2(v1, v2_n) / 2.0f);
+ negate_v2_v2(v2_n, b);
+ return (float)M_PI - 2.0f * saasin(len_v2v2(a, v2_n) / 2.0f);
}
/**
@@ -766,16 +766,16 @@ void project_v3_plane(float out[3], const float plane_no[3], const float plane_c
sub_v3_v3(out, vector);
}
-/* Returns a vector bisecting the angle at v2 formed by v1, v2 and v3 */
-void bisect_v3_v3v3v3(float out[3], const float v1[3], const float v2[3], const float v3[3])
+/* Returns a vector bisecting the angle at b formed by a, b and c */
+void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
{
float d_12[3], d_23[3];
- sub_v3_v3v3(d_12, v2, v1);
- sub_v3_v3v3(d_23, v3, v2);
+ sub_v3_v3v3(d_12, b, a);
+ sub_v3_v3v3(d_23, c, b);
normalize_v3(d_12);
normalize_v3(d_23);
- add_v3_v3v3(out, d_12, d_23);
- normalize_v3(out);
+ add_v3_v3v3(r, d_12, d_23);
+ normalize_v3(r);
}
/**
diff --git a/source/blender/blenlib/intern/memory_utils.c b/source/blender/blenlib/intern/memory_utils.c
index 91e75861dde..d477c20a242 100644
--- a/source/blender/blenlib/intern/memory_utils.c
+++ b/source/blender/blenlib/intern/memory_utils.c
@@ -31,16 +31,16 @@
#include "BLI_strict_flags.h"
/**
- * Check if memory is zero'd, as with memset(s, 0, nbytes)
+ * Check if memory is zero'd, as with memset(arr, 0, arr_size)
*/
-bool BLI_memory_is_zero(const void *s, const size_t nbytes)
+bool BLI_memory_is_zero(const void *arr, const size_t arr_size)
{
- const char *s_byte = s;
- const char *s_end = (const char *)s + nbytes;
+ const char *arr_byte = arr;
+ const char *arr_end = (const char *)arr + arr_size;
- while ((s_byte != s_end) && (*s_byte == 0)) {
- s_byte++;
+ while ((arr_byte != arr_end) && (*arr_byte == 0)) {
+ arr_byte++;
}
- return (s_byte == s_end);
+ return (arr_byte == arr_end);
}
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index ab2b0fd2928..4a2915ef24e 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -222,12 +222,12 @@ void BLI_smallhash_release(SmallHash *sh)
}
}
-void BLI_smallhash_insert(SmallHash *sh, uintptr_t key, void *val)
+void BLI_smallhash_insert(SmallHash *sh, uintptr_t key, void *item)
{
SmallHashEntry *e;
BLI_assert(key != SMHASH_KEY_UNUSED);
- BLI_assert(smallhash_val_is_used(val));
+ BLI_assert(smallhash_val_is_used(item));
BLI_assert(BLI_smallhash_haskey(sh, key) == false);
if (UNLIKELY(smallhash_test_expand_buckets(++sh->nentries, sh->nbuckets))) {
@@ -236,7 +236,7 @@ void BLI_smallhash_insert(SmallHash *sh, uintptr_t key, void *val)
e = smallhash_lookup_first_free(sh, key);
e->key = key;
- e->val = val;
+ e->val = item;
}
/**
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index db062ff50fd..a841068bfdb 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -341,11 +341,11 @@ bool BLI_file_alias_target(
* Returns the st_mode from stat-ing the specified path name, or 0 if stat fails
* (most likely doesn't exist or no access).
*/
-int BLI_exists(const char *name)
+int BLI_exists(const char *path)
{
#if defined(WIN32)
BLI_stat_t st;
- wchar_t *tmp_16 = alloc_utf16_from_8(name, 1);
+ wchar_t *tmp_16 = alloc_utf16_from_8(path, 1);
int len, res;
len = wcslen(tmp_16);
@@ -375,9 +375,9 @@ int BLI_exists(const char *name)
}
#else
struct stat st;
- BLI_assert(!BLI_path_is_rel(name));
- if (stat(name, &st)) {
- return 0;
+ BLI_assert(!BLI_path_is_rel(path));
+ if (stat(path, &st)) {
+ return (0);
}
#endif
return (st.st_mode);
@@ -582,9 +582,9 @@ void *BLI_file_read_text_as_mem_with_newline_as_nil(const char *filepath,
/**
* Reads the contents of a text file and returns the lines in a linked list.
*/
-LinkNode *BLI_file_read_as_lines(const char *name)
+LinkNode *BLI_file_read_as_lines(const char *filepath)
{
- FILE *fp = BLI_fopen(name, "r");
+ FILE *fp = BLI_fopen(filepath, "r");
LinkNodePair lines = {NULL, NULL};
char *buf;
size_t size;