Go to the source code of this file.
|
| void | vector3_add (const double a[3], const double b[3], double out[3]) |
| | Add two 3D vectors component-wise.
|
| |
| void | vector3_cross (const double a[3], const double b[3], double out[3]) |
| | Compute the cross product of two vectors.
|
| |
| double | vector3_dot (const double a[3], const double b[3]) |
| | Compute the dot product of two vectors.
|
| |
| void | vector3_normalize (double v[3]) |
| | Normalise a 3D vector in-place.
|
| |
| void | vector3_sub (const double a[3], const double b[3], double out[3]) |
| | Subtract two 3D vectors component-wise.
|
| |
◆ vector3_add()
| void vector3_add |
( |
const double |
a[3], |
|
|
const double |
b[3], |
|
|
double |
out[3] |
|
) |
| |
Add two 3D vectors component-wise.
- Parameters
-
| a | First operand. |
| b | Second operand. |
| out | Output \(a + b\). |
Definition at line 4 of file vector3.c.
4 {
5 out[0] = a[0] + b[0];
6 out[1] = a[1] + b[1];
7 out[2] = a[2] + b[2];
8}
◆ vector3_cross()
| void vector3_cross |
( |
const double |
a[3], |
|
|
const double |
b[3], |
|
|
double |
out[3] |
|
) |
| |
Compute the cross product of two vectors.
- Parameters
-
| a | First vector. |
| b | Second vector. |
| out | Output \(a \times b\). |
Definition at line 20 of file vector3.c.
20 {
21 out[0] = a[1]*b[2] - a[2]*b[1];
22 out[1] = a[2]*b[0] - a[0]*b[2];
23 out[2] = a[0]*b[1] - a[1]*b[0];
24}
◆ vector3_dot()
| double vector3_dot |
( |
const double |
a[3], |
|
|
const double |
b[3] |
|
) |
| |
Compute the dot product of two vectors.
- Parameters
-
| a | First vector. |
| b | Second vector. |
- Returns
- Dot product \(a \cdot b\).
Definition at line 16 of file vector3.c.
16 {
17 return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
18}
◆ vector3_normalize()
| void vector3_normalize |
( |
double |
v[3] | ) |
|
Normalise a 3D vector in-place.
- Parameters
-
Definition at line 26 of file vector3.c.
26 {
27 double mag = sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
28 if (mag > 0) {
29 v[0]/=mag; v[1]/=mag; v[2]/=mag;
30 }
31}
◆ vector3_sub()
| void vector3_sub |
( |
const double |
a[3], |
|
|
const double |
b[3], |
|
|
double |
out[3] |
|
) |
| |
Subtract two 3D vectors component-wise.
- Parameters
-
| a | Minuend. |
| b | Subtrahend. |
| out | Output \(a - b\). |
Definition at line 10 of file vector3.c.
10 {
11 out[0] = a[0] - b[0];
12 out[1] = a[1] - b[1];
13 out[2] = a[2] - b[2];
14}