liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
vector2.h
Go to the documentation of this file.
1
5
6#ifndef LIBA_VECTOR2_H
7#define LIBA_VECTOR2_H
8
9#include "a.h"
10#include "math.h"
11
17
18/* clang-format off */
20#define A_VECTOR2_C(x, y) {a_real_c(x), a_real_c(y)}
21/* clang-format on */
22
24#define a_vector2_c(x) a_cast_s(a_vector2, x)
25#define a_vector2_(_, x) a_cast_s(a_vector2 _, x)
26
27typedef struct a_vector2 a_vector2;
28
29#if defined(__cplusplus)
30namespace a
31{
32typedef struct a_vector2 vector2;
33} /* namespace a */
34extern "C" {
35#endif /* __cplusplus */
36#if !defined A_HAVE_INLINE || defined(LIBA_VECTOR2_C)
38#undef A_INTERN
39#define A_INTERN A_PUBLIC extern
41#endif /* A_HAVE_INLINE */
42
51A_INTERN void a_vector2_val(a_vector2 const *ctx, a_real *x, a_real *y);
55A_INTERN void a_vector2_set_val(a_vector2 *ctx, a_real x, a_real y);
59A_INTERN void a_vector2_pol(a_vector2 const *ctx, a_real *rho, a_real *theta);
63A_INTERN void a_vector2_set_pol(a_vector2 *ctx, a_real rho, a_real theta);
64
68A_INTERN void a_vector2_add(a_vector2 const *lhs, a_vector2 const *rhs, a_vector2 *res);
72A_INTERN void a_vector2_sub(a_vector2 const *lhs, a_vector2 const *rhs, a_vector2 *res);
76A_INTERN void a_vector2_mul(a_vector2 const *lhs, a_real rhs, a_vector2 *res);
80A_INTERN void a_vector2_div(a_vector2 const *lhs, a_real rhs, a_vector2 *res);
84A_INTERN void a_vector2_neg(a_vector2 const *ctx, a_vector2 *res);
85
102A_EXTERN a_real a_vector2_norm(a_vector2 const *ctx);
113A_INTERN a_real a_vector2_norm2(a_vector2 const *ctx);
127A_EXTERN a_real a_vector2_dist(a_vector2 const *lhs, a_vector2 const *rhs);
141A_INTERN a_real a_vector2_dist2(a_vector2 const *lhs, a_vector2 const *rhs);
155A_INTERN a_real a_vector2_dot(a_vector2 const *lhs, a_vector2 const *rhs);
170A_INTERN a_real a_vector2_cross(a_vector2 const *lhs, a_vector2 const *rhs);
187A_INTERN void a_vector2_outer(a_vector2 const *lhs, a_vector2 const *rhs, a_real res[4]);
195A_INTERN a_bool a_vector2_isver(a_vector2 const *lhs, a_vector2 const *rhs);
203A_INTERN a_bool a_vector2_ispar(a_vector2 const *lhs, a_vector2 const *rhs);
219A_EXTERN a_real a_vector2_angle(a_vector2 const *lhs, a_vector2 const *rhs);
220
233A_EXTERN int a_vector2_decom(a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *u, a_vector2 *v);
234
250A_EXTERN int a_vector2_proj(a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *res);
266A_EXTERN int a_vector2_perp(a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *res);
282A_EXTERN int a_vector2_refl(a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *res);
283
296A_INTERN void a_vector2_lerp(a_vector2 const *lhs, a_vector2 const *rhs, a_real val, a_vector2 *res);
297
312A_INTERN void a_vector2_rot_(a_vector2 const *ctx, a_real sin, a_real cos, a_vector2 *res);
326A_EXTERN void a_vector2_rot(a_vector2 const *ctx, a_real angle, a_vector2 *res);
327
328#if !defined A_HAVE_INLINE || defined(LIBA_VECTOR2_C)
330#undef A_INTERN
331#define A_INTERN static A_INLINE
333#endif /* A_HAVE_INLINE */
334#if defined(__cplusplus)
335} /* extern "C" */
336#endif /* __cplusplus */
337
338struct a_point2;
343{
344 a_real x, y;
345#if defined(__cplusplus)
347 A_INLINE void set(a_point2 const &p, a_point2 const &q);
349 A_INLINE a_real set_dir(a_real x_, a_real y_)
350 {
351 return a_vector2_set_dir(this, x_, y_);
352 }
353
354 A_INLINE void val(a_real &x_, a_real &y_) const
355 {
356 a_vector2_val(this, &x_, &y_);
357 }
358
359 A_INLINE void set_val(a_real x_, a_real y_)
360 {
361 a_vector2_set_val(this, x_, y_);
362 }
363
364 A_INLINE void pol(a_real &rho, a_real &theta) const
365 {
366 a_vector2_pol(this, &rho, &theta);
367 }
368
369 A_INLINE void set_pol(a_real rho, a_real theta)
370 {
371 a_vector2_set_pol(this, rho, theta);
372 }
373
374 A_INLINE void add(a_vector2 const &rhs, a_vector2 &res) const
375 {
376 a_vector2_add(this, &rhs, &res);
377 }
378
379 A_INLINE void sub(a_vector2 const &rhs, a_vector2 &res) const
380 {
381 a_vector2_sub(this, &rhs, &res);
382 }
383
384 A_INLINE void mul(a_real rhs, a_vector2 &res) const
385 {
386 a_vector2_mul(this, rhs, &res);
387 }
388
389 A_INLINE void div(a_real rhs, a_vector2 &res) const
390 {
391 a_vector2_div(this, rhs, &res);
392 }
393
394 A_INLINE void neg(a_vector2 &res) const
395 {
396 a_vector2_neg(this, &res);
397 }
398
399 A_INLINE a_real unit() { return a_vector2_unit(this); }
401 A_INLINE a_real norm() const { return a_vector2_norm(this); }
403 A_INLINE a_real norm2() const { return a_vector2_norm2(this); }
405 A_INLINE a_real dist(a_vector2 const &rhs) const
406 {
407 return a_vector2_dist(this, &rhs);
408 }
409
410 A_INLINE a_real dist2(a_vector2 const &rhs) const
411 {
412 return a_vector2_dist2(this, &rhs);
413 }
414
415 A_INLINE a_real dot(a_vector2 const &rhs) const
416 {
417 return a_vector2_dot(this, &rhs);
418 }
419
420 A_INLINE a_real cross(a_vector2 const &rhs) const
421 {
422 return a_vector2_cross(this, &rhs);
423 }
424
425 A_INLINE void outer(a_vector2 const &rhs, a_real res[4]) const
426 {
427 a_vector2_outer(this, &rhs, res);
428 }
429
430 A_INLINE a_bool isver(a_vector2 const &rhs) const
431 {
432 return a_vector2_isver(this, &rhs);
433 }
434
435 A_INLINE a_bool ispar(a_vector2 const &rhs) const
436 {
437 return a_vector2_ispar(this, &rhs);
438 }
439
440 A_INLINE a_real angle(a_vector2 const &rhs) const
441 {
442 return a_vector2_angle(this, &rhs);
443 }
444
445 A_INLINE int decom(a_vector2 const &dir, a_vector2 &u, a_vector2 &v) const
446 {
447 return a_vector2_decom(this, &dir, &u, &v);
448 }
449
450 A_INLINE int proj(a_vector2 const &dir, a_vector2 &res) const
451 {
452 return a_vector2_proj(this, &dir, &res);
453 }
454
455 A_INLINE int perp(a_vector2 const &dir, a_vector2 &res) const
456 {
457 return a_vector2_perp(this, &dir, &res);
458 }
459
460 A_INLINE int refl(a_vector2 const &dir, a_vector2 &res) const
461 {
462 return a_vector2_refl(this, &dir, &res);
463 }
464
465 A_INLINE void lerp(a_vector2 const &rhs, a_real val, a_vector2 &res) const
466 {
467 a_vector2_lerp(this, &rhs, val, &res);
468 }
469
470 A_INLINE void rot(a_real angle, a_vector2 &res) const
471 {
472 a_vector2_rot(this, angle, &res);
473 }
474
475 A_INLINE void rot(a_real sin, a_real cos, a_vector2 &res) const
476 {
477 a_vector2_rot_(this, sin, cos, &res);
478 }
479
480 friend A_INLINE a_real operator^(a_vector2 const &lhs, a_vector2 const &rhs)
481 {
482 return a_vector2_cross(&lhs, &rhs);
483 }
484
485 friend A_INLINE void operator+=(a_vector2 &lhs, a_vector2 const &rhs) { a_vector2_add(&lhs, &rhs, &lhs); }
487 friend A_INLINE a_vector2 operator+(a_vector2 const &lhs, a_vector2 const &rhs)
488 {
489 a_vector2 res;
490 a_vector2_add(&lhs, &rhs, &res);
491 return res;
492 }
493
494 friend A_INLINE void operator-=(a_vector2 &lhs, a_vector2 const &rhs) { a_vector2_sub(&lhs, &rhs, &lhs); }
496 friend A_INLINE a_vector2 operator-(a_vector2 const &lhs, a_vector2 const &rhs)
497 {
498 a_vector2 res;
499 a_vector2_sub(&lhs, &rhs, &res);
500 return res;
501 }
502
503 friend A_INLINE a_real operator*(a_vector2 const &lhs, a_vector2 const &rhs)
504 {
505 return a_vector2_dot(&lhs, &rhs);
506 }
507
508 friend A_INLINE void operator*=(a_vector2 &lhs, a_real rhs) { a_vector2_mul(&lhs, rhs, &lhs); }
510 friend A_INLINE a_vector2 operator*(a_real lhs, a_vector2 const &rhs)
511 {
512 a_vector2 res;
513 a_vector2_mul(&rhs, lhs, &res);
514 return res;
515 }
516
517 friend A_INLINE a_vector2 operator*(a_vector2 const &lhs, a_real rhs)
518 {
519 a_vector2 res;
520 a_vector2_mul(&lhs, rhs, &res);
521 return res;
522 }
523
524 friend A_INLINE void operator/=(a_vector2 &lhs, a_real rhs) { a_vector2_div(&lhs, rhs, &lhs); }
526 friend A_INLINE a_vector2 operator/(a_vector2 const &lhs, a_real rhs)
527 {
528 a_vector2 res;
529 a_vector2_div(&lhs, rhs, &res);
530 return res;
531 }
532 friend A_INLINE a_vector2 operator+(a_vector2 const &rhs) { return rhs; }
534 friend A_INLINE a_vector2 operator-(a_vector2 const &rhs)
535 {
536 a_vector2 res;
537 a_vector2_neg(&rhs, &res);
538 return res;
539 }
540#endif /* __cplusplus */
541};
542
543#if defined(LIBA_VECTOR2_C)
545#undef A_INTERN
546#define A_INTERN A_INLINE
548#endif /* LIBA_VECTOR2_C */
549#if defined(A_HAVE_INLINE) || defined(LIBA_VECTOR2_C)
550
552{
553 ctx->x = x;
554 ctx->y = y;
555 return a_vector2_unit(ctx);
556}
557A_INTERN void a_vector2_val(a_vector2 const *ctx, a_real *x, a_real *y)
558{
559 *x = ctx->x;
560 *y = ctx->y;
561}
562A_INTERN void a_vector2_set_val(a_vector2 *ctx, a_real x, a_real y)
563{
564 ctx->x = x;
565 ctx->y = y;
566}
567A_INTERN void a_vector2_pol(a_vector2 const *ctx, a_real *rho, a_real *theta)
568{
569 a_real_cart2pol(ctx->x, ctx->y, rho, theta);
570}
571A_INTERN void a_vector2_set_pol(a_vector2 *ctx, a_real rho, a_real theta)
572{
573 a_real_pol2cart(rho, theta, &ctx->x, &ctx->y);
574}
575A_INTERN void a_vector2_add(a_vector2 const *lhs, a_vector2 const *rhs, a_vector2 *res)
576{
577 res->x = lhs->x + rhs->x;
578 res->y = lhs->y + rhs->y;
579}
580A_INTERN void a_vector2_sub(a_vector2 const *lhs, a_vector2 const *rhs, a_vector2 *res)
581{
582 res->x = lhs->x - rhs->x;
583 res->y = lhs->y - rhs->y;
584}
585A_INTERN void a_vector2_mul(a_vector2 const *lhs, a_real rhs, a_vector2 *res)
586{
587 res->x = lhs->x * rhs;
588 res->y = lhs->y * rhs;
589}
590A_INTERN void a_vector2_div(a_vector2 const *lhs, a_real rhs, a_vector2 *res)
591{
592 res->x = lhs->x / rhs;
593 res->y = lhs->y / rhs;
594}
595A_INTERN void a_vector2_neg(a_vector2 const *ctx, a_vector2 *res)
596{
597 res->x = -ctx->x;
598 res->y = -ctx->y;
599}
600
601A_INTERN a_real a_vector2_norm2(a_vector2 const *ctx)
602{
603 return ctx->x * ctx->x + ctx->y * ctx->y;
604}
605
606A_INTERN a_real a_vector2_dist2(a_vector2 const *lhs, a_vector2 const *rhs)
607{
608 a_real const x = rhs->x - lhs->x;
609 a_real const y = rhs->y - lhs->y;
610 return x * x + y * y;
611}
612
613A_INTERN a_real a_vector2_dot(a_vector2 const *lhs, a_vector2 const *rhs)
614{
615 return lhs->x * rhs->x + lhs->y * rhs->y;
616}
617
618A_INTERN a_real a_vector2_cross(a_vector2 const *lhs, a_vector2 const *rhs)
619{
620 return lhs->x * rhs->y - lhs->y * rhs->x;
621}
622
623A_INTERN void a_vector2_outer(a_vector2 const *lhs, a_vector2 const *rhs, a_real res[4])
624{
625 res[0] = lhs->x * rhs->x;
626 res[1] = lhs->x * rhs->y;
627 res[2] = lhs->y * rhs->x;
628 res[3] = lhs->y * rhs->y;
629}
630
631A_INTERN a_bool a_vector2_isver(a_vector2 const *lhs, a_vector2 const *rhs)
632{
633 a_real const r = lhs->x * rhs->x + lhs->y * rhs->y;
634 return A_ABS(r) < A_REAL_TOL;
635}
636
637A_INTERN a_bool a_vector2_ispar(a_vector2 const *lhs, a_vector2 const *rhs)
638{
639 a_real const r = lhs->x * rhs->y - lhs->y * rhs->x;
640 return A_ABS(r) < A_REAL_TOL;
641}
642
643A_INTERN void a_vector2_lerp(a_vector2 const *lhs, a_vector2 const *rhs, a_real val, a_vector2 *res)
644{
645 res->x = lhs->x + (rhs->x - lhs->x) * val;
646 res->y = lhs->y + (rhs->y - lhs->y) * val;
647}
648
649A_INTERN void a_vector2_rot_(a_vector2 const *ctx, a_real sin, a_real cos, a_vector2 *res)
650{
651 a_real const x = cos * ctx->x - sin * ctx->y;
652 a_real const y = sin * ctx->x + cos * ctx->y;
653 res->x = x;
654 res->y = y;
655}
656
657#endif /* A_HAVE_INLINE */
658#if defined(LIBA_VECTOR2_C)
660#undef A_INTERN
661#define A_INTERN static A_INLINE
663#endif /* LIBA_VECTOR2_C */
664
666
667#endif /* a/vector2.h */
algorithm library
void set(a_point2 const &p, a_point2 const &q)
set a 2D vector as the difference from point p to point q.
Definition point2.h:254
double a_real
compiler built-in floating-point number type
Definition a.h:1012
int a_vector2_decom(a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *u, a_vector2 *v)
decompose a 2D vector into two orthogonal components relative to a given direction.
void a_vector2_add(a_vector2 const *lhs, a_vector2 const *rhs, a_vector2 *res)
add a 2D vector to a 2D vector.
void a_vector2_set_val(a_vector2 *ctx, a_real x, a_real y)
set the cartesian coordinates of a 2D vector.
a_real a_vector2_set_dir(a_vector2 *ctx, a_real x, a_real y)
set the components of a 2D vector and normalize it in place.
void a_vector2_mul(a_vector2 const *lhs, a_real rhs, a_vector2 *res)
multiplie a 2D vector by a scalar.
void a_vector2_pol(a_vector2 const *ctx, a_real *rho, a_real *theta)
get the polar coordinates of a 2D vector.
void a_vector2_lerp(a_vector2 const *lhs, a_vector2 const *rhs, a_real val, a_vector2 *res)
compute linear interpolation (LERP) between two 2D vectors.
a_bool a_vector2_ispar(a_vector2 const *lhs, a_vector2 const *rhs)
check if two 2D vectors are parallel or anti-parallel.
a_real a_vector2_norm2(a_vector2 const *ctx)
compute the squared magnitude of a 2D vector.
a_bool a_vector2_isver(a_vector2 const *lhs, a_vector2 const *rhs)
check if two 2D vectors are orthogonal.
void a_vector2_set_pol(a_vector2 *ctx, a_real rho, a_real theta)
set the polar coordinates of a 2D vector.
a_real a_vector2_cross(a_vector2 const *lhs, a_vector2 const *rhs)
compute the cross product (vector product) of two 2D vectors
a_real a_vector2_dot(a_vector2 const *lhs, a_vector2 const *rhs)
compute the dot product (scalar product) of two 2D vectors.
a_real a_vector2_norm(a_vector2 const *ctx)
compute the magnitude of a 2D vector.
a_real a_vector2_unit(a_vector2 *ctx)
normalize a 2D vector in-place to unit length.
int a_vector2_proj(a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *res)
project vector onto the direction of vector.
void a_vector2_div(a_vector2 const *lhs, a_real rhs, a_vector2 *res)
divide a 2D vector by a scalar.
a_real a_vector2_dist2(a_vector2 const *lhs, a_vector2 const *rhs)
compute the squared distance between two 2D vectors.
void a_vector2_neg(a_vector2 const *ctx, a_vector2 *res)
negate a 2D vector.
void a_vector2_outer(a_vector2 const *lhs, a_vector2 const *rhs, a_real res[4])
compute the outer product (tensor product) of two 2D vectors.
a_real a_vector2_angle(a_vector2 const *lhs, a_vector2 const *rhs)
compute the angle between two 2D vectors in radians.
void a_vector2_sub(a_vector2 const *lhs, a_vector2 const *rhs, a_vector2 *res)
subtract a 2D vector from a 2D vector.
int a_vector2_perp(a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *res)
project vector onto the line perpendicular to vector.
int a_vector2_refl(a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *res)
reflect vector across the line with direction vector.
void a_vector2_val(a_vector2 const *ctx, a_real *x, a_real *y)
get the cartesian coordinates of a 2D vector.
void a_vector2_rot_(a_vector2 const *ctx, a_real sin, a_real cos, a_vector2 *res)
rotate a 2D vector by a specified angle (in radians).
a_real a_vector2_dist(a_vector2 const *lhs, a_vector2 const *rhs)
compute the distance between two 2D vectors.
void a_vector2_rot(a_vector2 const *ctx, a_real angle, a_vector2 *res)
rotate a 2D vector by a specified angle (in radians).
#define A_ABS(x)
absolute value of x,
Definition a.h:1062
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 two-dimensional point
Definition point2.h:264
instance structure for two-dimensional vector
Definition vector2.h:343
a_real unit()
normalize a 2D vector in-place to unit length.
Definition vector2.h:399
a_bool isver(a_vector2 const &rhs) const
check if two 2D vectors are orthogonal.
Definition vector2.h:430
friend a_real operator^(a_vector2 const &lhs, a_vector2 const &rhs)
compute the cross product (vector product) of two 2D vectors
Definition vector2.h:480
void rot(a_real angle, a_vector2 &res) const
rotate a 2D vector by a specified angle (in radians).
Definition vector2.h:470
void pol(a_real &rho, a_real &theta) const
get the polar coordinates of a 2D vector.
Definition vector2.h:364
friend a_vector2 operator*(a_real lhs, a_vector2 const &rhs)
multiplie a 2D vector by a scalar.
Definition vector2.h:510
void rot(a_real sin, a_real cos, a_vector2 &res) const
rotate a 2D vector by a specified angle (in radians).
Definition vector2.h:475
friend a_vector2 operator/(a_vector2 const &lhs, a_real rhs)
divide a 2D vector by a scalar.
Definition vector2.h:526
friend a_real operator*(a_vector2 const &lhs, a_vector2 const &rhs)
compute the dot product (scalar product) of two 2D vectors.
Definition vector2.h:503
void div(a_real rhs, a_vector2 &res) const
divide a 2D vector by a scalar.
Definition vector2.h:389
a_real cross(a_vector2 const &rhs) const
compute the cross product (vector product) of two 2D vectors
Definition vector2.h:420
a_real dist2(a_vector2 const &rhs) const
compute the squared distance between two 2D vectors.
Definition vector2.h:410
a_real dist(a_vector2 const &rhs) const
compute the distance between two 2D vectors.
Definition vector2.h:405
int perp(a_vector2 const &dir, a_vector2 &res) const
project vector onto the line perpendicular to vector.
Definition vector2.h:455
void lerp(a_vector2 const &rhs, a_real val, a_vector2 &res) const
compute linear interpolation (LERP) between two 2D vectors.
Definition vector2.h:465
a_real dot(a_vector2 const &rhs) const
compute the dot product (scalar product) of two 2D vectors.
Definition vector2.h:415
void add(a_vector2 const &rhs, a_vector2 &res) const
add a 2D vector to a 2D vector.
Definition vector2.h:374
friend a_vector2 operator+(a_vector2 const &lhs, a_vector2 const &rhs)
add a 2D vector to a 2D vector.
Definition vector2.h:487
int refl(a_vector2 const &dir, a_vector2 &res) const
reflect vector across the line with direction vector.
Definition vector2.h:460
a_real norm() const
compute the magnitude of a 2D vector.
Definition vector2.h:401
void val(a_real &x_, a_real &y_) const
get the cartesian coordinates of a 2D vector.
Definition vector2.h:354
friend a_vector2 operator*(a_vector2 const &lhs, a_real rhs)
multiplie a 2D vector by a scalar.
Definition vector2.h:517
void mul(a_real rhs, a_vector2 &res) const
multiplie a 2D vector by a scalar.
Definition vector2.h:384
void neg(a_vector2 &res) const
negate a 2D vector.
Definition vector2.h:394
friend void operator+=(a_vector2 &lhs, a_vector2 const &rhs)
add a 2D vector to a 2D vector.
Definition vector2.h:485
void set_val(a_real x_, a_real y_)
set the cartesian coordinates of a 2D vector.
Definition vector2.h:359
friend a_vector2 operator-(a_vector2 const &rhs)
negate a 2D vector.
Definition vector2.h:534
int proj(a_vector2 const &dir, a_vector2 &res) const
project vector onto the direction of vector.
Definition vector2.h:450
friend void operator/=(a_vector2 &lhs, a_real rhs)
divide a 2D vector by a scalar.
Definition vector2.h:524
friend void operator-=(a_vector2 &lhs, a_vector2 const &rhs)
subtract a 2D vector from a 2D vector.
Definition vector2.h:494
void sub(a_vector2 const &rhs, a_vector2 &res) const
subtract a 2D vector from a 2D vector.
Definition vector2.h:379
friend void operator*=(a_vector2 &lhs, a_real rhs)
multiplie a 2D vector by a scalar.
Definition vector2.h:508
void outer(a_vector2 const &rhs, a_real res[4]) const
compute the outer product (tensor product) of two 2D vectors.
Definition vector2.h:425
a_bool ispar(a_vector2 const &rhs) const
check if two 2D vectors are parallel or anti-parallel.
Definition vector2.h:435
int decom(a_vector2 const &dir, a_vector2 &u, a_vector2 &v) const
decompose a 2D vector into two orthogonal components relative to a given direction.
Definition vector2.h:445
friend a_vector2 operator-(a_vector2 const &lhs, a_vector2 const &rhs)
subtract a 2D vector from a 2D vector.
Definition vector2.h:496
a_real set_dir(a_real x_, a_real y_)
set the components of a 2D vector and normalize it in place.
Definition vector2.h:349
void set_pol(a_real rho, a_real theta)
set the polar coordinates of a 2D vector.
Definition vector2.h:369
a_real norm2() const
compute the squared magnitude of a 2D vector.
Definition vector2.h:403
a_real angle(a_vector2 const &rhs) const
compute the squared distance between two 2D vectors.
Definition vector2.h:440