33 #ifndef LE_GEOMETRY_SIMD_H
34 #define LE_GEOMETRY_SIMD_H
51 struct {
float x, y, z, w;};
56 V4SF vi = {0.0f, 0.0f, 0.0f, 1.0f};
60 LeVertex(
float px,
float py,
float pz)
62 V4SF vi = {px, py, pz, 1.0f};
66 LeVertex(
float px,
float py,
float pz,
float pw)
68 V4SF vi = {px, py, pz, pw};
73 static LeVertex spherical(
float azi,
float inc,
float dist)
76 r.
x = cosf(azi) * cosf(inc) * dist;
77 r.
y = sinf(inc) * dist;
78 r.
z = -sinf(azi) * cosf(inc) * dist;
132 V4SF vs = {v, v, v, v};
140 V4SF vs = {v, v, v, v};
159 V4SF vs = {v, v, v, v};
166 V4SF vs = {v, v, v, v};
182 return d.
x + d.
y + d.
z;
188 c.
x = y * v.
z - v.
y * z;
189 c.
y = -x * v.
z + v.
x * z;
190 c.
z = x * v.
y - v.
x * y;
197 c.
x = copysignf(1.0f, x);
198 c.
y = copysignf(1.0f, y);
199 c.
z = copysignf(1.0f, z);
200 c.
w = copysignf(1.0f, w);
207 c.
x = floorf(x + 0.5f);
208 c.
y = floorf(y + 0.5f);
209 c.
z = floorf(z + 0.5f);
210 c.
w = floorf(w + 0.5f);
228 V4SF vi = {0.0f, 0.0f, 0.0f, 1.0f};
232 V4SF vs = {d, d, d, d};
240 return sqrtf(dot(*
this));
265 axis = (v2 - v1).normalize();
266 norm = (v2 - v1).norm();
283 xAxis.axis =
LeVertex(1.0f, 0.0f, 0.0f);
311 lines[0] =
LeVertex(1.0f, 0.0f, 0.0f, 0.0f);
312 lines[1] =
LeVertex(0.0f, 1.0f, 0.0f, 0.0f);
313 lines[2] =
LeVertex(0.0f, 0.0f, 1.0f, 0.0f);
314 lines[3] =
LeVertex(0.0f, 0.0f, 0.0f, 1.0f);
329 m.lines[0] =
LeVertex(lines[0].x, lines[1].x, lines[2].x, lines[3].x);
330 m.lines[1] =
LeVertex(lines[0].x, lines[1].x, lines[2].x, lines[3].x);
331 m.lines[2] =
LeVertex(lines[0].x, lines[1].x, lines[2].x, lines[3].x);
332 m.lines[3] =
LeVertex(lines[0].x, lines[1].x, lines[2].x, lines[3].x);
395 void rotateX(
float a)
409 void rotateY(
float a)
423 void rotateZ(
float a)
437 void rotate(
LeVertex axis,
float angle)
439 float c = cosf(angle);
440 float s = sinf(angle);
444 m.lines[0] =
LeVertex(c + axis.
x * axis.
x * d, axis.
x * axis.
y * d - axis.
z * s, axis.
x * axis.
z * d + axis.
y * s, 0.0f);
445 m.lines[1] =
LeVertex(axis.
y * axis.
x * d + axis.
z * s, c + axis.
y * axis.
y * d, axis.
y * axis.
z * d - axis.
x * s, 0.0f);
446 m.lines[2] =
LeVertex(axis.
z * axis.
x * d - axis.
y * s, axis.
z * axis.
y * d + axis.
x * s, c + axis.
z * axis.
z * d, 0.0f);
447 m.lines[3] =
LeVertex(0.0f, 0.0f, 0.0f, 1.0f);
455 float l = sqrtf(lines[0].x * lines[0].x + lines[1].x * lines[1].x);
457 angle.
x = atan2f(lines[2].y, lines[2].z);
458 angle.
y = atan2f(-lines[2].x, l);
459 angle.
z = atan2f(lines[1].x, lines[0].x);
462 angle.
x = atan2f(-lines[1].z, lines[1].y);
463 angle.
y = atan2f(-lines[2].x, l);
476 m.lines[0] =
LeVertex(right.
x, up.
x, back.
x, 0.0f);
477 m.lines[1] =
LeVertex(right.
y, up.
y, back.
y, 0.0f);
478 m.lines[2] =
LeVertex(right.
z, up.
z, back.
z, 0.0f);
479 m.lines[3] =
LeVertex(0.0f, 0.0f, 0.0f, 1.0f);
491 m.lines[0] =
LeVertex(right.
x, up.
x, back.
x, 0.0f);
492 m.lines[1] =
LeVertex(right.
y, up.
y, back.
y, 0.0f);
493 m.lines[2] =
LeVertex(right.
z, up.
z, back.
z, 0.0f);
494 m.lines[3] =
LeVertex(0.0f, 0.0f, 0.0f, 1.0f);
502 float d = lines[0].x*(lines[1].y*lines[2].z-lines[2].y*lines[1].z)
503 - lines[0].y*(lines[1].x*lines[2].z-lines[1].z*lines[2].x)
504 + lines[0].z*(lines[1].x*lines[2].y-lines[1].y*lines[2].x);
507 if (d == 0.0f) {m.
zero();
return m;}
510 m.lines[0].x = (lines[1].y * lines[2].z - lines[2].y * lines[1].z) * d;
511 m.lines[0].y = -(lines[0].y * lines[2].z - lines[2].y * lines[0].z) * d;
512 m.lines[0].z = (lines[0].y * lines[1].z - lines[1].y * lines[0].z) * d;
514 m.lines[1].x = -(lines[1].x * lines[2].z - lines[2].x * lines[1].z) * d;
515 m.lines[1].y = (lines[0].x * lines[2].z - lines[2].x * lines[0].z) * d;
516 m.lines[1].z = -(lines[0].x * lines[1].z - lines[1].x * lines[0].z) * d;
518 m.lines[2].x = (lines[1].x * lines[2].y - lines[2].x * lines[1].y) * d;
519 m.lines[2].y = -(lines[0].x * lines[2].y - lines[2].x * lines[0].y) * d;
520 m.lines[2].z = (lines[0].x * lines[1].y - lines[1].x * lines[0].y) * d;
533 l2.
x + l2.
y + l2.
z + l2.
w,
534 l3.
x + l3.
y + l3.
z + l3.
w);
540 r.lines[0] = lines[0] + m.lines[0];
541 r.lines[1] = lines[1] + m.lines[1];
542 r.lines[2] = lines[2] + m.lines[2];
543 r.lines[3] = lines[3] + m.lines[3];
551 for (
int i = 0; i < 4; i++) {
556 r.lines[i] = vx * m.lines[0] + vy * m.lines[1] + vz * m.lines[2] + vw * m.lines[3];
574 #endif //LE_GEOMETRY_SIMD_H
const LeVertex up
Definition: geometry_scalar.h:661
struct __attribute__((aligned(16))) LeVertex
Definition: geometry_simd.h:47
LightEngine 3D: General engine configuration file.
float x
Definition: geometry_scalar.h:48
LightEngine 3D: Global helpers and definitions.
Definition: geometry_scalar.h:660
const LeVertex down
Definition: geometry_scalar.h:662
const LeVertex back
Definition: geometry_scalar.h:664
const LeVertex front
Definition: geometry_scalar.h:663
LeVertex cross(LeVertex v) const
Definition: geometry_scalar.h:198
float y
Definition: geometry_scalar.h:48
LeVertex normalize()
Definition: geometry_scalar.h:237
Represent a vertex in 3D space.
Definition: geometry_scalar.h:46
Represent a 4x4 matrix to handle 3D transforms.
Definition: geometry_scalar.h:346
LeVertex axis
Definition: geometry_scalar.h:268
float z
Definition: geometry_scalar.h:48
float w
Definition: geometry_scalar.h:48
Represent an axis in 3D space.
Definition: geometry_scalar.h:265
const LeVertex left
Definition: geometry_scalar.h:665
const LeVertex zero
Definition: geometry_scalar.h:667
LightEngine 3D: SIMD constants / types and intrinsic definitions.
const LeVertex right
Definition: geometry_scalar.h:666
Represent a plane in 3D space.
Definition: geometry_scalar.h:302
void zero()
Definition: geometry_scalar.h:378