/*****************************************************************************/
/**
 * @file coord.h
 * @author FanHao (hao_fan_bit_ee@163.com)
 * @version 0.0
 * @date 2023-05-06
 *
 * @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
 * Lab of Communication and Network
 *
 ******************************************************************************/

#ifndef _COORD_H
#define _COORD_H
/**
 * @addtogroup LinkLayer
 * @{
 */

/**
 * @defgroup LinkLayerGeometry
 * @{
 */

/**
 * @defgroup LinkLayerGeometry_Coord
 * @{
 */

/**
 * @struct COORD
 * @brief Structure for storing 3D coordinates.
 */
typedef struct
{
	double x;
	double y;
	double z;
} COORD;

extern const COORD COORD_NIL;
extern const COORD COORD_ZERO;
extern const COORD COORD_ONE;
extern const COORD COORD_X_AXIS;
extern const COORD COORD_Y_AXIS;
extern const COORD COORD_Z_AXIS;

/** @brief Subtracts two coordinate vectors. */
COORD Coord_Sub(COORD a, COORD b);

/** @brief Adds two coordinate vectors. */
COORD Coord_Add(COORD a, COORD b);

/** @brief Multiplies a coordinate vector by a real number. */
void Coord_ScalarMult(COORD *a, double t);

/** @brief Multiplies a coordinate vector by a real number. */
COORD Coord_GetScalarMult(COORD a, double t);

/** @brief Divides a coordinate vector by a real number. */
void Coord_ScalarDiv(COORD *a, double t);

/** @brief Divides a coordinate vector by a real number. */
COORD Coord_GetScalarDiv(COORD a, double t);

/** @brief Dot product. */
double Coord_Dot(COORD a, COORD b);

/** @brief Cross product. */
COORD Coord_Cross(COORD a, COORD b);

/** @brief Multiplies two coordinate vector in elementwise. */
COORD Coord_ElementwiseMult(COORD a, COORD b);

/** @brief Divides two coordinate vector in elementwise. */
COORD Coord_ElementwiseDiv(COORD a, COORD b);

/** @brief Calculate a coordinate vector length^2 (omits calling square root). */
double Coord_SquareLength(COORD a);

/** @brief Calculate a coordinate vector length. */
double Coord_Length(COORD a);

/** @brief Calculate two coordinates' distance. */
double Coord_Distance(COORD a, COORD b);

/** @brief Normalize coordinate vector. */
void Coord_Normalize(COORD *a);

/** @brief Normalize coordinate vector. */
COORD Coord_GetNormalized(COORD a);

/** @brief Returns the angle between the two vectors. */
double Coord_Angle(COORD a, COORD b);

#endif

/** @} LinkLayerGeometry_Coord */

/** @} LinkLayerGeometry */

/** @} LinkLayer */
