37 t8_vec_norm (
const double vec[3])
41 for (
int i = 0; i < 3; i++) {
42 norm += vec[i] * vec[i];
51 t8_vec_normalize (
double vec[3])
53 const double inv_norm = 1.0 / t8_vec_norm (vec);
55 for (
int i = 0; i < 3; i++) {
65 t8_vec_copy (
const double vec_in[3],
double vec_out[3])
67 for (
int i = 0; i < 3; i++) {
68 vec_out[i] = vec_in[i];
79 t8_vec_dist (
const double vec_x[3],
const double vec_y[3])
83 for (
int i = 0; i < 3; i++) {
84 dist += SC_SQR (vec_x[i] - vec_y[i]);
94 t8_vec_ax (
double vec_x[3],
const double alpha)
96 for (
int i = 0; i < 3; i++) {
107 t8_vec_axy (
const double vec_x[3],
double vec_y[3],
const double alpha)
109 for (
int i = 0; i < 3; i++) {
110 vec_y[i] = vec_x[i] * alpha;
123 t8_vec_axb (
const double vec_x[3],
double vec_y[3],
const double alpha,
const double b)
125 for (
int i = 0; i < 3; i++) {
126 vec_y[i] = alpha * vec_x[i] + b;
137 t8_vec_axpy (
const double vec_x[3],
double vec_y[3],
const double alpha)
139 for (
int i = 0; i < 3; i++) {
140 vec_y[i] += alpha * vec_x[i];
150 t8_vec_axpyz (
const double vec_x[3],
const double vec_y[3],
double vec_z[3],
const double alpha)
152 for (
int i = 0; i < 3; i++) {
153 vec_z[i] = vec_y[i] + alpha * vec_x[i];
163 t8_vec_dot (
const double vec_x[3],
const double vec_y[3])
167 for (
int i = 0; i < 3; i++) {
168 dot += vec_x[i] * vec_y[i];
179 t8_vec_cross (
const double vec_x[3],
const double vec_y[3],
double cross[3])
181 for (
int i = 0; i < 3; i++) {
182 cross[i] = vec_x[(i + 1) % 3] * vec_y[(i + 2) % 3] - vec_x[(i + 2) % 3] * vec_y[(i + 1) % 3];
192 t8_vec_diff (
const double vec_x[3],
const double vec_y[3],
double diff[3])
194 for (
int i = 0; i < 3; i++) {
195 diff[i] = vec_x[i] - vec_y[i];
208 t8_vec_eq (
const double vec_x[3],
const double vec_y[3],
const double tol)
211 return fabs (vec_x[0] - vec_y[0]) <= tol && fabs (vec_x[1] - vec_y[1]) <= tol && fabs (vec_x[2] - vec_y[2]) <= tol;
219 t8_vec_rescale (
double vec[3],
const double new_length)
221 t8_vec_normalize (vec);
222 t8_vec_ax (vec, new_length);
232 t8_vec_tri_normal (
const double p1[3],
const double p2[3],
const double p3[3],
double normal[3])
237 a[0] = p2[0] - p1[0];
238 a[1] = p2[1] - p1[1];
239 a[2] = p2[2] - p1[2];
241 b[0] = p3[0] - p1[0];
242 b[1] = p3[1] - p1[1];
243 b[2] = p3[2] - p1[2];
245 t8_vec_cross (a, b, normal);
253 t8_vec_swap (
double p1[3],
double p2[3])
256 for (
int i = 0; i < 3; i++) {
This is the administrative header file for t8code.
#define T8_ASSERT(c)
Widely used assertion.
Definition: t8.h:71