Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
graphene-simd4x4f.h File Reference
#include "graphene-simd4f.h"
#include <math.h>
#include <float.h>

Go to the source code of this file.

Macros

#define graphene_simd4x4f_transpose_in_place(s)    (graphene_simd4x4f_transpose_in_place ((graphene_simd4x4f_t *) (s)))
 

Functions

static GRAPHENE_BEGIN_DECLS graphene_simd4x4f_t GRAPHENE_VECTORCALL graphene_simd4x4f_init (graphene_simd4f_t x, graphene_simd4f_t y, graphene_simd4f_t z, graphene_simd4f_t w)
 
static void graphene_simd4x4f_init_identity (graphene_simd4x4f_t *m)
 
static void graphene_simd4x4f_init_from_float (graphene_simd4x4f_t *m, const float *f)
 
static void graphene_simd4x4f_to_float (const graphene_simd4x4f_t *m, float *v)
 
GRAPHENE_AVAILABLE_IN_1_0 void graphene_simd4x4f_transpose_in_place (graphene_simd4x4f_t *s)
 
static void graphene_simd4x4f_sum (const graphene_simd4x4f_t *a, graphene_simd4f_t *res)
 
static void graphene_simd4x4f_vec4_mul (const graphene_simd4x4f_t *a, const graphene_simd4f_t *b, graphene_simd4f_t *res)
 
static void graphene_simd4x4f_vec3_mul (const graphene_simd4x4f_t *m, const graphene_simd4f_t *v, graphene_simd4f_t *res)
 
static void graphene_simd4x4f_point3_mul (const graphene_simd4x4f_t *m, const graphene_simd4f_t *p, graphene_simd4f_t *res)
 
static void graphene_simd4x4f_transpose (const graphene_simd4x4f_t *s, graphene_simd4x4f_t *res)
 
static void graphene_simd4x4f_inv_ortho_vec3_mul (const graphene_simd4x4f_t *a, const graphene_simd4f_t *b, graphene_simd4f_t *res)
 
static void graphene_simd4x4f_inv_ortho_point3_mul (const graphene_simd4x4f_t *a, const graphene_simd4f_t *b, graphene_simd4f_t *res)
 
static void graphene_simd4x4f_matrix_mul (const graphene_simd4x4f_t *a, const graphene_simd4x4f_t *b, graphene_simd4x4f_t *res)
 
static void graphene_simd4x4f_init_perspective (graphene_simd4x4f_t *m, float fovy_rad, float aspect, float z_near, float z_far)
 
static void graphene_simd4x4f_init_ortho (graphene_simd4x4f_t *m, float left, float right, float bottom, float top, float z_near, float z_far)
 
static void graphene_simd4x4f_init_look_at (graphene_simd4x4f_t *m, graphene_simd4f_t eye, graphene_simd4f_t center, graphene_simd4f_t up)
 
static void graphene_simd4x4f_init_frustum (graphene_simd4x4f_t *m, float left, float right, float bottom, float top, float z_near, float z_far)
 
static void graphene_simd4x4f_perspective (graphene_simd4x4f_t *m, float depth)
 
static void graphene_simd4x4f_translation (graphene_simd4x4f_t *m, float x, float y, float z)
 
static void graphene_simd4x4f_scale (graphene_simd4x4f_t *m, float x, float y, float z)
 
static void graphene_simd4x4f_rotation (graphene_simd4x4f_t *m, float rad, graphene_simd4f_t axis)
 
static void graphene_simd4x4f_add (const graphene_simd4x4f_t *a, const graphene_simd4x4f_t *b, graphene_simd4x4f_t *res)
 
static void graphene_simd4x4f_sub (const graphene_simd4x4f_t *a, const graphene_simd4x4f_t *b, graphene_simd4x4f_t *res)
 
static void graphene_simd4x4f_mul (const graphene_simd4x4f_t *a, const graphene_simd4x4f_t *b, graphene_simd4x4f_t *res)
 
static void graphene_simd4x4f_div (const graphene_simd4x4f_t *a, const graphene_simd4x4f_t *b, graphene_simd4x4f_t *res)
 
static bool graphene_simd4x4f_inverse (const graphene_simd4x4f_t *m, graphene_simd4x4f_t *res)
 
static void graphene_simd4x4f_determinant (const graphene_simd4x4f_t *m, graphene_simd4f_t *det_r, graphene_simd4f_t *invdet_r)
 
static bool graphene_simd4x4f_is_identity (const graphene_simd4x4f_t *m)
 
static bool graphene_simd4x4f_is_2d (const graphene_simd4x4f_t *m)
 

Macro Definition Documentation

◆ graphene_simd4x4f_transpose_in_place

#define graphene_simd4x4f_transpose_in_place ( s)     (graphene_simd4x4f_transpose_in_place ((graphene_simd4x4f_t *) (s)))

Definition at line 210 of file graphene-simd4x4f.h.

210#define graphene_simd4x4f_transpose_in_place(s) \
211 (graphene_simd4x4f_transpose_in_place ((graphene_simd4x4f_t *) (s)))

Referenced by graphene_simd4x4f_inv_ortho_point3_mul(), graphene_simd4x4f_inv_ortho_vec3_mul(), and graphene_simd4x4f_transpose().

Function Documentation

◆ graphene_simd4x4f_add()

static void graphene_simd4x4f_add ( const graphene_simd4x4f_t * a,
const graphene_simd4x4f_t * b,
graphene_simd4x4f_t * res )
inlinestatic

graphene_simd4x4f_add: : a graphene_simd4x4f_t : a graphene_simd4x4f_t @res: (out caller-allocates): return location for a graphene_simd4x4f_t

Adds each row vector of and and places the results in @res.

Since: 1.0

Definition at line 880 of file graphene-simd4x4f.h.

883{
884 res->x = graphene_simd4f_add (a->x, b->x);
885 res->y = graphene_simd4f_add (a->y, b->y);
886 res->z = graphene_simd4f_add (a->z, b->z);
887 res->w = graphene_simd4f_add (a->w, b->w);
888}
#define graphene_simd4f_add(a, b)
graphene_simd4f_t w
graphene_simd4f_t z
graphene_simd4f_t y
graphene_simd4f_t x

References graphene_simd4f_add, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_determinant()

static void graphene_simd4x4f_determinant ( const graphene_simd4x4f_t * m,
graphene_simd4f_t * det_r,
graphene_simd4f_t * invdet_r )
inlinestatic

graphene_simd4x4f_determinant: @m: a graphene_simd4x4f_t @det_r: (out): return location for the matrix determinant @invdet_r: (out): return location for the inverse of the matrix determinant

Computes the determinant (and its inverse) of the given matrix

Since: 1.0

Definition at line 1068 of file graphene-simd4x4f.h.

1071{
1072 /* split rows */
1073 const graphene_simd4f_t r0 = m->x;
1074 const graphene_simd4f_t r1 = m->y;
1075 const graphene_simd4f_t r2 = m->z;
1076 const graphene_simd4f_t r3 = m->w;
1077
1078 /* cofactors */
1082
1084
1087
1088 const graphene_simd4f_t r2_wxyz_x_r3 = graphene_simd4f_mul (r2_wxyz, r3);
1089 const graphene_simd4f_t r2_wxyz_x_r3_yzwx = graphene_simd4f_mul (r2_wxyz, r3_yzwx);
1090 const graphene_simd4f_t r2_wxyz_x_r3_zwxy = graphene_simd4f_mul (r2_wxyz, r3_zwxy);
1091
1093 graphene_simd4f_shuffle_zwxy (r2_wxyz_x_r3));
1095 r2_wxyz_x_r3_yzwx);
1096 const graphene_simd4f_t ar3 = graphene_simd4f_sub (r2_wxyz_x_r3_zwxy,
1097 graphene_simd4f_shuffle_wxyz (r2_wxyz_x_r3));
1098
1099 const graphene_simd4f_t r1_sum =
1100 graphene_simd4f_madd (r1_wxyz, ar1,
1101 graphene_simd4f_madd (r1_zwxy, ar2,
1102 graphene_simd4f_mul (r1_yzwx, ar3)));
1103
1104 /* determinant and its inverse */
1105 const graphene_simd4f_t d0 = graphene_simd4f_mul (r1_sum, r0);
1107
1109
1111
1112 if (det_r != NULL)
1113 *det_r = det;
1114
1115 if (invdet_r != NULL)
1116 *invdet_r = invdet;
1117}
#define NULL
Definition gmacros.h:924
#define graphene_simd4f_shuffle_wxyz(s)
#define graphene_simd4f_mul(a, b)
#define graphene_simd4f_shuffle_zwxy(s)
#define graphene_simd4f_splat_y(s)
#define graphene_simd4f_merge_high(a, b)
#define graphene_simd4f_splat_x(s)
#define graphene_simd4f_splat(v)
static graphene_simd4f_t graphene_simd4f_madd(const graphene_simd4f_t m1, const graphene_simd4f_t m2, const graphene_simd4f_t a)
#define graphene_simd4f_div(a, b)
#define graphene_simd4f_shuffle_yzwx(s)
#define graphene_simd4f_sub(a, b)

References graphene_simd4f_add, graphene_simd4f_div, graphene_simd4f_madd(), graphene_simd4f_merge_high, graphene_simd4f_mul, graphene_simd4f_shuffle_wxyz, graphene_simd4f_shuffle_yzwx, graphene_simd4f_shuffle_zwxy, graphene_simd4f_splat, graphene_simd4f_splat_x, graphene_simd4f_splat_y, graphene_simd4f_sub, NULL, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_div()

static void graphene_simd4x4f_div ( const graphene_simd4x4f_t * a,
const graphene_simd4x4f_t * b,
graphene_simd4x4f_t * res )
inlinestatic

graphene_simd4x4f_div: : a graphene_simd4x4f_t : a graphene_simd4x4f_t @res: (out caller-allocates): return location for a graphene_simd4x4f_t

Divides each row vector of and and places the results in @res.

Since: 1.0

Definition at line 945 of file graphene-simd4x4f.h.

948{
949 res->x = graphene_simd4f_div (a->x, b->x);
950 res->y = graphene_simd4f_div (a->y, b->y);
951 res->z = graphene_simd4f_div (a->z, b->z);
952 res->w = graphene_simd4f_div (a->w, b->w);
953}

References graphene_simd4f_div, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_init()

graphene_simd4x4f_t:

A SIMD-based matrix type that uses four graphene_simd4f_t vectors.

The matrix is treated as row-major, i.e. the x, y, z, and w vectors are rows, and elements of each vector are a column:

|[ graphene_simd4x4f_t = { x.x, x.y, x.z, x.w, y.x, y.y, y.z, y.w, z.x, z.y, z.z, z.w, w.x, w.y, w.z, w.w } ]|

The contents of the graphene_simd4x4f_t type are private and cannot be accessed directly; use the provided API instead.

Since: 1.0 graphene_simd4x4f_init: @x: a graphene_simd4f_t for the first row @y: a graphene_simd4f_t for the second row @z: a graphene_simd4f_t for the third row @w: a graphene_simd4f_t for the fourth row

Creates a new graphene_simd4x4f_t using the given row vectors to initialize it.

Returns: the newly created graphene_simd4x4f_t

Since: 1.0

Definition at line 73 of file graphene-simd4x4f.h.

77{
79
80 s.x = x;
81 s.y = y;
82 s.z = z;
83 s.w = w;
84
85 return s;
86}
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318

References s, graphene_simd4f_t::w, graphene_simd4x4f_t::x, graphene_simd4f_t::y, and graphene_simd4f_t::z.

Referenced by graphene_simd4x4f_init_identity(), graphene_simd4x4f_inverse(), graphene_simd4x4f_matrix_mul(), graphene_simd4x4f_perspective(), graphene_simd4x4f_rotation(), graphene_simd4x4f_scale(), and graphene_simd4x4f_translation().

◆ graphene_simd4x4f_init_from_float()

static void graphene_simd4x4f_init_from_float ( graphene_simd4x4f_t * m,
const float * f )
inlinestatic

graphene_simd4x4f_init_from_float: @m: a graphene_simd4x4f_t @f: (array fixed-size=16): an array of 16 floating point values

Initializes a graphene_simd4x4f_t with the given array of floating point values.

Since: 1.0

Definition at line 116 of file graphene-simd4x4f.h.

118{
119 m->x = graphene_simd4f_init_4f (f + 0);
120 m->y = graphene_simd4f_init_4f (f + 4);
121 m->z = graphene_simd4f_init_4f (f + 8);
122 m->w = graphene_simd4f_init_4f (f + 12);
123}
#define graphene_simd4f_init_4f(v)

References graphene_simd4f_init_4f, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_init_frustum()

static void graphene_simd4x4f_init_frustum ( graphene_simd4x4f_t * m,
float left,
float right,
float bottom,
float top,
float z_near,
float z_far )
inlinestatic

graphene_simd4x4f_init_frustum: @m: a graphene_simd4x4f_t @left: distance of the left clipping plane @right: distance of the right clipping plane @bottom: distance of the bottom clipping plane @top: distance of the top clipping plane @z_near: distance of the near clipping plane @z_far: distance of the far clipping plane

Initializes a SIMD matrix with a frustum described by the distances of six clipping planes.

Since: 1.2

Definition at line 696 of file graphene-simd4x4f.h.

703{
704 float x = 2.f * z_near / (right - left);
705 float y = 2.f * z_near / (top - bottom);
706
707 float a = (right + left) / (right - left);
708 float b = (top + bottom) / (top - bottom);
709 float c = -1.f * (z_far + z_near) / (z_far - z_near);
710 float d = -2.f * z_far * z_near / (z_far - z_near);
711
712 m->x = graphene_simd4f_init ( x, 0.f, 0.f, 0.f);
713 m->y = graphene_simd4f_init (0.f, y, 0.f, 0.f);
714 m->z = graphene_simd4f_init ( a, b, c, -1.f);
715 m->w = graphene_simd4f_init (0.f, 0.f, d, 0.f);
716}
#define graphene_simd4f_init(x, y, z, w)
lu_byte right
lu_byte left

References graphene_simd4f_init, left, right, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_init_identity()

static void graphene_simd4x4f_init_identity ( graphene_simd4x4f_t * m)
inlinestatic

graphene_simd4x4f_init_identity: @m: a graphene_simd4x4f_t

Initializes @m to be the identity matrix.

Since: 1.0

Definition at line 97 of file graphene-simd4x4f.h.

98{
99 *m = graphene_simd4x4f_init (graphene_simd4f_init (1.0f, 0.0f, 0.0f, 0.0f),
100 graphene_simd4f_init (0.0f, 1.0f, 0.0f, 0.0f),
101 graphene_simd4f_init (0.0f, 0.0f, 1.0f, 0.0f),
102 graphene_simd4f_init (0.0f, 0.0f, 0.0f, 1.0f));
103}
static GRAPHENE_BEGIN_DECLS graphene_simd4x4f_t GRAPHENE_VECTORCALL graphene_simd4x4f_init(graphene_simd4f_t x, graphene_simd4f_t y, graphene_simd4f_t z, graphene_simd4f_t w)

References graphene_simd4f_init, and graphene_simd4x4f_init().

◆ graphene_simd4x4f_init_look_at()

static void graphene_simd4x4f_init_look_at ( graphene_simd4x4f_t * m,
graphene_simd4f_t eye,
graphene_simd4f_t center,
graphene_simd4f_t up )
inlinestatic

graphene_simd4x4f_init_look_at: @m: a graphene_simd4x4f_t @eye: vector for the camera coordinates @center: vector for the object coordinates @up: vector for the upwards direction

Initializes a SIMD matrix with the projection necessary for the camera at the @eye coordinates to look at the object at the @center coordinates. The top of the camera is aligned to the @up vector.

Since: 1.0

Definition at line 635 of file graphene-simd4x4f.h.

639{
640 const graphene_simd4f_t direction = graphene_simd4f_sub (center, eye);
641 graphene_simd4f_t cross;
642 graphene_simd4f_t z_axis;
643 graphene_simd4f_t x_axis;
644 graphene_simd4f_t y_axis;
645 float eye_v[4];
646
647 if (graphene_simd4f_get_x (graphene_simd4f_dot3 (direction, direction)) < FLT_EPSILON)
648 /* eye and center are in the same position */
649 z_axis = graphene_simd4f_init (0, 0, 1, 0);
650 else
651 z_axis = graphene_simd4f_normalize3 (direction);
652
653 cross = graphene_simd4f_cross3 (z_axis, up);
654 if (graphene_simd4f_get_x (graphene_simd4f_dot3 (cross, cross)) < FLT_EPSILON)
655 {
656 graphene_simd4f_t tweak_z;
657
658 /* up and z_axis are parallel */
659 if (fabs (graphene_simd4f_get_z (up) - 1.0) < FLT_EPSILON)
660 tweak_z = graphene_simd4f_init (0.0001f, 0, 0, 0);
661 else
662 tweak_z = graphene_simd4f_init (0, 0, 0.0001f, 0);
663
664 z_axis = graphene_simd4f_add (z_axis, tweak_z);
665 z_axis = graphene_simd4f_normalize3 (z_axis);
666 cross = graphene_simd4f_cross3 (z_axis, up);
667 }
668
669 x_axis = graphene_simd4f_normalize3 (cross);
670 y_axis = graphene_simd4f_cross3 (x_axis, z_axis);
671
672 graphene_simd4f_dup_4f (eye, eye_v);
673
674 m->x = x_axis;
675 m->y = y_axis;
676 m->z = graphene_simd4f_neg (z_axis);
677 m->w = graphene_simd4f_init (-eye_v[0], -eye_v[1], -eye_v[2], 1.f);
678}
static graphene_simd4f_t graphene_simd4f_normalize3(const graphene_simd4f_t v)
#define graphene_simd4f_neg(s)
#define graphene_simd4f_dup_4f(s, v)
#define graphene_simd4f_get_x(s)
#define graphene_simd4f_get_z(s)
#define graphene_simd4f_dot3(a, b)
#define graphene_simd4f_cross3(a, b)

References graphene_simd4f_add, graphene_simd4f_cross3, graphene_simd4f_dot3, graphene_simd4f_dup_4f, graphene_simd4f_get_x, graphene_simd4f_get_z, graphene_simd4f_init, graphene_simd4f_neg, graphene_simd4f_normalize3(), graphene_simd4f_sub, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_init_ortho()

static void graphene_simd4x4f_init_ortho ( graphene_simd4x4f_t * m,
float left,
float right,
float bottom,
float top,
float z_near,
float z_far )
inlinestatic

graphene_simd4x4f_init_ortho: @m: a graphene_simd4x4f_t @left: edge of the left clipping plane @right: edge of the right clipping plane @bottom: edge of the bottom clipping plane @top: edge of the top clipping plane @z_near: depth of the near clipping plane @z_far: depth of the far clipping plane

Initializes the given SIMD matrix with an orthographic projection.

Since: 1.0

Definition at line 595 of file graphene-simd4x4f.h.

602{
603 float delta_x = right - left;
604 float delta_y = top - bottom;
605 float delta_z = z_far - z_near;
606
607 float a = 2.0f / delta_x;
608 float b = -(right + left) / delta_x;
609 float c = 2.0f / delta_y;
610 float d = -(top + bottom) / delta_y;
611 float e = -2.0f / delta_z;
612 float f = -(z_far + z_near) / delta_z;
613
614 m->x = graphene_simd4f_init ( a, 0.0f, 0.0f, 0.0f);
615 m->y = graphene_simd4f_init (0.0f, c, 0.0f, 0.0f);
616 m->z = graphene_simd4f_init (0.0f, 0.0f, e, 0.0f);
617 m->w = graphene_simd4f_init ( b, d, f, 1.0f);
618}

References graphene_simd4f_init, left, right, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_init_perspective()

static void graphene_simd4x4f_init_perspective ( graphene_simd4x4f_t * m,
float fovy_rad,
float aspect,
float z_near,
float z_far )
inlinestatic

graphene_simd4x4f_init_perspective: @m: a graphene_simd4x4f_t @fovy_rad: the angle of the field of vision, in radians @aspect: the aspect value @z_near: the depth of the near clipping plane @z_far: the depth of the far clipping plane

Initializes a graphene_simd4x4f_t with a perspective projection.

Since: 1.0

Definition at line 560 of file graphene-simd4x4f.h.

565{
566 float delta_z = z_far - z_near;
567 float cotangent = tanf (GRAPHENE_PI_2 - fovy_rad * 0.5f);
568
569 float a = cotangent / aspect;
570 float b = cotangent;
571 float c = -(z_far + z_near) / delta_z;
572 float d = -2 * z_near * z_far / delta_z;
573
574 m->x = graphene_simd4f_init ( a, 0.0f, 0.0f, 0.0f);
575 m->y = graphene_simd4f_init (0.0f, b, 0.0f, 0.0f);
576 m->z = graphene_simd4f_init (0.0f, 0.0f, c, -1.0f);
577 m->w = graphene_simd4f_init (0.0f, 0.0f, d, 0.0f);
578}
#define GRAPHENE_PI_2

References GRAPHENE_PI_2, graphene_simd4f_init, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_inv_ortho_point3_mul()

static void graphene_simd4x4f_inv_ortho_point3_mul ( const graphene_simd4x4f_t * a,
const graphene_simd4f_t * b,
graphene_simd4f_t * res )
inlinestatic

graphene_simd4x4f_inv_ortho_point3_mul: : a graphene_simd4x4f_t : a graphene_simd4x4f_t @res: (out): return location for the result vector

Performs the inverse orthographic transformation of the first three components in the given vector, using the given SIMD matrix.

Unlike graphene_simd4x4f_inv_ortho_vec3_mul(), this function will also use the fourth row vector of the SIMD matrix.

Since: 1.0

Definition at line 447 of file graphene-simd4x4f.h.

450{
451 graphene_simd4f_t translation = graphene_simd4f_sub (*b, a->w);
452 graphene_simd4x4f_t transpose = *a;
453
454 transpose.w = graphene_simd4f_init (0.f, 0.f, 0.f, 0.f);
456
457 graphene_simd4x4f_point3_mul (&transpose, &translation, res);
458}
#define graphene_simd4x4f_transpose_in_place(s)
static void graphene_simd4x4f_point3_mul(const graphene_simd4x4f_t *m, const graphene_simd4f_t *p, graphene_simd4f_t *res)

References graphene_simd4f_init, graphene_simd4f_sub, graphene_simd4x4f_point3_mul(), graphene_simd4x4f_transpose_in_place, and graphene_simd4x4f_t::w.

◆ graphene_simd4x4f_inv_ortho_vec3_mul()

static void graphene_simd4x4f_inv_ortho_vec3_mul ( const graphene_simd4x4f_t * a,
const graphene_simd4f_t * b,
graphene_simd4f_t * res )
inlinestatic

graphene_simd4x4f_inv_ortho_vec3_mul: : a graphene_simd4x4f_t : a graphene_simd4f_t @res: (out): return location for the transformed vector

Performs the inverse orthographic transformation of the first three components in the given vector, using the first three row vectors of the given SIMD matrix.

Since: 1.0

Definition at line 418 of file graphene-simd4x4f.h.

421{
422 graphene_simd4x4f_t transpose = *a;
423 graphene_simd4f_t translation = *b;
424
425 transpose.w = graphene_simd4f_init (0.f, 0.f, 0.f, 0.f);
427
428 graphene_simd4x4f_vec3_mul (&transpose, &translation, res);
429}
static void graphene_simd4x4f_vec3_mul(const graphene_simd4x4f_t *m, const graphene_simd4f_t *v, graphene_simd4f_t *res)

References graphene_simd4f_init, graphene_simd4x4f_transpose_in_place, graphene_simd4x4f_vec3_mul(), and graphene_simd4x4f_t::w.

◆ graphene_simd4x4f_inverse()

static bool graphene_simd4x4f_inverse ( const graphene_simd4x4f_t * m,
graphene_simd4x4f_t * res )
inlinestatic

graphene_simd4x4f_inverse: @m: a graphene_simd4x4f_t @res: (out): return location for the inverse matrix

Inverts the given graphene_simd4x4f_t.

Returns: true if the matrix was invertible

Since: 1.0

Definition at line 967 of file graphene-simd4x4f.h.

969{
970 /* split rows */
971 const graphene_simd4f_t r0 = m->x;
972 const graphene_simd4f_t r1 = m->y;
973 const graphene_simd4f_t r2 = m->z;
974 const graphene_simd4f_t r3 = m->w;
975
976 /* cofactors */
980
984
988
992
993 const graphene_simd4f_t r0_wxyz_x_r1 = graphene_simd4f_mul (r0_wxyz, r1);
994 const graphene_simd4f_t r0_wxyz_x_r1_yzwx = graphene_simd4f_mul (r0_wxyz, r1_yzwx);
995 const graphene_simd4f_t r0_wxyz_x_r1_zwxy = graphene_simd4f_mul (r0_wxyz, r1_zwxy);
996
997 const graphene_simd4f_t r2_wxyz_x_r3 = graphene_simd4f_mul (r2_wxyz, r3);
998 const graphene_simd4f_t r2_wxyz_x_r3_yzwx = graphene_simd4f_mul (r2_wxyz, r3_yzwx);
999 const graphene_simd4f_t r2_wxyz_x_r3_zwxy = graphene_simd4f_mul (r2_wxyz, r3_zwxy);
1000
1002 graphene_simd4f_shuffle_zwxy (r2_wxyz_x_r3));
1004 r2_wxyz_x_r3_yzwx);
1005 const graphene_simd4f_t ar3 = graphene_simd4f_sub (r2_wxyz_x_r3_zwxy,
1006 graphene_simd4f_shuffle_wxyz (r2_wxyz_x_r3));
1007
1009 graphene_simd4f_shuffle_zwxy (r0_wxyz_x_r1));
1011 r0_wxyz_x_r1_yzwx);
1012 const graphene_simd4f_t br3 = graphene_simd4f_sub (r0_wxyz_x_r1_zwxy,
1013 graphene_simd4f_shuffle_wxyz (r0_wxyz_x_r1));
1014
1015 const graphene_simd4f_t r0_sum =
1016 graphene_simd4f_madd (r0_yzwx, ar3,
1017 graphene_simd4f_madd (r0_zwxy, ar2,
1018 graphene_simd4f_mul (r0_wxyz, ar1)));
1019 const graphene_simd4f_t r1_sum =
1020 graphene_simd4f_madd (r1_wxyz, ar1,
1021 graphene_simd4f_madd (r1_zwxy, ar2,
1022 graphene_simd4f_mul (r1_yzwx, ar3)));
1023 const graphene_simd4f_t r2_sum =
1024 graphene_simd4f_madd (r2_yzwx, br3,
1025 graphene_simd4f_madd (r2_zwxy, br2,
1026 graphene_simd4f_mul (r2_wxyz, br1)));
1027 const graphene_simd4f_t r3_sum =
1028 graphene_simd4f_madd (r3_yzwx, br3,
1029 graphene_simd4f_madd (r3_zwxy, br2,
1030 graphene_simd4f_mul (r3_wxyz, br1)));
1031
1032 /* determinant and its inverse */
1033 const graphene_simd4f_t d0 = graphene_simd4f_mul (r1_sum, r0);
1036 if (fabsf (graphene_simd4f_get_x (det)) >= FLT_EPSILON)
1037 {
1039
1044
1045 graphene_simd4x4f_t mt = graphene_simd4x4f_init (o0, o1, o2, o3);
1046
1047 /* transpose the resulting matrix */
1048 graphene_simd4x4f_transpose (&mt, res);
1049
1050 return true;
1051 }
1052
1053 return false;
1054}
#define graphene_simd4f_flip_sign_1010(s)
#define graphene_simd4f_flip_sign_0101(s)
static void graphene_simd4x4f_transpose(const graphene_simd4x4f_t *s, graphene_simd4x4f_t *res)

References graphene_simd4f_add, graphene_simd4f_div, graphene_simd4f_flip_sign_0101, graphene_simd4f_flip_sign_1010, graphene_simd4f_get_x, graphene_simd4f_madd(), graphene_simd4f_merge_high, graphene_simd4f_mul, graphene_simd4f_shuffle_wxyz, graphene_simd4f_shuffle_yzwx, graphene_simd4f_shuffle_zwxy, graphene_simd4f_splat, graphene_simd4f_splat_x, graphene_simd4f_splat_y, graphene_simd4f_sub, graphene_simd4x4f_init(), graphene_simd4x4f_transpose(), graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_is_2d()

static bool graphene_simd4x4f_is_2d ( const graphene_simd4x4f_t * m)
inlinestatic

graphene_simd4x4f_is_2d: @m: a graphene_simd4x4f_t

Checks whether the given matrix is compatible with an affine transformation matrix.

Returns: true if the matrix is compatible with an affine transformation matrix

Since: 1.0

Definition at line 1156 of file graphene-simd4x4f.h.

1157{
1158 float f[4];
1159
1160 if (!(fabsf (graphene_simd4f_get_z (m->x)) < FLT_EPSILON && fabsf (graphene_simd4f_get_w (m->x)) < FLT_EPSILON))
1161 return false;
1162
1163 if (!(fabsf (graphene_simd4f_get_z (m->y)) < FLT_EPSILON && fabsf (graphene_simd4f_get_w (m->y)) < FLT_EPSILON))
1164 return false;
1165
1166 graphene_simd4f_dup_4f (m->z, f);
1167 if (!(fabsf (f[0]) < FLT_EPSILON &&
1168 fabsf (f[1]) < FLT_EPSILON &&
1169 1.f - fabsf (f[2]) < FLT_EPSILON &&
1170 fabsf (f[3]) < FLT_EPSILON))
1171 return false;
1172
1173 if (!(fabsf (graphene_simd4f_get_z (m->w)) < FLT_EPSILON && 1.f - fabsf (graphene_simd4f_get_w (m->w)) < FLT_EPSILON))
1174 return false;
1175
1176 return true;
1177}
#define graphene_simd4f_get_w(s)

References graphene_simd4f_dup_4f, graphene_simd4f_get_w, graphene_simd4f_get_z, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_is_identity()

static bool graphene_simd4x4f_is_identity ( const graphene_simd4x4f_t * m)
inlinestatic

graphene_simd4x4f_is_identity: @m: a graphene_simd4x4f_t

Checks whether the given matrix is the identity matrix.

Returns: true if the matrix is the identity matrix

Since: 1.0

Definition at line 1130 of file graphene-simd4x4f.h.

1131{
1132 const graphene_simd4f_t r0 = graphene_simd4f_init (1.0f, 0.0f, 0.0f, 0.0f);
1133 const graphene_simd4f_t r1 = graphene_simd4f_init (0.0f, 1.0f, 0.0f, 0.0f);
1134 const graphene_simd4f_t r2 = graphene_simd4f_init (0.0f, 0.0f, 1.0f, 0.0f);
1135 const graphene_simd4f_t r3 = graphene_simd4f_init (0.0f, 0.0f, 0.0f, 1.0f);
1136
1137 return graphene_simd4f_cmp_eq (m->x, r0) &&
1138 graphene_simd4f_cmp_eq (m->y, r1) &&
1139 graphene_simd4f_cmp_eq (m->z, r2) &&
1140 graphene_simd4f_cmp_eq (m->w, r3);
1141}
#define graphene_simd4f_cmp_eq(a, b)

References graphene_simd4f_cmp_eq, graphene_simd4f_init, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_matrix_mul()

static void graphene_simd4x4f_matrix_mul ( const graphene_simd4x4f_t * a,
const graphene_simd4x4f_t * b,
graphene_simd4x4f_t * res )
inlinestatic

graphene_simd4x4f_matrix_mul: : a graphene_simd4x4f_t : a graphene_simd4x4f_t @res: (out): return location for the result

Multiplies the two matrices, following the convention:

|[ res = A × B

= ⎡ A.x × B ⎤
  ⎜ A.y × B ⎟
  ⎜ A.z × B ⎟
  ⎣ A.w × B ⎦

= ⎡ res.x ⎤
  ⎜ res.y ⎟
  ⎜ res.z ⎟
  ⎣ res.w ⎦

]|

See also: graphene_simd4x4f_vec4_mul()

Since: 1.0

Definition at line 487 of file graphene-simd4x4f.h.

490{
491#if 0
492 /* this is the classic naive A*B implementation of the row * column
493 * matrix product. using a SIMD scalar implementation, it's fairly
494 * slow at 329ns per multiplication; the SSE implementation makes it
495 * about 10x faster, at 32ns; the GCC vector implementation is only
496 * 5x faster, at 66ns. the biggest culprits are the transpose operation
497 * and the multiple, one lane reads to compute the scalar sum.
498 */
500
502
503 res->x =
508
509 res->y =
514
515 res->z =
520
521 res->w =
526#else
527 /* this is an optimized version of the matrix multiplication, using
528 * four dot products for each row vector. this yields drastically
529 * better numbers while retaining the same correct results as above:
530 * the scalar implementation now clocks at 91ns; the GCC vector
531 * implementation is 19ns; and the SSE implementation is 16ns.
532 *
533 * the order is correct if we want to multiply A with B; remember
534 * that matrix multiplication is non-commutative.
535 */
536 graphene_simd4f_t x, y, z, w;
537
538 graphene_simd4x4f_vec4_mul (b, &a->x, &x);
539 graphene_simd4x4f_vec4_mul (b, &a->y, &y);
540 graphene_simd4x4f_vec4_mul (b, &a->z, &z);
541 graphene_simd4x4f_vec4_mul (b, &a->w, &w);
542
543 *res = graphene_simd4x4f_init (x, y, z, w);
544#endif
545}
static float graphene_simd4f_sum_scalar(const graphene_simd4f_t v)
static void graphene_simd4x4f_vec4_mul(const graphene_simd4x4f_t *a, const graphene_simd4f_t *b, graphene_simd4f_t *res)

References graphene_simd4f_init, graphene_simd4f_mul, graphene_simd4f_sum_scalar(), graphene_simd4x4f_init(), graphene_simd4x4f_transpose(), graphene_simd4x4f_vec4_mul(), graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_mul()

static void graphene_simd4x4f_mul ( const graphene_simd4x4f_t * a,
const graphene_simd4x4f_t * b,
graphene_simd4x4f_t * res )
inlinestatic

graphene_simd4x4f_mul: : a graphene_simd4x4f_t : a graphene_simd4x4f_t @res: (out caller-allocates): return location for a graphene_simd4x4f_t

Multiplies each row vector of and and places the results in @res.

You most likely want graphene_simd4x4f_matrix_mul() instead.

Since: 1.0

Definition at line 924 of file graphene-simd4x4f.h.

927{
928 res->x = graphene_simd4f_mul (a->x, b->x);
929 res->y = graphene_simd4f_mul (a->y, b->y);
930 res->z = graphene_simd4f_mul (a->z, b->z);
931 res->w = graphene_simd4f_mul (a->w, b->w);
932}

References graphene_simd4f_mul, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_perspective()

static void graphene_simd4x4f_perspective ( graphene_simd4x4f_t * m,
float depth )
inlinestatic

graphene_simd4x4f_perspective: @m: a graphene_simd4x4f_t @depth: depth of the perspective

Adds a perspective transformation for the given @depth.

Since: 1.0

Definition at line 728 of file graphene-simd4x4f.h.

730{
731#if 1
732 const float m_xw = graphene_simd4f_get_w (m->x);
733 const float m_yw = graphene_simd4f_get_w (m->y);
734 const float m_zw = graphene_simd4f_get_w (m->z);
735 const float m_ww = graphene_simd4f_get_w (m->w);
736
737 const float p0 = graphene_simd4f_get_z (m->x) + -1.0f / depth * m_xw;
738 const float p1 = graphene_simd4f_get_z (m->y) + -1.0f / depth * m_yw;
739 const float p2 = graphene_simd4f_get_z (m->z) + -1.0f / depth * m_zw;
740 const float p3 = graphene_simd4f_get_z (m->w) + -1.0f / depth * m_ww;
741
742 const graphene_simd4f_t p_x = graphene_simd4f_merge_w (m->x, m_xw + p0);
743 const graphene_simd4f_t p_y = graphene_simd4f_merge_w (m->y, m_yw + p1);
744 const graphene_simd4f_t p_z = graphene_simd4f_merge_w (m->z, m_zw + p2);
745 const graphene_simd4f_t p_w = graphene_simd4f_merge_w (m->w, m_ww + p3);
746#else
747 /* this is equivalent to the operations above, but trying to inline
748 * them into SIMD registers as much as possible by transposing the
749 * original matrix and operating on the resulting column vectors. it
750 * should warrant a micro benchmark, because while the above code is
751 * dominated by single channel reads, the code below has a transpose
752 * operation.
753 */
755 const graphene_simd4f_t f, p;
756 const graphene_simd4f_t p_x, p_y, p_z, p_w;
757
759
766#endif
767
768 *m = graphene_simd4x4f_init (p_x, p_y, p_z, p_w);
769}
guint depth
#define graphene_simd4f_get_y(s)
#define graphene_simd4f_merge_w(s, v)
static graphene_simd4f_t graphene_simd4f_sum(const graphene_simd4f_t v)
#define graphene_simd4f_reciprocal(s)

References depth, graphene_simd4f_get_w, graphene_simd4f_get_x, graphene_simd4f_get_y, graphene_simd4f_get_z, graphene_simd4f_merge_w, graphene_simd4f_mul, graphene_simd4f_neg, graphene_simd4f_reciprocal, graphene_simd4f_splat, graphene_simd4f_sum(), graphene_simd4x4f_init(), graphene_simd4x4f_transpose(), graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_point3_mul()

static void graphene_simd4x4f_point3_mul ( const graphene_simd4x4f_t * m,
const graphene_simd4f_t * p,
graphene_simd4f_t * res )
inlinestatic

graphene_simd4x4f_point3_mul: @m: a graphene_simd4x4f_t : a graphene_simd4f_t @res: (out): return location for a graphene_simd4f_t

Multiplies the given graphene_simd4x4f_t with the given graphene_simd4f_t.

Unlike graphene_simd4x4f_vec3_mul(), this function will use the W components of the matrix:

|[ res = b × A

= ⎡x⎤ ⎛ x.x  x.y  x.z  x.w ⎞
  ⎜y⎟ ⎜ y.x  y.y  y.z  y.w ⎟
  ⎜z⎟ ⎜ z.x  z.y  z.z  z.w ⎟
  ⎣w⎦ ⎝ w.x  w.y  w.z  w.w ⎠

= [ x.x × x   x.y × x   x.z × x   x.w × x ]
       +         +         +         +
  [ y.x × y   y.y × y   y.z × y   y.w × y ]
       +         +         +         +
  [ z.x × z   z.y × z   z.z × z   z.w × z ]
       +         +         +         +
  [   w.x       w.y       w.z       w.w   ]

= ⎡ x.x × x + y.x × y + z.x × z + w.x ⎤
  ⎜ x.y × x + y.y × y + z.y × z + w.y ⎟
  ⎜ x.z × x + y.z × y + z.z × z + w.z ⎟
  ⎣ x.w × x + y.w × y + z.w × z + w.w ⎦

]|

Since: 1.0

Definition at line 373 of file graphene-simd4x4f.h.

376{
377 const graphene_simd4f_t v = *p;
381
383 graphene_simd4f_mul (m->y, v_y)),
385 m->w));
386}
#define graphene_simd4f_splat_z(s)

References graphene_simd4f_add, graphene_simd4f_mul, graphene_simd4f_splat_x, graphene_simd4f_splat_y, graphene_simd4f_splat_z, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

Referenced by graphene_simd4x4f_inv_ortho_point3_mul().

◆ graphene_simd4x4f_rotation()

static void graphene_simd4x4f_rotation ( graphene_simd4x4f_t * m,
float rad,
graphene_simd4f_t axis )
inlinestatic

graphene_simd4x4f_rotation: @m: a graphene_simd4x4f_t @rad: the rotation, in radians @axis: the vector of the axis of rotation

Initializes @m to contain a rotation of the given angle along the given axis.

Since: 1.0

Definition at line 831 of file graphene-simd4x4f.h.

834{
835 float sine, cosine;
836 float x, y, z;
837 float ab, bc, ca;
838 float tx, ty, tz;
839 graphene_simd4f_t i, j, k;
840
841 rad = -rad;
842 axis = graphene_simd4f_normalize3 (axis);
843
844 /* We cannot use graphene_sincos() because it's a private function, whereas
845 * graphene-simd4x4f.h is a public header
846 */
847 sine = sinf (rad);
848 cosine = cosf (rad);
849
850 x = graphene_simd4f_get_x (axis);
851 y = graphene_simd4f_get_y (axis);
852 z = graphene_simd4f_get_z (axis);
853
854 ab = x * y * (1.0f - cosine);
855 bc = y * z * (1.0f - cosine);
856 ca = z * x * (1.0f - cosine);
857
858 tx = x * x;
859 ty = y * y;
860 tz = z * z;
861
862 i = graphene_simd4f_init (tx + cosine * (1.0f - tx), ab - z * sine, ca + y * sine, 0.f);
863 j = graphene_simd4f_init (ab + z * sine, ty + cosine * (1.0f - ty), bc - x * sine, 0.f);
864 k = graphene_simd4f_init (ca - y * sine, bc + x * sine, tz + cosine * (1.0f - tz), 0.f);
865
866 *m = graphene_simd4x4f_init (i, j, k, graphene_simd4f_init (0.0f, 0.0f, 0.0f, 1.0f));
867}

References graphene_simd4f_get_x, graphene_simd4f_get_y, graphene_simd4f_get_z, graphene_simd4f_init, graphene_simd4f_normalize3(), and graphene_simd4x4f_init().

◆ graphene_simd4x4f_scale()

static void graphene_simd4x4f_scale ( graphene_simd4x4f_t * m,
float x,
float y,
float z )
inlinestatic

graphene_simd4x4f_scale: @m: a graphene_simd4x4f_t @x: scaling factor on the X axis @y: scaling factor on the Y axis @z: scaling factor on the Z axis

Initializes @m to contain a scaling transformation with the given factors.

Since: 1.0

Definition at line 807 of file graphene-simd4x4f.h.

811{
812 *m = graphene_simd4x4f_init (graphene_simd4f_init ( x, 0.0f, 0.0f, 0.0f),
813 graphene_simd4f_init (0.0f, y, 0.0f, 0.0f),
814 graphene_simd4f_init (0.0f, 0.0f, z, 0.0f),
815 graphene_simd4f_init (0.0f, 0.0f, 0.0f, 1.0f));
816
817}

References graphene_simd4f_init, and graphene_simd4x4f_init().

◆ graphene_simd4x4f_sub()

static void graphene_simd4x4f_sub ( const graphene_simd4x4f_t * a,
const graphene_simd4x4f_t * b,
graphene_simd4x4f_t * res )
inlinestatic

graphene_simd4x4f_sub: : a graphene_simd4x4f_t : a graphene_simd4x4f_t @res: (out caller-allocates): return location for a graphene_simd4x4f_t

Subtracts each row vector of and and places the results in @res.

Since: 1.0

Definition at line 901 of file graphene-simd4x4f.h.

904{
905 res->x = graphene_simd4f_sub (a->x, b->x);
906 res->y = graphene_simd4f_sub (a->y, b->y);
907 res->z = graphene_simd4f_sub (a->z, b->z);
908 res->w = graphene_simd4f_sub (a->w, b->w);
909}

References graphene_simd4f_sub, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_sum()

static void graphene_simd4x4f_sum ( const graphene_simd4x4f_t * a,
graphene_simd4f_t * res )
inlinestatic

graphene_simd4x4f_sum: : a graphene_simd4f_t @res: (out): return location for the sum vector

Adds all the row vectors of .

Since: 1.0

Definition at line 227 of file graphene-simd4x4f.h.

229{
231 s = graphene_simd4f_add (s, a->z);
232 s = graphene_simd4f_add (s, a->w);
233 *res = s;
234}

References graphene_simd4f_add, and s.

◆ graphene_simd4x4f_to_float()

static void graphene_simd4x4f_to_float ( const graphene_simd4x4f_t * m,
float * v )
inlinestatic

graphene_simd4x4f_to_float: @m: a #graphene_sidm4x4f_t @v: (out caller-allocates) (array fixed-size=16): a floating point values vector capable of holding at least 16 values

Copies the content of @m in a float array.

Since: 1.0

Definition at line 136 of file graphene-simd4x4f.h.

138{
139 graphene_simd4f_dup_4f (m->x, v + 0);
140 graphene_simd4f_dup_4f (m->y, v + 4);
141 graphene_simd4f_dup_4f (m->z, v + 8);
142 graphene_simd4f_dup_4f (m->w, v + 12);
143}

References graphene_simd4f_dup_4f, graphene_simd4x4f_t::w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

◆ graphene_simd4x4f_translation()

static void graphene_simd4x4f_translation ( graphene_simd4x4f_t * m,
float x,
float y,
float z )
inlinestatic

graphene_simd4x4f_translation: @m: a graphene_simd4x4f_t @x: coordinate of the X translation @y: coordinate of the Y translation @z: coordinate of the Z translation

Initializes @m to contain a translation to the given coordinates.

Since: 1.0

Definition at line 783 of file graphene-simd4x4f.h.

787{
788 *m = graphene_simd4x4f_init (graphene_simd4f_init (1.0f, 0.0f, 0.0f, 0.0f),
789 graphene_simd4f_init (0.0f, 1.0f, 0.0f, 0.0f),
790 graphene_simd4f_init (0.0f, 0.0f, 1.0f, 0.0f),
791 graphene_simd4f_init ( x, y, z, 1.0f));
792}

References graphene_simd4f_init, and graphene_simd4x4f_init().

◆ graphene_simd4x4f_transpose()

static void graphene_simd4x4f_transpose ( const graphene_simd4x4f_t * s,
graphene_simd4x4f_t * res )
inlinestatic

graphene_simd4x4f_transpose: @s: a graphene_simd4x4f_t @res: (out): return location for the transposed matrix

Transposes the given graphene_simd4x4f_t.

Since: 1.0

Definition at line 398 of file graphene-simd4x4f.h.

400{
401 *res = *s;
403}

References graphene_simd4x4f_transpose_in_place, and s.

Referenced by graphene_simd4x4f_inverse(), graphene_simd4x4f_matrix_mul(), and graphene_simd4x4f_perspective().

◆ graphene_simd4x4f_transpose_in_place()

GRAPHENE_AVAILABLE_IN_1_0 void graphene_simd4x4f_transpose_in_place ( graphene_simd4x4f_t * s)

◆ graphene_simd4x4f_vec3_mul()

static void graphene_simd4x4f_vec3_mul ( const graphene_simd4x4f_t * m,
const graphene_simd4f_t * v,
graphene_simd4f_t * res )
inlinestatic

graphene_simd4x4f_vec3_mul: @m: a graphene_simd4x4f_t @v: a graphene_simd4f_t @res: (out): return location for a graphene_simd4f_t

Left multiplies the given graphene_simd4x4f_t with the given graphene_simd4f_t, using only the first three row vectors of the matrix, and the first three components of the vector; the W components of the matrix and vector are ignored:

|[ res = b × A

= ⎡x⎤ ⎛ x.x  x.y  x.z ⎞
  ⎜y⎟ ⎜ y.x  y.y  y.z ⎟
  ⎣z⎦ ⎝ z.x  z.y  z.z ⎠

= [ x.x × x   x.y × x   x.z × x ]
       +         +         +
  [ y.x × y   y.y × y   y.z × y ]
       +         +         +
  [ z.x × z   z.y × z   z.z × z ]

= ⎡ x.x × x + y.x × y + z.x × z ⎤
  ⎜ x.y × x + y.y × y + z.y × z ⎟
  ⎜ x.z × x + y.z × y + z.z × z ⎟
  ⎣               0             ⎦

]|

See also: graphene_simd4x4f_vec4_mul(), graphene_simd4x4f_point3_mul()

Since: 1.0

Definition at line 321 of file graphene-simd4x4f.h.

324{
329
331 graphene_simd4f_mul (m->y, v_y)),
332 graphene_simd4f_mul (m->z, v_z));
333 *res = graphene_simd4f_zero_w (r);
334}
#define graphene_simd4f_zero_w(v)

References graphene_simd4f_add, graphene_simd4f_mul, graphene_simd4f_splat_x, graphene_simd4f_splat_y, graphene_simd4f_splat_z, graphene_simd4f_zero_w, graphene_simd4x4f_t::x, graphene_simd4x4f_t::y, and graphene_simd4x4f_t::z.

Referenced by graphene_simd4x4f_inv_ortho_vec3_mul().

◆ graphene_simd4x4f_vec4_mul()

static void graphene_simd4x4f_vec4_mul ( const graphene_simd4x4f_t * a,
const graphene_simd4f_t * b,
graphene_simd4f_t * res )
inlinestatic

graphene_simd4x4f_vec4_mul: : a graphene_simd4x4f_t : a graphene_simd4f_t @res: (out): return location for a graphene_simd4f_t

Left multiplies the given graphene_simd4x4f_t with the given graphene_simd4f_t row vector using a dot product:

|[ res = b × A

= ⎡x⎤ ⎛ x.x  x.y  x.z  x.w ⎞
  ⎜y⎟ ⎜ y.x  y.y  y.z  y.w ⎟
  ⎜z⎟ ⎜ z.x  z.y  z.z  z.w ⎟
  ⎣w⎦ ⎝ w.x  w.y  w.z  w.w ⎠

= [ x.x × x   x.y × x   x.z × x   x.w × x ]
       +         +         +         +
  [ y.x × y   y.y × y   y.z × y   y.w × y ]
       +         +         +         +
  [ z.x × z   z.y × z   z.z × z   z.w × z ]
       +         +         +         +
  [ w.x × w   w.y × w   w.z × w   w.w × w ]

= ⎡ x.x × x + y.x × y + z.x × z + w.x × w ⎤
  ⎜ x.y × x + y.y × y + z.y × z + w.y × w ⎟
  ⎜ x.z × x + y.z × y + z.z × z + w.z × w ⎟
  ⎣ x.w × x + y.w × y + z.w × z + w.w × w ⎦

]|

Since: 1.0

Definition at line 270 of file graphene-simd4x4f.h.

273{
274 const graphene_simd4f_t v = *b;
279
281 graphene_simd4f_mul (a->y, v_y)),
283 graphene_simd4f_mul (a->w, v_w)));
284}
#define graphene_simd4f_splat_w(s)

References graphene_simd4f_add, graphene_simd4f_mul, graphene_simd4f_splat_w, graphene_simd4f_splat_x, graphene_simd4f_splat_y, and graphene_simd4f_splat_z.

Referenced by graphene_simd4x4f_matrix_mul().