liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
vector3.h
Go to the documentation of this file.
1
5
6#ifndef LIBA_VECTOR3_H
7#define LIBA_VECTOR3_H
8
9#include "a.h"
10#include "math.h"
11
17
18/* clang-format off */
20#define A_VECTOR3_C(x, y, z) {a_real_c(x), a_real_c(y), a_real_c(z)}
21/* clang-format on */
22
24#define a_vector3_c(x) a_cast_s(a_vector3, x)
25#define a_vector3_(_, x) a_cast_s(a_vector3 _, x)
26
27typedef struct a_vector3 a_vector3;
28
29#if defined(__cplusplus)
30namespace a
31{
32typedef struct a_vector3 vector3;
33} /* namespace a */
34extern "C" {
35#endif /* __cplusplus */
36#if !defined A_HAVE_INLINE || defined(LIBA_VECTOR3_C)
38#undef A_INTERN
39#define A_INTERN A_PUBLIC extern
41#endif /* A_HAVE_INLINE */
42
51A_INTERN void a_vector3_val(a_vector3 const *ctx, a_real *x, a_real *y, a_real *z);
55A_INTERN void a_vector3_set_val(a_vector3 *ctx, a_real x, a_real y, a_real z);
59A_INTERN void a_vector3_cyl(a_vector3 const *ctx, a_real *rho, a_real *theta, a_real *z);
63A_INTERN void a_vector3_set_cyl(a_vector3 *ctx, a_real rho, a_real theta, a_real z);
67A_INTERN void a_vector3_sph(a_vector3 const *ctx, a_real *rho, a_real *theta, a_real *alpha);
71A_INTERN void a_vector3_set_sph(a_vector3 *ctx, a_real rho, a_real theta, a_real alpha);
72
76A_INTERN void a_vector3_add(a_vector3 const *lhs, a_vector3 const *rhs, a_vector3 *res);
80A_INTERN void a_vector3_sub(a_vector3 const *lhs, a_vector3 const *rhs, a_vector3 *res);
84A_INTERN void a_vector3_mul(a_vector3 const *lhs, a_real rhs, a_vector3 *res);
88A_INTERN void a_vector3_div(a_vector3 const *lhs, a_real rhs, a_vector3 *res);
92A_INTERN void a_vector3_neg(a_vector3 const *ctx, a_vector3 *res);
93
110A_EXTERN a_real a_vector3_norm(a_vector3 const *ctx);
121A_EXTERN a_real a_vector3_norm2(a_vector3 const *ctx);
135A_EXTERN a_real a_vector3_dot(a_vector3 const *lhs, a_vector3 const *rhs);
149A_EXTERN a_real a_vector3_dist(a_vector3 const *lhs, a_vector3 const *rhs);
163A_EXTERN a_real a_vector3_dist2(a_vector3 const *lhs, a_vector3 const *rhs);
179A_EXTERN a_real a_vector3_angle(a_vector3 const *lhs, a_vector3 const *rhs);
187A_EXTERN a_bool a_vector3_isver(a_vector3 const *lhs, a_vector3 const *rhs);
195A_EXTERN a_bool a_vector3_ispar(a_vector3 const *lhs, a_vector3 const *rhs);
212A_EXTERN void a_vector3_cross(a_vector3 const *lhs, a_vector3 const *rhs, a_vector3 *res);
229A_EXTERN void a_vector3_outer(a_vector3 const *lhs, a_vector3 const *rhs, a_real res[9]);
230
252A_EXTERN int a_vector3_ortho(a_vector3 const *ctx, a_vector3 *u, a_vector3 *v);
253
269A_EXTERN int a_vector3_proj(a_vector3 const *ctx, a_vector3 const *dir, a_vector3 *res);
285A_EXTERN int a_vector3_perp(a_vector3 const *ctx, a_vector3 const *dir, a_vector3 *res);
301A_EXTERN int a_vector3_refl(a_vector3 const *ctx, a_vector3 const *dir, a_vector3 *res);
317A_EXTERN int a_vector3_sym1(a_vector3 const *ctx, a_vector3 const *dir, a_vector3 *res);
318
334A_EXTERN void a_vector3_rot_(a_vector3 const *ctx, a_vector3 const *dir, a_real sin, a_real cos, a_vector3 *res);
349A_EXTERN void a_vector3_rot(a_vector3 const *ctx, a_vector3 const *dir, a_real angle, a_vector3 *res);
369A_EXTERN void a_vector3_rot2d(a_vector3 const *iu, a_vector3 const *iv, a_real angle,
370 a_vector3 *ou, a_vector3 *ov);
371
372#if !defined A_HAVE_INLINE || defined(LIBA_VECTOR3_C)
374#undef A_INTERN
375#define A_INTERN static A_INLINE
377#endif /* A_HAVE_INLINE */
378#if defined(__cplusplus)
379} /* extern "C" */
380#endif /* __cplusplus */
381
382struct a_point3;
387{
388 a_real x, y, z;
389#if defined(__cplusplus)
391 A_INLINE void set(a_point3 const &p, a_point3 const &q);
393 A_INLINE a_real set_dir(a_real x_, a_real y_, a_real z_)
394 {
395 return a_vector3_set_dir(this, x_, y_, z_);
396 }
397
398 A_INLINE void val(a_real &x_, a_real &y_, a_real &z_) const
399 {
400 a_vector3_val(this, &x_, &y_, &z_);
401 }
402
403 A_INLINE void set_val(a_real x_, a_real y_, a_real z_)
404 {
405 a_vector3_set_val(this, x_, y_, z_);
406 }
407
408 A_INLINE void cyl(a_real &rho, a_real &theta, a_real &z_) const
409 {
410 a_vector3_cyl(this, &rho, &theta, &z_);
411 }
412
413 A_INLINE void set_cyl(a_real rho, a_real theta, a_real z_)
414 {
415 a_vector3_set_cyl(this, rho, theta, z_);
416 }
417
418 A_INLINE void sph(a_real &rho, a_real &theta, a_real &alpha) const
419 {
420 a_vector3_sph(this, &rho, &theta, &alpha);
421 }
422
423 A_INLINE void set_sph(a_real rho, a_real theta, a_real alpha)
424 {
425 a_vector3_set_sph(this, rho, theta, alpha);
426 }
427
428 A_INLINE void add(a_vector3 const &rhs, a_vector3 &res) const
429 {
430 a_vector3_add(this, &rhs, &res);
431 }
432
433 A_INLINE void sub(a_vector3 const &rhs, a_vector3 &res) const
434 {
435 a_vector3_sub(this, &rhs, &res);
436 }
437
438 A_INLINE void mul(a_real rhs, a_vector3 &res) const
439 {
440 a_vector3_mul(this, rhs, &res);
441 }
442
443 A_INLINE void div(a_real rhs, a_vector3 &res) const
444 {
445 a_vector3_div(this, rhs, &res);
446 }
447
448 A_INLINE void neg(a_vector3 &res) const
449 {
450 a_vector3_neg(this, &res);
451 }
452
453 A_INLINE a_real unit() { return a_vector3_unit(this); }
455 A_INLINE a_real norm() const { return a_vector3_norm(this); }
457 A_INLINE a_real norm2() const { return a_vector3_norm2(this); }
459 A_INLINE a_real dot(a_vector3 const &rhs) const { return a_vector3_dot(this, &rhs); }
461 A_INLINE a_real dist(a_vector3 const &rhs) const { return a_vector3_dist(this, &rhs); }
463 A_INLINE a_real dist2(a_vector3 const &rhs) const { return a_vector3_dist2(this, &rhs); }
465 A_INLINE a_real angle(a_vector3 const &rhs) const { return a_vector3_angle(this, &rhs); }
467 A_INLINE a_bool isver(a_vector3 const &rhs) const { return a_vector3_isver(this, &rhs); }
469 A_INLINE a_bool ispar(a_vector3 const &rhs) const { return a_vector3_ispar(this, &rhs); }
471 A_INLINE void cross(a_vector3 const &rhs, a_vector3 &res) const
472 {
473 a_vector3_cross(this, &rhs, &res);
474 }
475
476 A_INLINE void outer(a_vector3 const &rhs, a_real res[9]) const
477 {
478 a_vector3_outer(this, &rhs, res);
479 }
480
481 A_INLINE int ortho(a_vector3 &u, a_vector3 &v) const
482 {
483 return a_vector3_ortho(this, &u, &v);
484 }
485
486 A_INLINE int proj(a_vector3 const &dir, a_vector3 &res) const
487 {
488 return a_vector3_proj(this, &dir, &res);
489 }
490
491 A_INLINE int perp(a_vector3 const &dir, a_vector3 &res) const
492 {
493 return a_vector3_perp(this, &dir, &res);
494 }
495
496 A_INLINE int refl(a_vector3 const &dir, a_vector3 &res) const
497 {
498 return a_vector3_refl(this, &dir, &res);
499 }
500
501 A_INLINE int sym1(a_vector3 const &dir, a_vector3 &res) const
502 {
503 return a_vector3_sym1(this, &dir, &res);
504 }
505
506 A_INLINE void rot(a_vector3 const &dir, a_real angle, a_vector3 &res) const
507 {
508 a_vector3_rot(this, &dir, angle, &res);
509 }
510
511 A_INLINE void rot(a_vector3 const &dir, a_real sin, a_real cos, a_vector3 &res) const
512 {
513 a_vector3_rot_(this, &dir, sin, cos, &res);
514 }
515
516 static A_INLINE void rot2d(a_vector3 const &iu, a_vector3 const &iv, a_real angle,
517 a_vector3 &ou, a_vector3 &ov)
518 {
519 a_vector3_rot2d(&iu, &iv, angle, &ou, &ov);
520 }
521
522 friend A_INLINE a_vector3 operator^(a_vector3 const &lhs, a_vector3 const &rhs)
523 {
524 a_vector3 res;
525 a_vector3_cross(&lhs, &rhs, &res);
526 return res;
527 }
528
529 friend A_INLINE void operator+=(a_vector3 &lhs, a_vector3 const &rhs) { a_vector3_add(&lhs, &rhs, &lhs); }
531 friend A_INLINE a_vector3 operator+(a_vector3 const &lhs, a_vector3 const &rhs)
532 {
533 a_vector3 res;
534 a_vector3_add(&lhs, &rhs, &res);
535 return res;
536 }
537
538 friend A_INLINE void operator-=(a_vector3 &lhs, a_vector3 const &rhs) { a_vector3_sub(&lhs, &rhs, &lhs); }
540 friend A_INLINE a_vector3 operator-(a_vector3 const &lhs, a_vector3 const &rhs)
541 {
542 a_vector3 res;
543 a_vector3_sub(&lhs, &rhs, &res);
544 return res;
545 }
546
547 friend A_INLINE a_real operator*(a_vector3 const &lhs, a_vector3 const &rhs)
548 {
549 return a_vector3_dot(&lhs, &rhs);
550 }
551
552 friend A_INLINE void operator*=(a_vector3 &lhs, a_real rhs) { a_vector3_mul(&lhs, rhs, &lhs); }
554 friend A_INLINE a_vector3 operator*(a_real lhs, a_vector3 const &rhs)
555 {
556 a_vector3 res;
557 a_vector3_mul(&rhs, lhs, &res);
558 return res;
559 }
560
561 friend A_INLINE a_vector3 operator*(a_vector3 const &lhs, a_real rhs)
562 {
563 a_vector3 res;
564 a_vector3_mul(&lhs, rhs, &res);
565 return res;
566 }
567
568 friend A_INLINE void operator/=(a_vector3 &lhs, a_real rhs) { a_vector3_div(&lhs, rhs, &lhs); }
570 friend A_INLINE a_vector3 operator/(a_vector3 const &lhs, a_real rhs)
571 {
572 a_vector3 res;
573 a_vector3_div(&lhs, rhs, &res);
574 return res;
575 }
576 friend A_INLINE a_vector3 operator+(a_vector3 const &rhs) { return rhs; }
578 friend A_INLINE a_vector3 operator-(a_vector3 const &rhs)
579 {
580 a_vector3 res;
581 a_vector3_neg(&rhs, &res);
582 return res;
583 }
584#endif /* __cplusplus */
585};
586
587#if defined(LIBA_VECTOR3_C)
589#undef A_INTERN
590#define A_INTERN A_INLINE
592#endif /* LIBA_VECTOR3_C */
593#if defined(A_HAVE_INLINE) || defined(LIBA_VECTOR3_C)
594
596{
597 ctx->x = x;
598 ctx->y = y;
599 ctx->z = z;
600 return a_vector3_unit(ctx);
601}
602A_INTERN void a_vector3_val(a_vector3 const *ctx, a_real *x, a_real *y, a_real *z)
603{
604 *x = ctx->x;
605 *y = ctx->y;
606 *z = ctx->z;
607}
608A_INTERN void a_vector3_set_val(a_vector3 *ctx, a_real x, a_real y, a_real z)
609{
610 ctx->x = x;
611 ctx->y = y;
612 ctx->z = z;
613}
614A_INTERN void a_vector3_cyl(a_vector3 const *ctx, a_real *rho, a_real *theta, a_real *z)
615{
616 a_real_cart2pol(ctx->x, ctx->y, rho, theta);
617 *z = ctx->z;
618}
619A_INTERN void a_vector3_set_cyl(a_vector3 *ctx, a_real rho, a_real theta, a_real z)
620{
621 a_real_pol2cart(rho, theta, &ctx->x, &ctx->y);
622 ctx->z = z;
623}
624A_INTERN void a_vector3_sph(a_vector3 const *ctx, a_real *rho, a_real *theta, a_real *alpha)
625{
626 a_real_cart2sph(ctx->x, ctx->y, ctx->z, rho, theta, alpha);
627}
628A_INTERN void a_vector3_set_sph(a_vector3 *ctx, a_real rho, a_real theta, a_real alpha)
629{
630 a_real_sph2cart(rho, theta, alpha, &ctx->x, &ctx->y, &ctx->z);
631}
632A_INTERN void a_vector3_add(a_vector3 const *lhs, a_vector3 const *rhs, a_vector3 *res)
633{
634 res->x = lhs->x + rhs->x;
635 res->y = lhs->y + rhs->y;
636 res->z = lhs->z + rhs->z;
637}
638A_INTERN void a_vector3_sub(a_vector3 const *lhs, a_vector3 const *rhs, a_vector3 *res)
639{
640 res->x = lhs->x - rhs->x;
641 res->y = lhs->y - rhs->y;
642 res->z = lhs->z - rhs->z;
643}
644A_INTERN void a_vector3_mul(a_vector3 const *lhs, a_real rhs, a_vector3 *res)
645{
646 res->x = lhs->x * rhs;
647 res->y = lhs->y * rhs;
648 res->z = lhs->z * rhs;
649}
650A_INTERN void a_vector3_div(a_vector3 const *lhs, a_real rhs, a_vector3 *res)
651{
652 res->x = lhs->x / rhs;
653 res->y = lhs->y / rhs;
654 res->z = lhs->z / rhs;
655}
656A_INTERN void a_vector3_neg(a_vector3 const *ctx, a_vector3 *res)
657{
658 res->x = -ctx->x;
659 res->y = -ctx->y;
660 res->z = -ctx->z;
661}
662
663#endif /* A_HAVE_INLINE */
664#if defined(LIBA_VECTOR3_C)
666#undef A_INTERN
667#define A_INTERN static A_INLINE
669#endif /* LIBA_VECTOR3_C */
670
672
673#endif /* a/vector3.h */
algorithm library
void set(a_point3 const &p, a_point3 const &q)
set a 3D vector as the difference from point p to point q.
Definition point3.h:183
double a_real
compiler built-in floating-point number type
Definition a.h:1012
void a_vector3_cyl(a_vector3 const *ctx, a_real *rho, a_real *theta, a_real *z)
get the cylindrical coordinates of a 3D vector.
void a_vector3_rot(a_vector3 const *ctx, a_vector3 const *dir, a_real angle, a_vector3 *res)
rotate a 3D vector around an arbitrary unit axis using Rodrigues' rotation formula.
int a_vector3_sym1(a_vector3 const *ctx, a_vector3 const *dir, a_vector3 *res)
reflect vector across the line with direction vector.
void a_vector3_mul(a_vector3 const *lhs, a_real rhs, a_vector3 *res)
multiplie a 3D vector by a scalar.
void a_vector3_set_cyl(a_vector3 *ctx, a_real rho, a_real theta, a_real z)
set the cylindrical coordinates of a 3D vector.
void a_vector3_set_sph(a_vector3 *ctx, a_real rho, a_real theta, a_real alpha)
set the spherical coordinates of a 3D vector.
a_real a_vector3_dot(a_vector3 const *lhs, a_vector3 const *rhs)
compute the dot product (scalar product) of two 3D vectors.
void a_vector3_rot_(a_vector3 const *ctx, a_vector3 const *dir, a_real sin, a_real cos, a_vector3 *res)
rotate a 3D vector around an arbitrary unit axis using Rodrigues' rotation formula.
void a_vector3_sph(a_vector3 const *ctx, a_real *rho, a_real *theta, a_real *alpha)
get the spherical coordinates of a 3D vector.
void a_vector3_set_val(a_vector3 *ctx, a_real x, a_real y, a_real z)
set the cartesian coordinates of a 3D vector.
a_real a_vector3_norm2(a_vector3 const *ctx)
compute the squared magnitude of a 3D vector.
void a_vector3_outer(a_vector3 const *lhs, a_vector3 const *rhs, a_real res[9])
compute the outer product (tensor product) of two 3D vectors.
a_real a_vector3_set_dir(a_vector3 *ctx, a_real x, a_real y, a_real z)
set the components of a 3D vector and normalize it in place.
void a_vector3_add(a_vector3 const *lhs, a_vector3 const *rhs, a_vector3 *res)
add a 3D vector to a 3D vector.
void a_vector3_cross(a_vector3 const *lhs, a_vector3 const *rhs, a_vector3 *res)
compute the cross product (vector product) of two 3D vectors
void a_vector3_rot2d(a_vector3 const *iu, a_vector3 const *iv, a_real angle, a_vector3 *ou, a_vector3 *ov)
rotate a 2D basis in the plane spanned by two orthogonal vectors.
int a_vector3_ortho(a_vector3 const *ctx, a_vector3 *u, a_vector3 *v)
construct an orthonormal basis from a given 3D direction vector.
a_bool a_vector3_isver(a_vector3 const *lhs, a_vector3 const *rhs)
check if two 3D vectors are orthogonal.
a_bool a_vector3_ispar(a_vector3 const *lhs, a_vector3 const *rhs)
check if two 3D vectors are parallel or anti-parallel.
a_real a_vector3_angle(a_vector3 const *lhs, a_vector3 const *rhs)
compute the angle between two 3D vectors in radians.
int a_vector3_proj(a_vector3 const *ctx, a_vector3 const *dir, a_vector3 *res)
project vector onto the direction of vector.
a_real a_vector3_dist2(a_vector3 const *lhs, a_vector3 const *rhs)
compute the squared distance between two 3D vectors.
int a_vector3_refl(a_vector3 const *ctx, a_vector3 const *dir, a_vector3 *res)
reflect vector across the plane perpendicular to normal vector.
a_real a_vector3_dist(a_vector3 const *lhs, a_vector3 const *rhs)
compute the distance between two 3D vectors.
a_real a_vector3_norm(a_vector3 const *ctx)
compute the magnitude of a 3D vector.
a_real a_vector3_unit(a_vector3 *ctx)
normalize a 3D vector in-place to unit length.
void a_vector3_neg(a_vector3 const *ctx, a_vector3 *res)
negate a 3D vector.
void a_vector3_div(a_vector3 const *lhs, a_real rhs, a_vector3 *res)
divide a 3D vector by a scalar.
void a_vector3_sub(a_vector3 const *lhs, a_vector3 const *rhs, a_vector3 *res)
subtract a 3D vector from a 3D vector.
void a_vector3_val(a_vector3 const *ctx, a_real *x, a_real *y, a_real *z)
get the cartesian coordinates of a 3D vector.
int a_vector3_perp(a_vector3 const *ctx, a_vector3 const *dir, a_vector3 *res)
project vector onto the plane perpendicular to normal vector.
bool a_bool
type, capable of holding one of the two values: 1 and 0
Definition a.h:320
mathematical algorithm library
instance structure for three-dimensional point
Definition point3.h:193
instance structure for three-dimensional vector
Definition vector3.h:387
a_bool ispar(a_vector3 const &rhs) const
check if two 3D vectors are parallel or anti-parallel.
Definition vector3.h:469
void rot(a_vector3 const &dir, a_real sin, a_real cos, a_vector3 &res) const
rotate a 3D vector around an arbitrary unit axis using Rodrigues' rotation formula.
Definition vector3.h:511
friend a_vector3 operator+(a_vector3 const &lhs, a_vector3 const &rhs)
add a 3D vector to a 3D vector.
Definition vector3.h:531
friend a_vector3 operator*(a_real lhs, a_vector3 const &rhs)
multiplie a 3D vector by a scalar.
Definition vector3.h:554
int proj(a_vector3 const &dir, a_vector3 &res) const
project vector onto the direction of vector.
Definition vector3.h:486
a_real norm2() const
compute the squared magnitude of a 3D vector.
Definition vector3.h:457
void set_cyl(a_real rho, a_real theta, a_real z_)
set the cylindrical coordinates of a 3D vector.
Definition vector3.h:413
void div(a_real rhs, a_vector3 &res) const
divide a 3D vector by a scalar.
Definition vector3.h:443
void sub(a_vector3 const &rhs, a_vector3 &res) const
subtract a 3D vector from a 3D vector.
Definition vector3.h:433
a_real unit()
normalize a 3D vector in-place to unit length.
Definition vector3.h:453
void val(a_real &x_, a_real &y_, a_real &z_) const
get the cartesian coordinates of a 3D vector.
Definition vector3.h:398
int perp(a_vector3 const &dir, a_vector3 &res) const
project vector onto the plane perpendicular to normal vector.
Definition vector3.h:491
friend void operator+=(a_vector3 &lhs, a_vector3 const &rhs)
add a 3D vector to a 3D vector.
Definition vector3.h:529
friend a_vector3 operator^(a_vector3 const &lhs, a_vector3 const &rhs)
compute the cross product (vector product) of two 3D vectors
Definition vector3.h:522
void outer(a_vector3 const &rhs, a_real res[9]) const
compute the outer product (tensor product) of two 3D vectors.
Definition vector3.h:476
void cyl(a_real &rho, a_real &theta, a_real &z_) const
get the cylindrical coordinates of a 3D vector.
Definition vector3.h:408
a_bool isver(a_vector3 const &rhs) const
check if two 3D vectors are orthogonal.
Definition vector3.h:467
friend void operator*=(a_vector3 &lhs, a_real rhs)
multiplie a 3D vector by a scalar.
Definition vector3.h:552
friend void operator-=(a_vector3 &lhs, a_vector3 const &rhs)
subtract a 3D vector from a 3D vector.
Definition vector3.h:538
a_real dist(a_vector3 const &rhs) const
compute the distance between two 3D vectors.
Definition vector3.h:461
int refl(a_vector3 const &dir, a_vector3 &res) const
reflect vector across the plane perpendicular to normal vector.
Definition vector3.h:496
static void rot2d(a_vector3 const &iu, a_vector3 const &iv, a_real angle, a_vector3 &ou, a_vector3 &ov)
rotate a 2D basis in the plane spanned by two orthogonal vectors.
Definition vector3.h:516
a_real dist2(a_vector3 const &rhs) const
compute the squared distance between two 3D vectors.
Definition vector3.h:463
int sym1(a_vector3 const &dir, a_vector3 &res) const
reflect vector across the line with direction vector.
Definition vector3.h:501
a_real dot(a_vector3 const &rhs) const
compute the dot product (scalar product) of two 3D vectors.
Definition vector3.h:459
friend a_vector3 operator*(a_vector3 const &lhs, a_real rhs)
multiplie a 3D vector by a scalar.
Definition vector3.h:561
void mul(a_real rhs, a_vector3 &res) const
multiplie a 3D vector by a scalar.
Definition vector3.h:438
friend a_vector3 operator-(a_vector3 const &rhs)
negate a 3D vector.
Definition vector3.h:578
a_real angle(a_vector3 const &rhs) const
compute the angle between two 3D vectors in radians.
Definition vector3.h:465
int ortho(a_vector3 &u, a_vector3 &v) const
construct an orthonormal basis from a given 3D direction vector.
Definition vector3.h:481
friend a_vector3 operator-(a_vector3 const &lhs, a_vector3 const &rhs)
subtract a 3D vector from a 3D vector.
Definition vector3.h:540
a_real norm() const
compute the magnitude of a 3D vector.
Definition vector3.h:455
void neg(a_vector3 &res) const
negate a 3D vector.
Definition vector3.h:448
a_real set_dir(a_real x_, a_real y_, a_real z_)
set the components of a 3D vector and normalize it in place.
Definition vector3.h:393
void add(a_vector3 const &rhs, a_vector3 &res) const
add a 3D vector to a 3D vector.
Definition vector3.h:428
friend a_real operator*(a_vector3 const &lhs, a_vector3 const &rhs)
compute the dot product (scalar product) of two 3D vectors.
Definition vector3.h:547
void set_sph(a_real rho, a_real theta, a_real alpha)
set the spherical coordinates of a 3D vector.
Definition vector3.h:423
void set_val(a_real x_, a_real y_, a_real z_)
set the cartesian coordinates of a 3D vector.
Definition vector3.h:403
void cross(a_vector3 const &rhs, a_vector3 &res) const
compute the cross product (vector product) of two 3D vectors
Definition vector3.h:471
void sph(a_real &rho, a_real &theta, a_real &alpha) const
get the spherical coordinates of a 3D vector.
Definition vector3.h:418
friend a_vector3 operator/(a_vector3 const &lhs, a_real rhs)
divide a 3D vector by a scalar.
Definition vector3.h:570
void rot(a_vector3 const &dir, a_real angle, a_vector3 &res) const
rotate a 3D vector around an arbitrary unit axis using Rodrigues' rotation formula.
Definition vector3.h:506
friend void operator/=(a_vector3 &lhs, a_real rhs)
divide a 3D vector by a scalar.
Definition vector3.h:568